IVRPhoneTree.Web/Controllers/MenuController.cs
_58using System;_58using System.Collections.Generic;_58using System.Web.Mvc;_58using Twilio.AspNet.Mvc;_58using Twilio.TwiML;_58using Twilio.TwiML.Voice;_58_58namespace IVRPhoneTree.Web.Controllers_58{_58 public class MenuController : ControllerBase_58 {_58 // POST: Menu/Show_58 [HttpPost]_58 public ActionResult Show(string digits)_58 {_58 var selectedOption = digits;_58 var optionActions = new Dictionary<string, Func<ActionResult>>()_58 {_58 {"1", ReturnInstructions},_58 {"2", Planets}_58 };_58_58 return optionActions.ContainsKey(selectedOption) ?_58 optionActions[selectedOption]() :_58 RedirectWelcome();_58 }_58_58 private TwiMLResult ReturnInstructions()_58 {_58 var response = new VoiceResponse();_58 response.Say("To get to your extraction point, get on your bike and go down " +_58 "the street. Then Left down an alley. Avoid the police cars. Turn left " +_58 "into an unfinished housing development. Fly over the roadblock. Go " +_58 "passed the moon. Soon after you will see your mother ship.",_58 voice: Say.VoiceEnum.PollyAmy, language: "en-GB");_58_58 response.Say("Thank you for calling the E.T. Phone Home Service - the " +_58 "adventurous alien's first choice in intergalactic travel. Good bye.");_58_58 response.Hangup();_58_58 return TwiML(response);_58 }_58_58 private TwiMLResult Planets()_58 {_58 var response = new VoiceResponse();_58 var gather = new Gather(action: Url.ActionUri("Interconnect", "PhoneExchange"), numDigits: 1);_58 gather.Say("To call the planet Broh doe As O G, press 2. To call the planet " +_58 "DuhGo bah, press 3. To call an oober asteroid to your location, press 4. To " +_58 "go back to the main menu, press the star key ",_58 voice: Say.VoiceEnum.PollyAmy, language: "en-GB", loop: 3);_58 response.Append(gather);_58_58 return TwiML(response);_58 }_58 }_58}
That was only the main menu and the first option. If the caller chooses 2, we will take them to The Planet Directory in order to collect more input.