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; }
// // 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); }
// 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 TwilioResponse GetGreeting(VoiceRequest request) { string culture = LanguageHelper.GetDefaultCulture(); var response = new TwilioResponse(); try { var lookupPhoneNumber = request.GetOriginatingNumber(); var knownNumber = profileManager.CheckNumber(lookupPhoneNumber); if (knownNumber) { culture = profileManager.GetCulture(lookupPhoneNumber); if (string.IsNullOrEmpty(culture)) { culture = LanguageHelper.GetDefaultCulture(); } else { culture = LanguageHelper.GetValidCulture(culture); } IVREntryLang.Culture = new System.Globalization.CultureInfo(culture); twiMLHelper = new TwiMLHelper(culture, LanguageHelper.IsImplementedAsMP3(culture)); } else { twiMLHelper = new TwiMLHelper(LanguageHelper.GetDefaultCulture(), false); } twiMLHelper.SayOrPlay(response, IVREntryLang.Welcome); twiMLHelper.SayOrPlay(response, string.Format(IVREntryLang.PhoneLookup, string.Join(" ", lookupPhoneNumber.ToArray()))); if (!knownNumber) { twiMLHelper.SayOrPlay(response, IVREntryLang.PhoneNumberNotFound); response.Hangup(); return response; } response.BeginGather(new { finishOnKey = "#", action = string.Format("/api/IVRAuthenticate?language={0}", culture) }); twiMLHelper.SayOrPlay(response, IVREntryLang.EnterPin); response.EndGather(); } catch (Exception ex) { twiMLHelper.SayOrPlay(response, string.Format(IVREntryLang.Error, ex.Message)); twiMLHelper.SayOrPlay(response, string.Format(IVREntryLang.Error, ex.Message)); twiMLHelper.SayOrPlay(response, string.Format(IVREntryLang.Error, ex.Message)); response.Hangup(); } return response; }
public ActionResult Gather() { var response = new TwilioResponse(); response.BeginGather(new { action=Url.Action("Gather"), method="POST" }) .Say("Please enter your four digit package ID, followed by the pound sign."); response.EndGather(); response.Say("I'm sorry, I didn't get that."); response.Redirect( Url.Action("Gather"), "GET" ); return TwiML(response); }
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; }
public ActionResult Error() { var response = new TwilioResponse(); response.Say(string.Format("I'm sorry, there seems to have been a problem locating your package.")); response.BeginGather(new { action = Url.Action("Complete"), method = "POST" }) .Say("To speak with an agent, press one."); response.EndGather(); response.Redirect(Url.Action("Goodbye"), "GET"); return TwiML(response); }
public ActionResult Complete(string s) { var response = new TwilioResponse(); response.Say(string.Format("The status of your package is {0}.", s)); response.BeginGather(new { action = Url.Action("Complete"), method="POST" }) .Say("To locate another package, press one."); response.EndGather(); response.Redirect( Url.Action("Goodbye"), "GET" ); return TwiML(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 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 GetMainMenu() { var response = new TwilioResponse(); response.Say("Main menu."); response.BeginGather(new { numDigits = 1, action = "/IVRMain/MainMenuSelection" }); response.Say("Press one to check messages."); response.Say("Press two to listen to old messages."); response.Say("Press three to send a voice message to a favourite."); response.Say("Press four to listen to voice messages."); response.Say("Press five to send a public broadcast."); response.Say("Press six to listen public broadcasts."); response.EndGather(); return response; }
public HttpResponseMessage AnswerIncomingCall() { var twilioResponse = new TwilioResponse(); twilioResponse.BeginGather( new { action = Url.Link("ExtendedApi", new {controller = "Phone", action = "HandleConferenceCall"}), numDigits = 1 }); twilioResponse.Say( "Welcome to VoxVoi. If you have a conference number, please press 2. Otherwise, please stay on your line.", _voicesettings); twilioResponse.EndGather(); twilioResponse.Redirect( Url.Link("ExtendedApi", new {controller = "Phone", action = "HandleMenuCall"}), "POST"); return Request.CreateResponse(HttpStatusCode.OK, twilioResponse.Element); }
public TwiMLResult FirstClientStart(CallContextModel model) { var response = new TwilioResponse(); try { var call = Services.Call.GetByCallSid(Request["CallSid"]); // Get info for call context model.CallId = call.Id; model.ReceiverSid = Request["CallSid"]; model.ReceiverStatus = Request["CallStatus"]; // Get first client and second client var fromUser = Services.Users.GetUserById(model.CallerId); var toUser = Services.Users.GetUserById(model.ReceiverId); // Update call status Services.Call.UpdateCallStatus(model.CallId, model.ReceiverStatus, false); var greeting = string.Empty; if (model.IsCustomer) // Customer initiate call >> Consultant called first { string template = ConferenceConst.CallMenuForTalkNow; greeting = string.Format(template, fromUser.Name, model.NatureOfEnquiry); } else // Consultant initiate call >> Customer called first { string template = ConferenceConst.CallMenuForSchedule; greeting = string.Format(template, toUser.Name, fromUser.Name, model.NatureOfEnquiry); } response.BeginGather(new { numDigits = 1, action = Url.Action("FirstClientResponse", model) }); response.Pause(2); response.Say(greeting, new { voice = VoiceInConference, language = LanguageInConference }); response.EndGather(); response.Redirect(Url.Action("FirstClientStart", model)); } catch (Exception e) { // Save Log Log.Error("First client start. Error:", e); // Error response.Say(ConferenceConst.ErrorMessage, new { voice = VoiceInConference, language = LanguageInConference }); response.Hangup(); } return new TwiMLResult(response); }
public TwilioResponse ListenToBroadcastReplies(VoiceRequest request, int profileId, int lastBroadcastIdx, int subBroadcastIdx) { var response = new TwilioResponse(); PublicBroadcast broadcast; try { broadcast = broadcastManager.GetAll().Skip(lastBroadcastIdx).Take(1).FirstOrDefault(); } catch (Exception) { broadcast = null; } if (broadcast == null) { response.Say("Broadcast not found, returning to the main menu"); response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU)); return response; } if (broadcast.BroadcastReplies == null || broadcast.BroadcastReplies.Count == 0) { response.Say("Broadcast has no replies, returning to the main menu"); response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU)); return response; } var reply = broadcast.BroadcastReplies.Skip(subBroadcastIdx).Take(1).FirstOrDefault(); if (reply == null) { response.Say("No more replies, returning to the main menu"); response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU)); return response; } var fromProfile = profileManager.GetProfile(reply.FromProfileId); response.Say(string.Format("Playing broadcast reply from {0}", fromProfile.FullName)); response.Play(reply.Url); if (broadcast.BroadcastReplies.Count - subBroadcastIdx <= 0) { response.Say("That was the last reply to this broadcast."); } response.BeginGather(new { action = ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCAST_REPLY_RESPONSE_SELECTION, profileId, lastBroadcastIdx, subBroadcastIdx), playBeep = true, numDigits = 1 }); response.Say("Press one to reply privately to this broadcast."); response.Say("Press two to reply publicly to this broadcast."); if (broadcast.BroadcastReplies.Count - subBroadcastIdx > 0) { response.Say("Press three to listen to the next broadcast reply"); } response.Say("Press four to listen to the next public broadcast"); response.Say("Press five to add person as a favourite"); response.EndGather(); return response; }
public TwiMLResult WaiveFeeAction(CallContextModel model) { var response = new TwilioResponse(); try { response.BeginGather(new { numDigits = 1, action = Url.Action("WaiveFeeActionResponse", model) }); response.Say(ConferenceConst.WaiveFeeAction, new { voice = VoiceInConference, language = LanguageInConference }); response.EndGather(); response.Redirect(Url.Action("ConsultantAfterCall", model)); } catch (Exception e) { // Log Log.Error("Waive fee action. Error: ", e); // Error response.Say(ConferenceConst.ErrorMessage, new { voice = VoiceInConference, language = LanguageInConference }); response.Hangup(); } return new TwiMLResult(response); }
public TwiMLResult ConsultantAfterCall(CallContextModel model) { var response = new TwilioResponse(); try { response.BeginGather(new { numDigits = 1, action = Url.Action("ConsultantAfterCallResponse", model) }); // Check call duration var call = Services.Call.GetByCallSid(Request["CallSid"]); int startingTime = Convert.ToInt32(Services.SystemConfig.GetByKey(ParamatricBusinessRules.STARTING_TIME.ToString()).Value); if (call.Duration <= startingTime) { response.Say(ConferenceConst.ConsultantAfterCallNoInvoice, new { voice = VoiceInConference, language = LanguageInConference }); } else { response.Say(ConferenceConst.ConsultantAfterCall, new { voice = VoiceInConference, language = LanguageInConference }); } response.EndGather(); response.Redirect(Url.Action("ConsultantAfterCall", model)); } catch (Exception e) { // Log Log.Error("Consultant after call. Error: ", e); // Error response.Say(ConferenceConst.ErrorMessage, new { voice = VoiceInConference, language = LanguageInConference }); response.Hangup(); } return new TwiMLResult(response); }
public ActionResult NotFound() { var response = new TwilioResponse(); response.Say(string.Format("I'm sorry, I could not locate your package.")); response.BeginGather(new { action = Url.Action("Complete"), method = "POST" }) .Say("To try to locate the package again or to locate another package, press one.") .Say("To speak with an agent, press two."); response.EndGather(); response.Redirect(Url.Action("Goodbye"), "GET"); return TwiML(response); }
public ActionResult SecondClientStart(CallContextModel model) { var response = new TwilioResponse(); try { // Get info for call context model.CallerSid = Request["CallSid"]; model.CallerStatus = Request["CallStatus"]; Services.Call.UpdateCallStatus(model.CallId, model.CallerStatus, true); Services.Call.ReceiverHasPickedUp(model.CallId); // Get fromUser and toUser var fromUser = Services.Users.GetUserById(model.CallerId); var toUser = Services.Users.GetUserById(model.ReceiverId); var message = string.Empty; if (model.IsCustomer) // Customer initiate call >> Second client and FromUser is customer { string template = ConferenceConst.SecondClientStartForTalkNow; message = string.Format(template, fromUser.Name, toUser.Name, model.NatureOfEnquiry); } else // Consultant initiate call >> Second client and FromUser is consultant { string template = ConferenceConst.SecondClientStartForSchedule; message = string.Format(template, fromUser.Name, toUser.Name); } response.BeginGather(new { numDigits = 1, action = Url.Action("SecondClientResponse", model) }); response.Pause(2); response.Say(message, new { voice = VoiceInConference, language = LanguageInConference }); response.EndGather(); response.Redirect(Url.Action("SecondClientStart", model)); return new TwiMLResult(response); } catch (Exception e) { Log.Error("Second client start. Error: ", e); // Error response.Say(ConferenceConst.ErrorMessage, new { voice = VoiceInConference, language = LanguageInConference }); response.Hangup(); } return new TwiMLResult(response); }
public HttpResponseMessage HandleMenuCall(TwilioGatherRequest twilioRequest) { var twilioResponse = new TwilioResponse(); twilioResponse.Say("Welcome to VoxVoi", _voicesettings); twilioResponse.BeginGather( new { action = Url.Link("ExtendedApi", new { controller = "Phone", action = "ProcessMenuCall" }), numDigits = 1 }); twilioResponse.Say("Press 1 to connect with an agent", _voicesettings); twilioResponse.Say("Press 2 to be awesome", _voicesettings); twilioResponse.Say("Press 3 to leave a message", _voicesettings); twilioResponse.Say("Press 0 to return to the main menu", _voicesettings); twilioResponse.EndGather(); twilioResponse.Redirect(Url.Link("ExtendedApi", new {controller = "Phone", action = "HandleMenuCall"})); return Request.CreateResponse(HttpStatusCode.OK, twilioResponse.Element); }
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 TwilioResponse ListenToPublicBroadcasts(VoiceRequest request, int profileId, int idx) { var response = new TwilioResponse(); PublicBroadcast broadcast; try { broadcast = broadcastManager.GetAll().Skip(idx).Take(1).FirstOrDefault(); } catch (Exception) { broadcast = null; } if (broadcast == null) { response.Say("No more broadcasts found, returning to the main menu"); response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU)); return response; } var fromProfile = profileManager.GetProfile(broadcast.FromProfileId); response.Say(string.Format("Playing broadcast from {0}", fromProfile.FullName)); response.Play(broadcast.Url); response.BeginGather(new { action = ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCAST_RESPONSE_SELECTION, profileId, idx), playBeep = true, numDigits = 1 }); response.Say("Press one to reply privately to this broadcast."); response.Say("Press two to reply publicly to this broadcast."); response.Say("Press three to listen to the next broadcast."); if (broadcast.BroadcastReplies.Count > 0) { response.Say("Press four to listen to responses to this broadcast"); } response.EndGather(); return response; }
public TwilioResponse ListenToBroadcastsMenu(VoiceRequest request, int profileId) { var response = new TwilioResponse(); if (string.IsNullOrEmpty(request.Digits)) { response.BeginGather(new { numDigits = 1, action = ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCAST_MENU, profileId.ToString()) }); response.Say("Press one to listen to all public broadcasts"); //response.Say("Press two to listen to public broadcasts which match your country of origin"); response.EndGather(); return response; } switch (request.Digits) { case "1": response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_LISTEN_TO_ALL_PUBLIC, profileId, 0)); return response; case "2": response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCAST_LISTEN_TO_MATCHED, "countryOfBirthId")); return response; default: response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.MAIN_MENU_SELECTION)); return response; } }
public HttpResponseMessage HandleConferenceCall(TwilioGatherRequest twilioRequest) { var digits = twilioRequest.Digits; var twilioResponse = new TwilioResponse(); var conference = _client.ListConferences().Conferences.FirstOrDefault(name => name.FriendlyName.Equals(digits)); if (digits == "2") { twilioResponse.BeginGather( new { action = Url.Link("ExtendedApi", new { controller = "Phone", action = "CreateOrJoinConferenceCall" }), finishOnKey = "#", timeout = 8 }); twilioResponse.Say("Please enter the number of conference call you want to join, followed by the pound key.", _voicesettings); twilioResponse.EndGather(); } else if (conference == null) { twilioResponse.BeginGather( new { action = Url.Link("ExtendedApi", new {controller = "Phone", action = "HandleConferenceCall"}), numDigits = 1 }); twilioResponse.Say( string.Format( "A conference with number {0} doesn't exist. If you wish to create a conference Press 1, otherwise wait 5 seconds to return to the main menu", digits), _voicesettings); twilioResponse.EndGather(); /* Stop gather and inform falling back to the main menu */ twilioResponse.Say("No conference number was provided. You're returning to the main menu. Thank you.", _voicesettings); /* Fall back to main menu */ twilioResponse.Redirect(Url.Link("ExtendedApi", new {controller = "Phone", action = "AnswerIncomingCall"})); } else if(digits == "1") { twilioResponse.BeginGather( new { action = Url.Link("ExtendedApi", new { controller = "Phone", action = "CreateOrJoinConferenceCall"}), finishOnKey = "#", timeout = 8 }); twilioResponse.Say("Please enter the number of conference call you want to create, followed by the pound key.", _voicesettings); twilioResponse.EndGather(); } return Request.CreateResponse(HttpStatusCode.OK, twilioResponse.Element); }
public TwilioResponse PlayRecordedVoiceMessage(VoiceRequest request, int profileId, int? recordingIdx) { var response = new TwilioResponse(); var voiceMessages = profileManager.GetRecordings(profileId); if (voiceMessages == null || voiceMessages.Count == 0) { response.Say("You have no voice messages"); response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU)); return response; } if (recordingIdx.HasValue && recordingIdx.Value >= voiceMessages.Count) { response.Say("No more messages."); response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU)); return response; } Recording voiceMessage; if (recordingIdx.HasValue) { voiceMessage = voiceMessages[recordingIdx.Value]; } else { recordingIdx = 0; voiceMessage = voiceMessages[recordingIdx.Value]; } try { var profile = profileManager.GetProfile(voiceMessage.FromProfileId); response.Say(string.Format("Playing message {0} from {1}", recordingIdx + 1, profile.FullName)); } catch (Exception) { response.Say(string.Format("Playing message {0}", recordingIdx + 1)); } response.Play(voiceMessage.Url); response.BeginGather(new { numDigits = 1, action = string.Format("/IVRMain/PlayRecordedMessage_Response?profileId={0}&recordingIdx={1}&fromProfileId={2}", profileId, recordingIdx.Value, voiceMessage.FromProfileId) }); response.Say("Press one to repeat this message"); response.Say("Press two to delete this message"); response.Say("Press three to reply to this message"); response.Say("Press four to go to the next message"); response.EndGather(); return 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 ActionResult voice3(string From) { Demo.LogNumber(From); var response = new TwilioResponse(); response.Say("Hello, and prepare to be frustrated."); response.BeginGather(new { finishOnKey = "#", action = "http://onetugdemo.apphb.com/reftwilio/voice4" }); response.Say("Type in your account number and press pound."); response.EndGather(); return TwiML(response); }
public TwilioResponse ListFavourites(VoiceRequest request, int profileId, int? pageIdx) { var response = new TwilioResponse(); if (!pageIdx.HasValue) { pageIdx = 0; } var favourites = refUnitedAcctManager.GetFavourites(profileId, pageIdx.Value); if (favourites == null || favourites.Count == 0) { response.Say("You have no favourites to send voice messages to."); response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU)); return response; } response.Say("Listing favourites"); string favs = string.Join(",", favourites.Select(f => f.ProfileId).ToList()); response.BeginGather(new { numDigits = 1, action = string.Format("/IVRMain/SendFavMessage_RecordMsg?profileId={0}&favs={1}&pageIdx={2}", profileId, favs, pageIdx.Value) }); for (int i = 1; i <= favourites.Count; i++) { var fav = favourites[i - 1]; response.Say(string.Format("To send a message to {0} {1} press {2}", fav.FirstName, fav.Surname, i)); } response.Say("Press star to return to main menu"); if (favourites.Count > 9) { response.Say("To go to the next page press hash"); } response.EndGather(); return response; }