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 Complete(VoiceRequest request) { var response = new TwilioResponse(); if (request.Digits=="1") { response.Redirect( Url.Action("Gather"), "GET" ); } else { response.Redirect( Url.Action("Goodbye"), "GET" ); } return TwiML(response); }
public ActionResult Error(VoiceRequest request) { var response = new TwilioResponse(); switch (request.Digits) { case "1": response.Redirect(Url.Action("Agent"), "GET"); break; default: response.Redirect(Url.Action("Goodbye"), "GET"); break; } return TwiML(response); }
private TwiMLResult RedirectWelcome() { var response = new TwilioResponse(); response.Redirect(Url.Action("Welcome", "IVR")); return TwiML(response); }
public TwilioResponse GetMenuSelection(VoiceRequest request) { var response = new TwilioResponse(); try { string lookupPhoneNumber = request.GetOriginatingNumber(); int profileId = profileManager.GetProfileId(lookupPhoneNumber); var selection = int.Parse(request.Digits); switch (selection) { case 1: response.Say("Looking up unread messages."); var unreadCount = refUnitedAcctManager.GetUnreadMessageCount(profileId); response.Say(string.Format("You have {0} message{1}", unreadCount, (unreadCount == 1) ? "" : "s")); break; case 2: response.Say("Looking up messages"); response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.READ_PLATFORM_MESSAGES, profileId)); break; case 3: response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.SEND_MESSAGE_TO_FAVOURITE, profileId)); break; case 4: response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.PLAY_RECORDED_MESSAGES, profileId)); break; case 5: response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.BROADCAST_RECORD, profileId)); break; case 6: response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.BROADCAST_MENU, profileId)); break; default: response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU)); break; } } catch (Exception ex) { response.Say("an error has occured. " + ex.Message); } return response; }
public HttpResponseMessage Closed() { var voicemailUrl = _accountSettings.GetSetting("VoicemailUrl"); var twilioResponse = new TwilioResponse(); twilioResponse.Redirect(voicemailUrl); return Request.CreateResponse(HttpStatusCode.OK, twilioResponse.Element, new XmlMediaTypeFormatter()); }
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); }
// 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"); }
// 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 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); }
public TwilioResponse BroadcastReplyMenuSelection(VoiceRequest request, int profileId, int lastBroadcastIdx, int subBroadcastIdx) { var response = new TwilioResponse(); var selection = request.Digits; switch (selection) { case "1": response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_REPLY_PRIVATELY, profileId, lastBroadcastIdx, subBroadcastIdx)); return response; case "2": response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_REPLY_PUBLICLY, profileId, lastBroadcastIdx, subBroadcastIdx)); return response; case "3": response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_PLAY_PUBLIC_REPLY, profileId, lastBroadcastIdx, ++subBroadcastIdx)); return response; case "4": response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_LISTEN_TO_ALL_PUBLIC, profileId, ++lastBroadcastIdx)); return response; case "5": response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_ADD_REPLIER_AS_FAVOURITE, profileId, lastBroadcastIdx, subBroadcastIdx)); return response; default: response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU)); return 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 AddResponderAsFavourite(VoiceRequest request, int profileId, int lastBroadcastIdx, int subBroadcastIdx) { var broadcast = broadcastManager.GetAll().Skip(lastBroadcastIdx).Take(1).FirstOrDefault(); var reply = broadcast.BroadcastReplies.Skip(subBroadcastIdx).Take(1).FirstOrDefault(); int profileIdToFavourite = reply.FromProfileId; profileManager.AddAsFavourite(profileId, profileIdToFavourite); var profile = profileManager.GetProfile(profileIdToFavourite); var response = new TwilioResponse(); response.Say(string.Format("{0} has been added as a favourite", profile.FullName)); response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU)); return 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 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); }
// /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 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 HttpResponseMessage Post(VoiceRequest request) { var response = new TwilioResponse(); var validIds = new List<string> { "12345", "23456", "34567" }; var userId = request.Digits; var authenticated = validIds.Contains(userId); if (!authenticated) { response.Say("You entered an invalid ID. Goodbye."); response.Hangup(); } else { response.Say("ID is valid."); response.Redirect(string.Format("/api/Name?userId={0}", userId)); } return this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter()); }
public HttpResponseMessage CreateOrJoinConferenceCall(TwilioGatherRequest twilioRequest) { var conference = _client.ListConferences().Conferences.FirstOrDefault(name => name.FriendlyName.Equals(twilioRequest.Digits)); var twilioResponse = new TwilioResponse(); var digits = twilioRequest.Digits; twilioResponse.Say(string.Format("You're now joining conference {0}. Thank you.", digits), _voicesettings); if (conference != null) { var participant = _client.GetConferenceParticipant(conference.Sid, twilioRequest.CallSid); var context = GlobalHost.ConnectionManager.GetHubContext<Hubs.ConferenceHub>(); context.Clients.addParticipant(participant.ConferenceSid, participant.CallSid, participant.Muted); } twilioResponse.DialConference(twilioRequest.Digits, new { waitUrl = "http://twimlets.com/holdmusic?Bucket=com.twilio.music.rock", endConferenceOnExit = true }); twilioResponse.Redirect(Url.Link("ExtendedApi", new { controller = "Phone", action = "GoodByeMessage" })); return Request.CreateResponse(HttpStatusCode.OK, twilioResponse.Element); }
public TwilioResponse GetAuthentication(VoiceRequest request, string language) { var response = new TwilioResponse(); if (string.IsNullOrEmpty(language)) { language = LanguageHelper.GetDefaultCulture(); } else { language = LanguageHelper.GetValidCulture(language); } IVRAuthLang.Culture = new System.Globalization.CultureInfo(language); twiMLHelper = new TwiMLHelper(language, LanguageHelper.IsImplementedAsMP3(language)); string lookupPhoneNumber = request.GetOriginatingNumber(); var pin = request.Digits; var result = profileManager.CheckPin(lookupPhoneNumber, pin); string correctPin = profileManager.GetPin(lookupPhoneNumber); if (result) { response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU, language), "POST"); } else { twiMLHelper.SayOrPlay(response, IVRAuthLang.IncorrectPIN); response.Hangup(); } return 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 TwiMLResult SecondClientResponse(CallContextModel model, string digits) { var response = new TwilioResponse(); try { model.CallerStatus = Request["CallStatus"]; switch (digits) { case "1": // Update database second client is ready now and update status Services.Call.ReceiverReadyNow(model.CallId); Services.Call.UpdateCallStatus(model.CallId, model.CallerStatus, true); response.Redirect(Url.Action("SecondClientReady", model)); break; default: response.Pause(10); response.Redirect(Url.Action("SecondClientStart", model)); break; } } catch (Exception e) { Log.Error("First client response. Error: ", e); // Error response.Say(ConferenceConst.ErrorMessage, new { voice = VoiceInConference, language = LanguageInConference }); response.Hangup(); } return new TwiMLResult(response); }
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 TwiMLResult CallBackAfterConference(CallContextModel model) { var callSid = Request["CallSid"]; var response = new TwilioResponse(); try { if (model.IsCustomer) { model.ReceiverSid = callSid; } else { model.CallerSid = callSid; } response.Say(ConferenceConst.ThankForConsultantAndFollowupAction, new { voice = VoiceInConference, language = LanguageInConference }); response.Redirect(Url.Action("ConsultantAfterCall", model)); return new TwiMLResult(response); } catch (Exception e) { Log.Error("Call back after conference. Error: ", e); // Error response.Say(ConferenceConst.ErrorMessage, new { voice = VoiceInConference, language = LanguageInConference }); response.Hangup(); } return new TwiMLResult(response); }
public TwiMLResult FirstClientResponse(CallContextModel model, string digits) { var response = new TwilioResponse(); try { if (model.IsCustomer) // Customer initiate call >> Consultant called first { var optionKey = string.Empty; var optionNotify = ConferenceConst.OptionNotifyForDefer; var deferMinute = 5; switch (digits) { case "1": response.Redirect(Url.Action("FirstClientReady", model)); // Update on time and total consultation Services.Call.UpdateOnTime(model.ReceiverId); Services.Call.UpdateTotalConsultation(model.ReceiverId); // Change css CallHelper.ChangeCssDialToPhone(Services.Users.GetUserById(model.CallerId)); break; case "2": optionKey = ConferenceConst.OptionDefer5Minutes; break; case "3": optionKey = ConferenceConst.OptionDefer10Minutes; deferMinute = 10; break; case "4": optionKey = ConferenceConst.OptionDefer15Minutes; deferMinute = 15; break; case "5": optionKey = ConferenceConst.OptionSchedule24Hours; optionNotify = ConferenceConst.OptionNotifyForSchedule; deferMinute = 24 * 60; break; case "6": optionKey = ConferenceConst.OptionScheduleOver24Hours; optionNotify = ConferenceConst.OptionNotifyForSchedule; deferMinute = 48 * 60; break; case "9": optionNotify = ConferenceConst.OptionDeclineConsultation; // Update on time and total consultation Services.Call.UpdateTotalConsultation(model.ReceiverId); break; default: response.Redirect(Url.Action("FirstClientStart", model)); return new TwiMLResult(response); } var specialist = Services.Users.GetUserById(model.ReceiverId); if (digits != "1") { if (digits != "9") { // Update booking to database if (Services.Booking.UpdateBookingForDeferOrReSchedule(model.BookingId, deferMinute)) { if (("7".Equals(digits) == false) || ("8".Equals(digits) == false)) { // Call function to show popup defer or reschedule for customer bool isDefer = false; if ("2".Equals(digits) || "3".Equals(digits) || "4".Equals(digits)) { isDefer = true; } else { // Update status "Not available" for specilist when reschedule 5,6 _cache.Remove(string.Format(ConferenceConst.CacheSpecialistStatus, specialist.Id)); Services.Users.UpdateAvaibilityStatus(model.ReceiverId, AvailabilityStatus.NotAvailable); } CallHelper.ShowPopupTalkNowDeferOrReSchedule(model.CallerId, model.BookingId, isDefer, Services); } } else // If update booking defer unsuccess { // Log Log.Error("FirstClientResponse_Update booking fail"); throw new Exception("Update booking fail."); } response.Say(String.Format(ConferenceConst.PressKeyForSelectOption, digits, optionKey), new { voice = VoiceInConference, language = LanguageInConference }); } else // Specialist declined the consultation { // Update defer for booking is -1 Services.Booking.UpdateDeferBooking(model.BookingId, -1); // Notify for customer conference was declined by consultant var customer = Services.Users.GetUserById(model.CallerId); var sepecialist = Services.Users.GetUserById(model.ReceiverId); CallHelper.ShowPopupNotifyInConference(customer, ConferencePopupConst.DeclinedTitle, string.Format(ConferencePopupConst.DeclinedContent, specialist.Name)); // Update status "Maybe available" for specilist when decline 9 _cache.Remove(string.Format(ConferenceConst.CacheSpecialistStatus, specialist.Id)); // Compare current status and only change status when it is available if (AvailabilityStatus.Available.Equals(specialist.AvailabilityStatus)) { Services.Users.UpdateAvaibilityStatus(model.ReceiverId, AvailabilityStatus.MaybeAvailable); } } response.Say(optionNotify, new { voice = VoiceInConference, language = LanguageInConference }); response.Redirect(Url.Action("CallHangUpForDeferOrReSchedule", model)); } else { // Add cache status for specialist when talk now to use reupdate after talknow _cache.Add(string.Format(ConferenceConst.CacheSpecialistStatus, specialist.Id), specialist.AvailabilityStatus, new CacheItemPolicy { AbsoluteExpiration = DateTimeOffset.Now.AddDays(1) }); // Set status "NotAvailable" when begin talk now Services.Users.UpdateAvaibilityStatus(model.ReceiverId, AvailabilityStatus.NotAvailable); } } else // Consultant initiate call >> Customer called first { switch (digits) { case "1": response.Redirect(Url.Action("FirstClientReady", model)); break; default: response.Redirect(Url.Action("FirstClientStart", model)); break; } } return new TwiMLResult(response); } catch (Exception e) { // Log Log.Error("First client response. Error: ", e); // Error response.Say(ConferenceConst.ErrorMessage, new { voice = VoiceInConference, language = LanguageInConference }); response.Hangup(); } return new TwiMLResult(response); }
public TwiMLResult FirstClientReady(CallContextModel model) { var response = new TwilioResponse(); var message = string.Empty; try { // Make call to second client // If customer initiate call >> Customer will be call // If consultant initiate call >> Consultant will be call var customer = Services.Users.GetUserById(model.CallerId); var specialist = Services.Users.GetUserById(model.ReceiverId); try { if (model.IsCustomer) { string fullPhoneNumber = customer.MobileCountryCode + customer.MobilePhone; // Make call to customer var call = Services.Call.Dial(Url.Action("SecondClientStart", model), fullPhoneNumber); // Update callSid Services.Call.UpdateCallSid(model.CallId, call.Sid, true); } else { customer = Services.Users.GetUserById(model.ReceiverId); specialist = Services.Users.GetUserById(model.CallerId); string fullPhoneNumber = specialist.MobileCountryCode + specialist.MobilePhone; // Make call to consultant var call = Services.Call.Dial(Url.Action("SecondClientStart", model), fullPhoneNumber); // Update callSid Services.Call.UpdateCallSid(model.CallId, call.Sid, true); } } catch (Exception e) { // Log Log.Error("FirstClientReady_Call to second client failed. Error: ", e); } // Update call status model.ReceiverStatus = Request["CallStatus"]; Services.Call.UpdateCallStatus(model.CallId, model.ReceiverStatus, false); if (model.IsCustomer) // Customer initiate call >> Consultant called first { string template = ConferenceConst.AcceptCallNowForTalkNow; message = string.Format(template, customer.Name); } else // Consultant initiate call >> Customer called first { string template = ConferenceConst.AcceptCallNowForSchedule; message = string.Format(template, specialist.Title, specialist.Name); } response.Say(message, new { voice = VoiceInConference, language = LanguageInConference }); response.Redirect(Url.Action("FirstClientHold", model)); } catch (Exception e) { Log.Error("First client ready. Error: ", e); // Error response.Say(ConferenceConst.ErrorMessage, new { voice = VoiceInConference, language = LanguageInConference }); response.Hangup(); } return new TwiMLResult(response); }
public TwiMLResult FirstClientHold(CallContextModel model) { var response = new TwilioResponse(); try { bool pickedUp = Services.Call.ReceiverPickedUp(model.CallId); bool ready = Services.Call.ReceiverReady(model.CallId); // Update call status model.ReceiverStatus = Request["CallStatus"]; Services.Call.UpdateCallStatus(model.CallId, model.ReceiverStatus, false); if (pickedUp && ready) { // Join conference room response.Redirect(Url.Action("FirstClientConference", model)); } else { response.Pause(20); if (model.IsCustomer) //do Customer initiate call >> Consultant called first { response.Say(ConferenceConst.WaitForCustomer, new { voice = VoiceInConference, language = LanguageInConference }); } else // Consultant initiate call >> Customer called first { response.Say(ConferenceConst.WaitForConsultant, new { voice = VoiceInConference, language = LanguageInConference }); } response.Redirect(Url.Action("FirstClientHold", model)); } return new TwiMLResult(response); } catch (Exception e) { Log.Error("First client hold. Error: ", e); // Error response.Say(ConferenceConst.ErrorMessage, new { voice = VoiceInConference, language = LanguageInConference }); response.Hangup(); } return new TwiMLResult(response); }
public TwiMLResult ConsultantAfterCallResponse(CallContextModel model, string digits) { var response = new TwilioResponse(); var message = ConferenceConst.AcctionCompleted; var specialist = new UserDto(); var call = new CallDto(); bool canWaiveFee = true; int transcriptSuccess = 2; try { if (digits.Equals("2") || digits.Equals("3") || digits.Equals("4") || digits.Equals("5")) { call = Services.Call.GetByCallSid(Request["CallSid"]); if (string.IsNullOrWhiteSpace(model.RecordUrl)) { model.RecordSid = call.RecordSid; model.RecordDuration = call.RecordDuration; model.RecordUrl = call.RecordUrl; } // Get specialist if (model.IsCustomer) // Caller is customer { specialist = Services.Users.GetUserById(model.ReceiverId); } else { specialist = Services.Users.GetUserById(model.CallerId); } int startingTime = Convert.ToInt32(Services.SystemConfig.GetByKey(ParamatricBusinessRules.STARTING_TIME.ToString()).Value); if (call.Duration <= startingTime) { canWaiveFee = false; } } switch (digits) { case "1": // Dictate your follow up action var statusCallBack = Utilities.FormatLink(Url.Action("VoiceMail", "Conference", model)); Services.Call.RedirectToVoiceMail(Request["CallSid"], statusCallBack); break; case "2": // Transcript consultation // Send transcription request transcriptSuccess = SendTranscriptionRequest(specialist.Id.ToString(), specialist.UserName, specialist.Email, call.RecordUrl, call.RecordDuration, call.Booking); if (transcriptSuccess == 0) { message = ConferenceConst.BalanceNotEnoughForTranscript; } else if (transcriptSuccess == 1) { message = ConferenceConst.TranscriptError; } break; case "3": // Play consultation record response.Pause(5); response.Play(model.RecordUrl); break; case "4": // Play consultation record and transcription // Play consultation record response.Pause(5); response.Play(model.RecordUrl); // Send transcription request transcriptSuccess = SendTranscriptionRequest(specialist.Id.ToString(), specialist.UserName, specialist.Email, call.RecordUrl, call.RecordDuration, call.Booking); if (transcriptSuccess == 0) { message = ConferenceConst.BalanceNotEnoughForTranscript; } else if (transcriptSuccess == 1) { message = ConferenceConst.TranscriptError; } break; case "5": // Waive consultation fee if (canWaiveFee) { response.Redirect(Url.Action("WaiveFeeAction", model)); } else { response.Redirect(Url.Action("ConsultantAfterCall", model)); } break; default: response.Redirect(Url.Action("ConsultantAfterCall", model)); return new TwiMLResult(response); } } catch (Exception e) { // Log Log.Error("Consultant after call response. Error: ", e); // Error response.Say(ConferenceConst.ErrorMessage, new { voice = VoiceInConference, language = LanguageInConference }); response.Hangup(); } response.Say(message, new { voice = VoiceInConference, language = LanguageInConference }); response.Redirect(Url.Action("ConsultantAfterCall", model)); return new TwiMLResult(response); }
public TwiMLResult WaiveFeeActionResponse(CallContextModel model, string digits) { var response = new TwilioResponse(); try { switch (digits) { case "1": // Check waive fee already var invoice = Services.Invoices.GetByBookingIdAndUserId(model.BookingId, model.CallerId); if (invoice != null) { if (!invoice.IsWaiveFee) { // Send waive fee request SendWaiveFeeRequest(model); response.Say(ConferenceConst.AcctionCompleted, new { voice = VoiceInConference, language = LanguageInConference }); } else { // Say waive fee alreadly response.Say(ConferenceConst.WaiveFeeAlready, new { voice = VoiceInConference, language = LanguageInConference }); } } break; default: response.Redirect(Url.Action("ConsultantAfterCall", model)); break; } } catch (Exception e) { Log.Error("Waive fee action response. Error: ", e); // Error response.Say(ConferenceConst.ErrorMessage, new { voice = VoiceInConference, language = LanguageInConference }); response.Hangup(); } response.Redirect(Url.Action("ConsultantAfterCall", model)); return new TwiMLResult(response); }