views:

68

answers:

1

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&lt;/Play&gt;
</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.

+2  A: 

Although I almost don't have a clue about what you are talking, since nobody sofar said anything I will have a shot at it (don't shoot me if I'm totally not in the direction).

In MVC 2 you can render actions in your views:

<%= Html.Action("home", "menu" , new { someparam = somevalue, someotherparam = someothervalue }) %>

This would call the Menu action in your Home controller with the given parameters. The Result of this Action would then be inserted in your view.
This way you can keep your views clean, and all your Menu stuff in one place. Just have to add the above stated line in every view.

Again the same can be done with HtmlHelper's, yet sometimes the above stated way is just easier.

Gidon
You have somehow managed to read my mind! This is exactly what I was trying to get to, how to store a series of actions to be performed given a particular input. Awesome!
Chris McCall
I'm happy I could help.
Gidon