I'm making an IVR system for a project, and have decided on Twilio to handle the phone portion (making and receiving calls, sending and receiving SMS messages). This will surface a website with an IVR front-end, allowing users to navigate the site using their touch-tone phone.
I'm not making all the content browse-able over the phone, just what makes sense.
Twilio sends in parameters to your URL on the querystring or via POST, and you respond with a special subset of XML that tells the IVR how to act. I made a lot of headway very quickly with ASP.net MVC, treating the Twilio XML content as a View and rendering the site's data to it.
Here's what a response to Twilio looks like:
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Say>Hello World</Say>
<Play>http://api.twilio.com/Cowbell.mp3</Play>
</Response>
Here's what a menu looks like to Twilio:
<?xml version="1.0" encoding="UTF-8" ?>
<Gather action="http://your_url" numdigits="1">
<Say>Press 1 to execute your_url, passing a parameter named "digits"</Say>
</Response>
Here's where I'm stuck:
I'm trying to add a universal "back" button, maybe a "skip" button, a "repeat" button, etc, and I'm finding that on each view, I'm detecting the digit pressed and then if-ing to a hardcoded Response.Redirect()
. I know this is going to quickly become unmaintainable for large numbers of views and menus.
So, how can I model the MVC app so that it's more like an application and less like a game of Zork? Stacks of Menu objects, each with Lists of MenuItem objects? How can I make, say "9" the universal option for "back" and have the app respect it, no matter where in the menu system the user is, without having to code for it in each view?
The back feature is just a symptom of the chaos this project will step into if I don't take a moment now to design it properly. Are there .net IVR frameworks out there I can inspect for ideas? Any help would be appreciated, I know this is not a novel problem, I just can't seem to get my head around the best path to take.