public TwilioResponse PingTeamMember(string teamId, string callingPartyId, int idx) { var response = new TwilioResponse(); Contact contact = directory.GetTeamMember(teamId, idx); Team team = directory.GetTeam(teamId); if (contact != null) { if (idx == 0) { response.Say(string.Format("Now attempting to connect you to {0}", team.Name)); } else { response.Say("Trying next team member..."); } response.Say("We are now contacting " + contact.Name + ", please hold the line"); response.Dial(new Number(contact.MobileNumber, new { url = string.Format("/Router/PreConnect?callingPartyId={0}", callingPartyId) }), new { callerId = "+442033229301", timeLimit = 5, action = string.Format("/Router/NextTeamMember?callingPartyId={0}&TeamId={1}&Idx={2}", callingPartyId, teamId, idx) }); } else { response.Say("Couldn't find a team member..."); response.Hangup(); } return(response); }
public async Task <ActionResult> HandleAgentTwoCall(string CallSid, string To) { //look up the call ID and drop into the same conference var response = new TwilioResponse(); //check the caller ID and try to find a call config that matches it IMobileServiceTable <WarmCall> warmCallTable = MobileService.GetTable <WarmCall>(); var warmCalls = await warmCallTable.ReadAsync <WarmCall>(warmCallTable.Where(w => w.AgentTwoPhone == To)); var warmCall = warmCalls.FirstOrDefault(); if (warmCall != null) { //update with the call sid warmCall.AgentTwoCallSid = CallSid; await warmCallTable.UpdateAsync(warmCall); //put the agent into a conference response.Say("An adventure is requesting assistance. Connecting you now"); response.DialConference(warmCall.CustomerCallSid); } else { response.Say("Who are you? Go away!"); response.Hangup(); } return(TwiML(response)); }
public void Can_Generate_Single_Hangup() { var response = new TwilioResponse(); response.Hangup(); Assert.True(IsValidTwiML(response.ToXDocument())); }
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 HttpResponseMessage Record_Callback(VoiceRequest request, CallType type) { var smtpCient = new SmtpClient(); var message = new MailMessage("*****@*****.**", "*****@*****.**", "New " + type + " Voice-mail from: " + request.From, "You have a new " + type + " voice-mail for the Ellsworth house. \r\nClick here to listen: " + request.RecordingUrl); var webClient = new WebClient(); using (var stream = webClient.OpenRead(request.RecordingUrl)) { message.Attachments.Add(new Attachment(stream, "recording.mp3")); smtpCient.Send(message); } var response = new TwilioResponse(); response.Sms("Ellsworth " + type + " voice-mail notification: From " + request.From, new { to = MyCell, from = ThisNumber }); // "Thank you for calling. I will contact you as soon as possible. " response.Play("/audio/closing.mp3"); response.Hangup(); return(TWiML(response)); }
public void Example_1() { var response = new TwilioResponse(); response.Hangup(); Assert.IsTrue(IsValidTwiML(response.ToXDocument())); }
public void Example_1() { var response = new TwilioResponse(); response.Hangup(); Assert.IsTrue(IsValidTwiML(response.ToXDocument())); }
public void Can_Generate_Single_Hangup() { var response = new TwilioResponse(); response.Hangup(); Assert.IsTrue(IsValidTwiML(response.ToXDocument())); }
public ActionResult Message(string body) { var response = new TwilioResponse(); response.Say($"Your text to me was {body.Length} characters long. Webhooks are neat :)"); response.Hangup(); return(TwiML(response)); }
public ActionResult ManageAccount(string CallSid, string Digits) { var call = GetCall(CallSid); TwilioResponse response = new TwilioResponse(); response.Say("Sorry. Account management is currently down for repairs. Please try again in 6 to 8 weeks."); response.Hangup(); return(SendTwilioResult(response)); }
public ActionResult Hangup() { var response = new TwilioResponse(); response.Say( "Your recording has been saved. Good bye"); response.Hangup(); 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 ActionResult Voice(string from) { var response = new TwilioResponse(); const string message = "Thanks for calling! " + "Your phone number is {0}. I got your call because of Twilio's webhook. " + "Goodbye!"; response.Say(string.Format(message, from)); response.Hangup(); return(TwiML(response)); }
public ActionResult CallComplete(string CallSid) { LocationalCall call = (LocationalCall)GetCall(CallSid); StateManager.CompletedCall(call); StateManager.AddToLog(CallSid, "Call is completed."); TwilioResponse response = new TwilioResponse(); response.Say("Goodbye baby cakes"); response.Hangup(); return(SendTwilioResult(response)); }
public TwiMLResult Index(VoiceRequest request) { var response = new TwilioResponse(); // Use <Say> to give the caller some instructions response.Say("Hello. Please leave a message after the beep."); // Use <Record> to record the caller's message response.Record(); // End the call with <Hangup> response.Hangup(); 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 TwilioResponse RespondToPreConnect(VoiceRequest request) { var response = new TwilioResponse(); if (request.Digits == "1") { response.Say("You are now being connected."); } else { response.Hangup(); } return(response); }
public TwiMLResult Index(VoiceRequest request) { var response = new TwilioResponse(); // Use <Say> to give the caller some instructions response.Say("Hello. Please leave a message and I will transcribe it."); // Use <Record> to record and transcribe the caller's message response.Record(new { transcribe = true, maxLength = 30 }); // End the call with <Hangup> response.Hangup(); return TwiML(response); }
private static TwiMLResult ReturnInstructions() { var response = new TwilioResponse(); response.Say("To get to your extraction point, get on your bike and go down " + "the street. Then Left down an alley. Avoid the police cars. Turn left " + "into an unfinished housing development. Fly over the roadblock. Go " + "passed the moon. Soon after you will see your mother ship.", new { voice = "alice", language = "en-GB" }); response.Say("Thank you for calling the ET Phone Home Service - the " + "adventurous alien's first choice in intergalactic travel"); response.Hangup(); return(new TwiMLResult(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); }
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 async Task <TwilioResponse> Complete(TwilioRequest request) { using (var db = dbFactory()) { var call = db.Calls.Where(f => f.CallId == request.CallSid).SingleOrDefault(); if (call != null) { call.Duration = request.CallDuration; await db.SaveChangesAsync(); this.config.GetPushHub <CallsHub>().updatedCall(CallsController.GetCallEntry(call)); } }; var response = new TwilioResponse(); response.Hangup(); return(LogResponse(response)); }
public async Task <ActionResult> HandleCustomerCall(string CallSid, string From) { var response = new TwilioResponse(); //check the caller ID and try to find a call config that matches it IMobileServiceTable <WarmCall> warmCallTable = MobileService.GetTable <WarmCall>(); var warmCalls = await warmCallTable.ReadAsync <WarmCall>(warmCallTable.Where(w => w.CustomerPhone == From)); var warmCall = warmCalls.FirstOrDefault(); if (warmCall != null) { //update with the call sid warmCall.CustomerCallSid = CallSid; await warmCallTable.UpdateAsync(warmCall); //put the customer into a conference response.Say("Please while while we conjure a support agent"); response.DialConference(CallSid); //dial an agent var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken); var result = client.InitiateOutboundCall("+17862200728", warmCall.AgentOnePhone, Url.ActionAbsolute("HandleAgentOneCall")); if (result.RestException != null) { Console.WriteLine(result.RestException.Message); } //let the browser know that the customer has connected and we're calling the agent } else { response.Say("Who are you? Go away!"); response.Hangup(); } return(TwiML(response)); }
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())); }
private TwilioResponse PingPerson(VoiceRequest request, string callingPartyId) { TwilioResponse response = new TwilioResponse(); var person = directory.GetContact(request.Digits); if (person != null) { if (person.AcceptCalls) { response.Say("We are now contacting " + person.Name + ", please hold the line"); response.Dial(new Number(person.MobileNumber, new { url = string.Format("/Router/PreConnect?callingPartyId={0}", callingPartyId) }), new { callerId = "+442033229301" }); } else { var divertedTo = directory.GetContact(person.DivertToId); if (divertedTo != null) { response.Say(person.Name + " is not currently accepting calls. Diverting you to " + divertedTo.Name); response.Dial(new Number(divertedTo.MobileNumber, new { url = string.Format("/Router/PreConnect?callingPartyId={0}", callingPartyId) }), new { callerId = "+442033229301" }); } else { response.Say("Unable to find someone to divert to..."); response.Hangup(); } } } else { response.Say("Person not found"); } return(response); }
//create a TwiML response to ignore the call public static TwilioResponse GetResponseIgnore(TwilioRequestVoice request, Entity.Client client, Entity.Call call) { if (log.IsDebugEnabled) { log.Debug("GetResponseIgnore.request." + (request == null ? "null" : request.ToJsonString())); } TwilioResponse resp = new TwilioResponse(); //TODO: create an ignored voicemail box to send the call to resp.Pause(1); resp.Say("Your call was ignored."); resp.Pause(1); resp.Hangup(); //log the current call state if (call != null) { call.CallResult = "call was ignored"; call.Save(); } return resp; }
//create a TwiML response for calls to an unknown client public static TwilioResponse GetResponseUnknownClient(TwilioRequestVoice request, Entity.Call call) { if (log.IsDebugEnabled) { log.Debug("GetResponseUnknownClient.request." + (request == null ? "null" : request.ToJsonString())); } TwilioResponse resp = new TwilioResponse(); resp.Pause(1); resp.Say("We're sorry. The person you are trying to reach could not be found."); resp.Pause(1); resp.Hangup(); //log the current call state if (call != null) { call.CallResult = "unknown client"; call.Save(); } return resp; }
//create a TwiML response to send the call to voicemail; appends the response to an existing response public static TwilioResponse GetResponseVoicemail(TwilioResponse resp, TwilioRequestVoice request, Entity.Client client, Entity.Call call) { if (log.IsDebugEnabled) { log.Debug("GetResponseVoicemail.request." + (request == null ? "null" : request.ToJsonString())); } //TODO: create valid voicemail box dial plan resp.Pause(1); resp.Say("You are being transferred to voicemail, but it's not setup yet. Goodbye."); resp.Pause(1); resp.Hangup(); //log the current call state if (call != null) { call.CallResult = "sent to voicemail"; call.Save(); } return resp; }
public void Hangup() { response.Hangup(); response.ToString(); }