public TwiMLResult Gather(VoiceRequest request) { var response = new TwilioResponse(); // If the user entered digits, process their request if (!string.IsNullOrEmpty(request.Digits)) { switch (request.Digits) { case "1": response.Say("You selected sales. Good for you!"); break; case "2": response.Say("You need support. We will help!"); break; default: response.Say("Sorry, I don't understand that choice.").Pause(); response.Redirect("/voice"); break; } } else { // If no input was sent, redirect to the /voice route response.Redirect("/voice"); } return(TwiML(response)); }
public ActionResult CaptureAnswer(string CallSid, int Digits) { var gameState = QuizShowState.Load(CallSid); var currentQuestion = gameState.Questions[gameState.CurrentQuestionIndex]; var orderedAnswers = currentQuestion.PossibleAnswers.OrderBy(a => a.Order).ToList(); var selectedAnswer = orderedAnswers[Digits]; var response = new TwilioResponse(); if (selectedAnswer.IsCorrect) { gameState.CorrectAnswerCount++; response.Say("Correct! . Well done. "); if (gameState.CurrentQuestionIndex >= 4) { response.Say("That was the last question. Lets see how you did."); response.Redirect(Url.ActionAbsolute("CalculateResults"), "GET"); } else { gameState.CurrentQuestionIndex++; response.Say("Lets try the next question."); response.Redirect(Url.ActionAbsolute("ReadQuestion"), "GET"); } } else { response.Say("Incorrect! . "); if (gameState.CurrentQuestionIndex >= 4) { response.Say("That was the last question. Lets see how you did."); response.Redirect(Url.ActionAbsolute("CalculateResults"), "GET"); } else { gameState.CurrentQuestionIndex++; response.Say("Lets try the next question."); response.Redirect(Url.ActionAbsolute("ReadQuestion"), "GET"); } } gameState.Save(); return(TwiML(response)); }
public ActionResult ServiceRequest(string CallSid, string Digits) { var call = GetCall(CallSid); TwilioResponse response = new TwilioResponse(); switch (Digits) { case "0": { StateManager.AddToLog(CallSid, string.Format("User selected option {0} from service selection.", "Return to Menu")); response.Say("Returning to the main menu."); response.Redirect(Url.Action("IncomingCall")); } break; case "1": { StateManager.AddToLog(CallSid, string.Format("User selected option {0} from service selection.", "Manage Account")); response.BeginGather( new { action = Url.Action("ManageAccount"), timeout = 120, method = "POST", numDigits = 8 }); response.Say("Please enter your 8 digit account number"); response.EndGather(); } break; case "2": { StateManager.AddToLog(CallSid, string.Format("User selected option {0} from service selection.", "Take a Loan")); response.Say( "All of our loan officers are currently giving money away to people less deserving than you."); } break; case "3": { StateManager.AddToLog(CallSid, string.Format("User selected option {0} from service selection.", "Talk to a Representative")); } break; default: { response.Say("Oy vey."); response.Redirect(Url.Action("IncomingCall")); } break; } return(SendTwilioResult(response)); }
public void Can_Generate_Single_Redirect_With_Method() { var response = new TwilioResponse(); response.Redirect("url", "GET"); Assert.IsTrue(IsValidTwiML(response.ToXDocument())); }
public void Example_1() { var response = new TwilioResponse(); response.Redirect("http://www.foo.com/nextInstructions"); Assert.IsTrue(IsValidTwiML(response.ToXDocument())); }
public HttpResponseMessage Post(VoiceRequest request) { var response = new TwilioResponse(); var option = (request != null) ? request.Digits : string.Empty; switch (option) { case "1": response.Say("Please say your name and provide your feedback. Press the pound key when you are finished."); response.Record(new { playBeep = "true", transcribe = "true", finishOnKey = "#", action = CallCreateController.URL }); break; case "2": response.Say("Enter the feedback id number followed by pound."); response.Gather(new { finishOnKey = "#", action = CallLookupController.URL }); break; default: response.Say("You've entered an invalid option."); response.Redirect(CallHomeController.URL); break; } return(this.Request.CreateResponse( HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter())); }
public HttpResponseMessage Post(VoiceRequest request) { var response = new TwilioResponse(); var transcrib = (request != null) ? request.TranscriptionText : "Request is null"; var recording = (request != null) ? request.RecordingUrl : "Request is null"; if (request != null) { var number = TwilioHelper.GetNumber(request.CallSid); var id = DataStore.Instance.Create( new Feedback { Submitter = "Twilio", Phone = number, Message = recording }); response.Say("Thank you for your feedback."); response.Say(string.Format("Your item number is {0}. Goodbye.", id)); response.Hangup(); } response.Redirect(CallHomeController.URL); return(this.Request.CreateResponse( HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter())); }
public void Example_2() { var response = new TwilioResponse(); response.Redirect("../nextInstructions"); Assert.IsTrue(IsValidTwiML(response.ToXDocument())); }
public TwilioResponse SetEvent([FromUri] string evtIds, [FromUri] string next, TwilioRequest request) { var response = new TwilioResponse(); if (!Regex.IsMatch(evtIds, "^[\\.0-9]+$")) { log.ErrorFormat("Offered events in bad format: {0}", evtIds); BuildSetEventMenu(response, Speeches.InvalidSelection, next); return(response); } var offeredEvents = evtIds.Split('.').Select(f => int.Parse(f)).ToArray(); int selected; if (!int.TryParse(request.Digits, out selected)) { log.ErrorFormat("Digits {0} are not an integer", request.Digits); BuildSetEventMenu(response, Speeches.InvalidSelection, next); return(response); } if (selected < 1 || selected > offeredEvents.Length) { BuildSetEventMenu(response, Speeches.InvalidSelection, next); return(response); } session.EventId = offeredEvents[selected - 1]; response.Redirect((next ?? Url.Content("~/api/Voice/Menu")) + session.ToQueryString()); return(LogResponse(response)); }
public void Example_2() { var response = new TwilioResponse(); response.Redirect("../nextInstructions"); Assert.True(IsValidTwiML(response.ToXDocument())); }
public void Can_Generate_Single_Redirect_With_Method() { var response = new TwilioResponse(); response.Redirect("url", "GET"); Assert.IsTrue(IsValidTwiML(response.ToXDocument())); }
public void Example_1() { var response = new TwilioResponse(); response.Redirect("http://www.foo.com/nextInstructions"); Assert.IsTrue(IsValidTwiML(response.ToXDocument())); }
public ActionResult LeaveGameExperience() { var response = new TwilioResponse(); response.Say("Thanks for playing a game."); response.Redirect(Url.ActionAbsolute("BasicWaitExperience")); return(TwiML(response)); }
// helper function to set up a <Gather> private static void RenderMainMenu(TwilioResponse response) { response.BeginGather(new { numDigits = 1 }); response.Say("For sales, press 1. For support, press 2."); response.EndGather(); // If the user doesn't enter input, loop response.Redirect("/voice"); }
public ActionResult BadResponse() { var response = new TwilioResponse(); response.Say("This call will self destruct in 5 seconds"); response.Pause(5); response.Redirect(Url.Action("Boom", "Fallback", null, "http")); return(TwiML(response)); }
public void Advanced() { var response = new TwilioResponse(); response.BeginGather(new { action = "/process_gather.php", method = "GET" }); response.Say("Enter something, or not"); response.EndGather(); response.Redirect("/process_gather.php?Digits=TIMEOUT", "GET"); Assert.IsTrue(IsValidTwiML(response.ToXDocument())); }
public TwiMLResult RedirectWelcome() { var response = new TwilioResponse(); response.Say("Returning to the main menu", new { voice = "alice", language = "en-GB" }); response.Redirect(Url.Action("Welcome", "IVR")); return(new TwiMLResult(response)); }
public void Advanced() { var response = new TwilioResponse(); response.BeginGather(new { action = "/process_gather.php", method = "GET" }); response.Say("Enter something, or not"); response.EndGather(); response.Redirect("/process_gather.php?Digits=TIMEOUT", "GET"); Assert.IsTrue(IsValidTwiML(response.ToXDocument())); }
public async Task <TwilioResponse> DoMenu(TwilioRequest request) { var response = new TwilioResponse(); if (request.Digits == "1") { var now = TimeUtils.GetLocalDateTime(this.config); var newEvent = new SarEvent { Name = "New Event at " + TimeUtils.GetMiltaryTimeVoiceText(now), Opened = now }; await this.eventService.Create(newEvent); LoadActiveEvents(); this.session.EventId = newEvent.Id; BeginMenu(response); response.SayVoice("Created " + newEvent.Name); await EndMenu(response); } else if (request.Digits == "2") { using (var db = dbFactory()) { BuildSetEventMenu(response, string.Empty, Url.Content("~/api/VoiceAdmin/Menu")); } } else if (request.Digits == "3") { response.SayVoice("Record a short description of this event at the tone"); response.Record(new { maxLength = 120, action = GetAction("SetDescription", controller: "VoiceAdmin") }); BeginMenu(response); await EndMenu(response); } else if (request.Digits == "9") { Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("targetId", this.session.EventId.ToString()); response.BeginGather(new { numDigits = 1, action = GetAction("ConfirmClose", args, controller: "VoiceAdmin"), timeout = 10 }); response.SayVoice("Press 9 to confirm close of {0}. Press any other key to return to menu.", GetEventName()); response.EndGather(); } else if (request.Digits == "0") { response.Redirect(GetAction("Menu")); } else { response.SayVoice("I didn't understand."); BeginMenu(response); await EndMenu(response); } return(response); }
// Webhook for Twilio survey number // GET: connectcall public ActionResult ConnectCall() { var response = new TwilioResponse(); var survey = _surveysRepository.FirstOrDefault(); var welcomeMessage = string.Format("Thank you for taking the {0} survey", survey.Title); response.Say(welcomeMessage); response.Redirect(Url.Action("find", "questions", new { id = 1 })); return(TwiML(response)); }
public ActionResult Introduction(string CallSid) { var quizShow = QuizShowState.CreateAndSave(CallSid); var response = new TwilioResponse(); response.Say("Welcome to the Twilio Quiz Show! Playing the game is simple. Just answer 5 trivia questions."); response.Say("Are you ready? . "); response.Redirect(Url.ActionAbsolute("ReadQuestion"), "GET"); return(TwiML(response)); }
public ActionResult NoAnswerProvided(string CallSid) { var gameState = QuizShowState.Load(CallSid); var response = new TwilioResponse(); if (gameState.CurrentQuestionIndex >= 4) { response.Say("I didn't hear your answer in time. That was the last question. Lets see how you did."); response.Redirect(Url.ActionAbsolute("CalculateResults"), "GET"); } else { gameState.CurrentQuestionIndex++; response.Say("I didn't hear your answer in time. Lets try the next question."); response.Redirect(Url.ActionAbsolute("ReadQuestion"), "GET"); } gameState.Save(); return(TwiML(response)); }
public TwiMLResult Index(VoiceRequest request) { var response = new TwilioResponse(); // Use the <Gather> verb to collect user input response.BeginGather(new { numDigits = 1 }); response.Say("For sales, press 1. For support, press 2."); response.EndGather(); // If the user doesn't enter input, loop response.Redirect("/voice"); return(TwiML(response)); }
public ActionResult ProcessCommand(string From, string Digits) { var response = new TwilioResponse(); var participants = LoadParticipants(); if (Digits == "6") { participants[From] = !(bool)participants[From]; response.Redirect(Url.Action("PlaceInConference", new { mute = participants[From] })); System.Web.HttpContext.Current.Cache["participants"] = participants; } return(TwiML(response)); }
public HttpResponseMessage Start(VoiceRequest request) { var response = new TwilioResponse(); // "Thank you for calling about the home at 1 3 4 West Ellsworth Avenue." response.Play("/audio/thank_you.mp3"); response.Sms("Curtis call notification: From " + request.From, new { to = MyCell, from = ThisNumber }); response.Redirect("menu"); return(TWiML(response)); }
public HttpResponseMessage Post(VoiceRequest request) { var pin = request.Digits; var authenticated = AuthenticationService.Authenticate(pin); if (!authenticated) { throw new InvalidPinException(pin); } var response = new TwilioResponse(); response.Say("Pin code is valid."); response.Redirect(string.Format("/api/User?pin={0}", pin)); return(this.TwiMLResponse(response)); }
public async Task <TwilioResponse> SetSigninEvent(TwilioRequest request) { var response = new TwilioResponse(); using (var db = dbFactory()) { var signin = await GetMembersLatestSignin(db, session.MemberId); await RosterController.AssignInternal(signin, session.EventId, db, this.config); var name = CurrentEvents.Where(f => f.Id == session.EventId).Select(f => f.Name).SingleOrDefault(); response.SayVoice(Speeches.ChangeEventTemplate, name); } response.Redirect(Url.Content("~/api/Voice/Menu") + session.ToQueryString()); return(LogResponse(response)); }
public async Task <TwilioResponse> DoMenu(TwilioRequest request) { var response = new TwilioResponse(); if (request.Digits == "1") { if (this.session.MemberId == null) { await AddLoginPrompt(response, Url.Content("~/api/Voice/DoSignInOut")); } else { response = await DoSignInOut(request); } } else if (request.Digits == "2") { BuildSetEventMenu(response, string.Empty, Url.Content("~/api/voice/Menu")); } else if (request.Digits == "3") { response.SayVoice(Speeches.StartRecording); response.Record(new { maxLength = 120, action = GetAction("StopRecording") }); BeginMenu(response); await EndMenu(response); } else if (request.Digits == "8") { await AddLoginPrompt(response, Url.Content("~/api/voice/Menu")); } else if (request.Digits == "9") { response.Redirect(GetAction("Menu", controller: "VoiceAdmin")); } else { response.SayVoice(Speeches.InvalidSelection); BeginMenu(response); await EndMenu(response); } return(LogResponse(response)); }
public HttpResponseMessage Menu(VoiceRequest request) { var response = new TwilioResponse(); response.BeginGather(new { action = "menu_selection" }); // "For general information about this property, press 1. " + // "If you are an agent or a broker, and you would like to schedule a viewing, press 2. "+ // "If you are not an agent and would like to schedule a viewing, press 3. " + // "To request more information about the home or to make an offer, press 4." // "For a quicker response, text your question to this number directly." response.Play("/audio/menu.mp3"); response.EndGather(); response.Pause(); response.Redirect("menu"); return(TWiML(response)); }
// /Voice/HandleGather public TwiMLResult HandleGather(VoiceRequest request) { var response = new TwilioResponse(); switch (request.Digits) { case "1": response.Dial("+13105551212"); response.Say("The call failed or the remote party hung up. Goodbye."); break; case "2": response.Say("Record your message after the tone."); response.Record(new {maxLength = "30", action = "/Voice/HandleRecord"}); break; default: response.Redirect("/Voice"); break; } return TwiML(response); }
public ActionResult PlayInvitation(string CallSid) { var response = new TwilioResponse(); response.BeginGather( new { action = Url.ActionAbsolute("PlayInvitation"), method = "POST", numDigits = "1", timeout = "3" }); response.Say("Lets play a game while you wait."); response.Say("If you would rather just listen to music, press 1"); response.EndGather(); response.Redirect(Url.ActionAbsolute("Introduction"), "GET"); return(TwiML(response)); }
public ActionResult ReadQuestion(string CallSid) { var gameState = QuizShowState.Load(CallSid); var currentQuestion = gameState.Questions[gameState.CurrentQuestionIndex]; var response = new TwilioResponse(); response.Say(". OK. Here is question number " + (gameState.CurrentQuestionIndex + 1).ToString() + ". ."); response.BeginGather( new { action = Url.ActionAbsolute("CaptureAnswer"), method = "POST", numDigits = "1", timeout = "5" }); response.Say(string.Format("{0}? . . ", currentQuestion.Text)); response.Say("Is the answer. . "); var orderedAnswers = currentQuestion.PossibleAnswers.OrderBy(a => a.Order).ToList(); for (int i = 0; i < orderedAnswers.Count(); i++) { if (i == (orderedAnswers.Count() - 1)) { response.Say(string.Format("Or. {0}. {1}. . ", (i + 1).ToString(), orderedAnswers[i].Text)); } else { response.Say(string.Format(". {0}. {1}. . ", (i + 1).ToString(), orderedAnswers[i].Text)); } } response.EndGather(); response.Redirect(Url.ActionAbsolute("NoAnswerProvided"), "GET"); gameState.Save(); return(TwiML(response)); }
public HttpResponseMessage Post(VoiceRequest request) { var response = new TwilioResponse(); var id = (request != null) ? request.Digits : string.Empty; var item = DataStore.Instance.GetItem(id); if (item == null) { response.Say("Item not found."); } else { response.Say(string.Format("The status of item {0} is {1}.", item.Id, item.Status)); } response.Redirect(CallHomeController.URL); return(this.Request.CreateResponse( HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter())); }
public ActionResult AddToConference(string From) { var participants = LoadParticipants(); if (participants.ContainsKey(From)) { participants[From] = false; } else { participants.Add(From, false); } System.Web.HttpContext.Current.Cache["participants"] = participants; var response = new TwilioResponse(); response.Say("Welcome to a conference. Press *6 to mute or unmute yourself."); response.Redirect(Url.Action("PlaceInConference", new { mute = false })); return(TwiML(response)); }