// // 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 HttpResponseMessage Get(VoiceRequest request) //{ // try // { // if (request != null) // { // repo.AddMessage(string.Format("unknown,\"{0}\",\"{1}\",starting", request.From, request.To)); // } // else // { // repo.AddMessage("unknown,unknown,unknown,starting"); // } // var response = new TwilioResponse(); // response.Say("G'day and welcome to the twilio monitoring thing...you should see your call appear on the web now..."); // //return response; // return this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter()); // } // catch (Exception ex) // { // var response = new TwilioResponse(); // response.Say(ex.Message); // response.Say(ex.StackTrace); // return this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter()); // } //} public HttpResponseMessage Post(VoiceRequest request) { try { if (request != null) { repo.AddMessage(string.Format("unknown,{0},{1},starting", request.From, request.To)); } else { repo.AddMessage("unknown,unknown,unknown,starting"); } var response = new TwilioResponse(); response.Say("G'day and welcome to the twilio monitoring thing...you should see your call appear on the web now..."); response.Pause(5); response.Say("Good bye..."); //return response; return this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter()); } catch (Exception ex) { var response = new TwilioResponse(); response.Say(ex.Message); response.Say(ex.StackTrace); return this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter()); } }
// // GET: /CallCenter/ public ActionResult Index() { var response = new TwilioResponse(); response.Pause(5); response.Say("Thanks for calling the Music Store"); return TwiML(response); }
public HttpResponseMessage Post(VoiceRequest request, string pin) { var user = AuthenticationService.GetUser(pin); var response = new TwilioResponse(); response.Say(string.Format("Hello {0}", user.Name)); response.Pause(2); response.Hangup(); return this.TwiMLResponse(response); }
public HttpResponseMessage Post(VoiceRequest request, string userId) { var response = new TwilioResponse(); var usernames = new Dictionary<string, string> { { "12345", "Tom" }, { "23456", "Dick" }, { "34567", "Harry" } }; var username = usernames[userId]; response.Say(string.Format("Hello {0}", username)); response.Pause(5); response.Hangup(); return this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter()); }
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 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 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); }