IVR vs Asp.net MVC: How can I stop reinventing the browser?

I am creating an IVR system for the project and decided to Twilio process part of the phone (creating and receiving calls, sending and receiving SMS messages). This will open a website with an IVR interface, allowing users to navigate the site using a touch-tone telephone.

I do not make all the content available for viewing by phone, which makes sense.

Twilio sends the parameters to your url in querystring or through POST, and you respond with a special subset of XML that tells IVR how to proceed. I progressed very quickly with ASP.net MVC, viewing the content of Twilio XML as representing and rendering site data.

Here's what Twilio's answer 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 the Twilio menu looks like:

 <?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 where I am stuck:

I am trying to add a universal back button, perhaps a skip button, a repeat button, etc., and I find that on each view I find the digit pressed, and then if it is hard-coded Response.Redirect() . I know that this will quickly become unattainable for a large number of views and menus.

So, how can I simulate an MVC application to look more like an application and not like a Zork game? Stacks of menu objects, each with lists of MenuItem objects? How can I make, say, "9" a universal option for "back" and maintain the application, no matter where the user is in the menu system, without having a code for this in every view?

The backward function is just a symptom of the chaos this project will enter into if I don’t draw it right now. Are there .net IVR frameworks out there, can I check for ideas? Any help would be appreciated, I know that this is not a new problem, I just can’t figure out how best to go.

+4
source share
2 answers

Although I almost do not know what you're talking about, since no one said anything that I will have a shot at him (do not shoot me if I am completely not in that direction).

In MVC 2, you can display actions in your views:

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

This will trigger the Menu action in your Home controller with the specified parameters. Result this Action will then be inserted into your view.
This way you can keep your views clean and your entire menu in one place. Just add the above line to all views.

Again, the same thing can be done with HtmlHelper 's, but sometimes the above method is simply simpler.

+2
source

Ricky from Twilio is here.

For some reason, code organized like Zork sounds like fun to me, but in practice I can figure out how it can drive someone crazy!

We just launched a bunch of non-trivial production-ready tutorials to help developers ask a question about how to organize a specific kind of application. One tutorial is an IVR built using C # with ASP.NET MVC .

Having a look at how we decided to structure things, we use 3 controllers to control our logic:

  • IVRController.cs . This controller contains a code that greets the user when he calls our IVR.
  • MenuController.cs . In this controller, we define the appropriate IVR menu for the user depending on their inputs.
  • PhoneExchangeController.cs . In this controller, we have the logic for forwarding a call from our IVR to another phone number.

As you want to customize the experience by adding something like “Press 9 to return,” making changes to MenuController.cs should help you there.

0
source

Source: https://habr.com/ru/post/1303464/


All Articles