public async Task <ActionResult> Twiml(string digits, string called) { var response = new TwilioResponse(); if (string.IsNullOrEmpty(digits)) { response .BeginGather(new { numDigits = 6, timeOut = 10 }) .Say("Please enter your verification.") .EndGather(); } else { var number = await _service.FindByPhoneNumberAsync(called); if (digits.Equals(number.VerificationCode)) { number.Verified = true; await _service.UpdateAsync(number); response.Say("Thank you! Your phone number has been verified."); } else { response .BeginGather(new { numDigits = 6, timeOut = 10 }) .Say("Verification code incorrect, please try again.") .EndGather(); } } return(TwiML(response)); }
// // GET: /Phone/ public ActionResult IncomingCall(string CallSid, string FromCity, string FromState, string FromZip, string FromCountry) { LocationalCall call = (LocationalCall)GetCall(CallSid); StateManager.AddNewCall(call); StateManager.AddToLog(CallSid, "Incoming call..."); call.City = FromCity; call.Country = FromCountry; call.ZipCode = FromZip; call.State = FromState; TwilioResponse response = new TwilioResponse(); response.BeginGather(new { action = Url.Action("ServiceRequest"), timeout = 120, method = "POST", numDigits = 1 }); response.Say("Welcome to the Bank of Griff."); response.Pause(); response.Say("Press 1 to manage your account."); response.Say("Press 2 to take out a loan."); response.Say("Press 3 to talk to a representative."); response.Pause(); response.EndGather(); return(SendTwilioResult(response)); }
public async Task <TwilioResponse> SetTimeOut(TwilioRequest request) { int minutes; var response = new TwilioResponse(); // add prompt for miles response.BeginGather(new { timeout = 10, action = GetAction("SetMiles") }); if (int.TryParse(request.Digits, out minutes)) { using (var db = dbFactory()) { var signin = await GetMembersLatestSignin(db, this.session.MemberId); signin.TimeOut = signin.TimeOut.Value.AddMinutes(minutes); await db.SaveChangesAsync(); this.config.GetPushHub <CallsHub>().updatedRoster(RosterController.GetRosterEntry(signin.Id, db), true); var sayDate = TimeUtils.GetMiltaryTimeVoiceText(signin.TimeOut.Value); response.SayVoice(Speeches.SignedOutTemplate, this.session.MemberName, sayDate); } } response.SayVoice(Speeches.MilesPrompt); response.EndGather(); return(LogResponse(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 TwiMLResult Welcome() { var response = new TwilioResponse(); response.BeginGather(new { action = Url.Action("Show", "Menu"), numDigits = "1" }) .Play("http://howtodocs.s3.amazonaws.com/et-phone.mp3", new { loop = 3 }) .EndGather(); 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 void Example_2() { var response = new TwilioResponse(); response.BeginGather(new { action = "/process_gather.php", method = "GET" }); response.Say("Please enter your account number, followed by the pound sign"); response.EndGather(); response.Say("We didn't receive any input. Goodbye!"); Assert.IsTrue(IsValidTwiML(response.ToXDocument())); }
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 void Example_2() { var response = new TwilioResponse(); response.BeginGather(new { action = "/process_gather.php", method = "GET" }); response.Say("Please enter your account number, followed by the pound sign"); response.EndGather(); response.Say("We didn't receive any input. Goodbye!"); 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); }
public void Can_Generate_Gather_With_All_Options_and_Nested_Verbs_With_Begin_End() { var response = new TwilioResponse(); response.BeginGather(new { action = "example.xml", timeout = 10, method = "GET", finishOnKey = "#", numDigits = 3 }) .Say("hello") .Play("example.mp3") .Pause(10) .EndGather(); Assert.True(IsValidTwiML(response.ToXDocument())); }
public TwilioResponse Greet(VoiceRequest request) { TwilioResponse response = new TwilioResponse(); response.Say("Welcome to Saint Georges Hospital Directory."); response.BeginGather(new { finishOnKey = "#", action = "/Router/InitialOptions" }); response.Say("Please enter your four digit I D then press the hash button"); response.EndGather(); return(response); }
// /Voice public TwiMLResult Index(VoiceRequest request) { var response = new TwilioResponse(); response.Say("Hello. It's me.", new {voice = "alice", language = "en-GB"}); response.Play("http://howtodocs.s3.amazonaws.com/ahoyhoy.mp3"); response.BeginGather(new {numDigits = "1", action = "/Voice/HandleGather"}); response.Say("To speak to a real person, press 1.\n" + "Press 2 to record a message for a Twilio educator.\n" + "Press any other key to start over."); response.EndGather(); return TwiML(response); }
public void Can_Generate_Gather_With_All_Options_and_Nested_Verbs_With_Begin_End() { var response = new TwilioResponse(); response.BeginGather(new { action = "example.xml", timeout = 10, method = "GET", finishOnKey = "#", numDigits = 3 }) .Say("hello") .Play("example.mp3") .Pause(10) .EndGather(); Assert.IsTrue(IsValidTwiML(response.ToXDocument())); }
private TwiMLResult Planets() { var response = new TwilioResponse(); response.BeginGather(new { action = Url.Action("Interconnect", "PhoneExchange"), numDigits = "1" }) .Say("To call the planet Broh doe As O G, press 2. To call the planet " + "DuhGo bah, press 3. To call an oober asteroid to your location, press 4. To " + "go back to the main menu, press the star key ", new { voice = "alice", language = "en-GB", loop = "3" }) .EndGather(); return(new TwiMLResult(response)); }
public ActionResult Join() { var response = new TwilioResponse(); response.Say("You are about to join the Rapid Response conference"); response.BeginGather(new { action = @Url.Action("Connect") }) .Say("Press 1 to join as a listener") .Say("Press 2 to join as a speaker") .Say("Press 3 to join as the moderator") .EndGather(); return(TwiML(response)); }
private async Task AddLoginPrompt(TwilioResponse response, string next) { Dictionary <string, string> args = new Dictionary <string, string>(); args.Add(NextKey, next ?? Url.Content("~/api/Voice/Menu")); response.BeginGather(new { timeout = 10, action = GetAction("DoLogin", args) }); response.SayVoice(Speeches.DEMPrompt); response.SayVoice(Speeches.GoBack); response.EndGather(); BeginMenu(response); await EndMenu(response); }
public ActionResult PlaceInConference(bool mute) { Debug.WriteLine("Putting caller into conference: {0}", mute); var response = new TwilioResponse(); response.DialConference("Chapter18Conference", new { muted = mute, beep = false, startConferenceOnEnter = true, endConferenceOnExit = false }, new { hangupOnStar = true }); response.BeginGather(new { action = Url.ActionAbsolute("ProcessCommand"), numDigits = "1" }); response.EndGather(); response.Say("Bye"); return(TwiML(response)); }
public void _1_4a() { var name = "Monkey"; var response = new TwilioResponse(); response.Say("Hello " + name); response.Play("http://demo.twilio.com/hellomonkey/monkey.mp3"); response.BeginGather(new { numDigits = 1, action = "hello-monkey-handle-key.php", method = "POST" }); response.Say("To speak to a real monkey, press 1. Press 2 to record your own monkey howl. Press any other key to start over."); response.EndGather(); Assert.IsTrue(IsValidTwiML(response.ToXDocument())); }
public void _1_4a() { var name = "Monkey"; var response = new TwilioResponse(); response.Say("Hello " + name); response.Play("http://demo.twilio.com/hellomonkey/monkey.mp3"); response.BeginGather(new { numDigits = 1, action = "hello-monkey-handle-key.php", method = "POST" }); response.Say("To speak to a real monkey, press 1. Press 2 to record your own monkey howl. Press any other key to start over."); response.EndGather(); Assert.True(IsValidTwiML(response.ToXDocument())); }
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 TwilioResponse PreConnect(VoiceRequest request, string callingPartyId) { var response = new TwilioResponse(); var callingParty = directory.GetContact(callingPartyId); response.BeginGather(new { numDigits = 1, action = "/Router/RespondToPreConnect" }); response.Say(string.Format("You have an incoming call from {0}", callingParty.Name)); response.Say("Press 1 to be connected"); response.Say("Press 2 to hangup"); response.EndGather(); response.Hangup(); return(response); }
public void EnterNumber( string message, Dictionary <string, string> urlParameters, int amountOfDigis = 1, int wait_time = 10 ) { response.BeginGather(new { action = GetCallbackUrl(TwillioConfig.VoiceCallbackUrl, urlParameters), numDigits = amountOfDigis }); response.Say(message); response.EndGather(); }
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 ActionResult AdvancedWait(string QueuePosition, string QueueTime, string AvgWaitTime, string CurrentQueueSize) { var response = new TwilioResponse(); response.Say(string.Format("Bwahahaha! Your time in the queue has been {0} seconds. Enjoy your wait with {1} of your friends!", QueueTime, CurrentQueueSize)); response.BeginGather(new { action = Url.Action("AdvancedWaitGather", "Queue", null, "http") }); //TODO: for some reason I have to hit # to get the Gather to work. Not sure why? response.Say("Enter the magic number now to be released from the queue", new { numDigits = "3", timeout = "7" }); response.EndGather(); response.Say("Not even brave enough to proffer a guess? Figures. You can try again in a bit."); response.Pause(10); //TODO: replace this with a play return(TwiML(response)); }
public async Task <TwilioResponse> Menu() { var response = new TwilioResponse(); if (this.session.IsAdmin == false) { response.BeginGather(new { numDigits = 10, action = GetAction("Login", controller: "VoiceAdmin"), timeout = 10 }); response.SayVoice("Enter admin password followed by pound"); response.EndGather(); } else { BeginMenu(response); await EndMenu(response); } return(response); }
public TwiMLResult Welcome() { var response = new TwilioResponse(); response.BeginGather(new { action = Url.Action("Show", "Menu"), numDigits = "1" }) .Say("Thank you for calling DEMO Pharmacy." + " If you would like to talk to a pharmacist, press 1. " + " To change the way we contact you, press 2.") .Pause(2) .Say("Thank you for calling DEMO Pharmacy." + " If you would like to talk to a pharmacist, press 1. " + " To change the way we contact you, press 2.") .Pause(2) .Say("Thank you for calling DEMO Pharmacy." + " If you would like to talk to a pharmacist, press 1. " + " To change the way we contact you, press 2.") .Pause(2) .Say("Goodbye") .EndGather(); return(TwiML(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)); }
public TwilioResponse InitialOptions(VoiceRequest request) { TwilioResponse response = new TwilioResponse(); var id = request.Digits; if (!directory.ExtensionExists(id)) { response.Say("We couldn't find your I D."); response.Hangup(); } response.BeginGather(new { finishOnKey = "#", action = string.Format("/Router/PingInital?callingPartyId={0}", id) }); response.Say("To contact an individual, enter their 4 digit I D and then press the hash button"); response.Say("To contact a team, enter star followed by the 4 digit I D and then press the hash button"); response.EndGather(); return(response); }
protected void BuildSetEventMenu(TwilioResponse response, string prompt, string thenUrl) { Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("evtIds", string.Join(".", this.CurrentEvents.Select(f => f.Id.ToString()))); args.Add("next", thenUrl); response.BeginGather(new { timeout = 10, action = GetAction("SetEvent", args) }); if (!string.IsNullOrWhiteSpace(prompt)) { response.SayVoice(prompt); } response.SayVoice(string.Format("There are {0} events in progress. ", this.CurrentEvents.Count)); for (int i = 0; i < this.CurrentEvents.Count; i++) { response.SayVoice(string.Format("Press {0} then pound for {1}. ", i + 1, this.CurrentEvents[i].Name)); } response.EndGather(); }
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 TwilioResponse Wait(string queueId, string queueTime, string queueSize) { var response = new TwilioResponse(); response.AllowedChildren.Add("Leave"); var queue = settings.Queue; if (Convert.ToInt32(queueTime) > queue.WaitTime || Convert.ToInt32(queueSize) > queue.Size) { return(response.Leave()); } if (!string.IsNullOrEmpty(queue.WaitUrl)) { response.BeginGather(new { method = "GET", action = GetEcho("gatherQueue") }) .Play(queue.WaitUrl) .EndGather(); } return(response); }
public HttpResponseMessage VoiceCall(string userId, int callId) { var response = new TwilioResponse(); var call = _callsService.GetCallById(callId); if (call == null) { response.Say("This call has been closed. Goodbye.").Hangup(); return(Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter())); } if (call.State == (int)CallStates.Cancelled || call.State == (int)CallStates.Closed || call.IsDeleted) { response.Say(string.Format("This call, Id {0} has been closed. Goodbye.", call.Number)).Hangup(); return(Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter())); } var stations = _departmentGroupsService.GetAllStationGroupsForDepartment(call.DepartmentId); string address = call.Address; if (String.IsNullOrWhiteSpace(address) && !string.IsNullOrWhiteSpace(call.GeoLocationData)) { try { string[] points = call.GeoLocationData.Split(char.Parse(",")); if (points != null && points.Length == 2) { address = _geoLocationProvider.GetAproxAddressFromLatLong(double.Parse(points[0]), double.Parse(points[1])); } } catch { } } if (String.IsNullOrWhiteSpace(address) && !String.IsNullOrWhiteSpace(call.Address)) { address = call.Address; } StringBuilder sb = new StringBuilder(); if (!String.IsNullOrWhiteSpace(address)) { sb.Append(string.Format("{0}, Priority {1} Address {2} Nature {3}", call.Name, call.GetPriorityText(), call.Address, call.NatureOfCall)); } else { sb.Append(string.Format("{0}, Priority {1} Nature {2}", call.Name, call.GetPriorityText(), call.NatureOfCall)); } sb.Append(", Press 0 to repeat, Press 1 to respond to the scene"); for (int i = 0; i < stations.Count; i++) { if (i >= 8) { break; } sb.Append(string.Format(", press {0} to respond to {1}", i + 2, stations[i].Name)); } response.BeginGather(new { numDigits = 1, timeout = 10, method = "GET", action = string.Format("{0}/Twilio/VoiceCallAction/{1}/{2}", Config.SystemBehaviorConfig.ResgridApiBaseUrl, userId, callId) }).Say(sb.ToString()).EndGather().Pause(10).Hangup(); return(Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter())); }