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; }
private static TwiMLResult Dial(string phoneNumber) { var response = new TwilioResponse(); response.Dial(phoneNumber); return new TwiMLResult(response); }
public ActionResult Connect(string phoneNumber) { var response = new TwilioResponse(); var callerIDAttribute = new {callerId = _credentials.PhoneNumber}; if (phoneNumber != null) { response.Dial(callerIDAttribute, new Number(phoneNumber)); } else { response.Dial(callerIDAttribute, new Client("support_agent")); } return TwiML(response); }
public ActionResult Index(VoiceRequest request) { var response = new TwilioResponse(); if (!string.IsNullOrEmpty(request.To)) { response.Dial(new Number(request.To), new {callerId = "+15017250604"}); } else { response.Say("Thanks for calling!"); } return TwiML(response); }
public ActionResult Index(VoiceRequest request) { var response = new TwilioResponse(); if (!string.IsNullOrEmpty(request.To)) { var callerId = "+15017250604"; // wrap the phone number or client name in the appropriate TwiML verb // by checking if the number given has only digits and format symbols if (Regex.IsMatch(request.To, "^[\\d\\+\\-\\(\\) ]+$")) { response.Dial(new Number(request.To), new {callerId}); } else { response.Dial(new Client(request.To), new {callerId}); } } else { response.Say("Thanks for calling!"); } return TwiML(response); }
public ActionResult ForwardCall(string called, string caller, string fromCity, string fromState) { var leadSource = _leadSourcesRepository.FirstOrDefault(x => x.IncomingNumberInternational == called); _leadsRepository.Create(new Lead { LeadSourceId = leadSource.Id, City = fromCity, State = fromState, PhoneNumber = caller }); var response = new TwilioResponse(); response.Dial(leadSource.ForwardingNumber); return TwiML(response); }
public ActionResult Connect(string digits) { var isMuted = digits.Equals("1"); // Listener var canControlConferenceOnEnter = digits.Equals("3"); // Moderator var response = new TwilioResponse(); response.Say("You have joined the conference"); response.Dial() .DialConference("RapidResponseRoom", new { waitUrl = "http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient", muted = isMuted, startConferenceOnEnter = canControlConferenceOnEnter, endConferenceOnExit = canControlConferenceOnEnter }); return TwiML(response); }
public virtual ActionResult VoiceTwiML(string PhoneNumber) { var twiml = new TwilioResponse(); try { var number = new Number(PhoneNumber); twiml.Dial(number, new { callerId = MY_TWILIO_PHONENUMBER }); } catch (Exception) { //e.printStackTrace(); } Response.ContentType = "text/xml"; Response.Write(twiml.ToString()); Response.End(); return Content(""); }
public ActionResult Connect(string digits) { var extension = digits; var agent = FindAgentByExtension(extension); if (agent == null) { return RedirectToMenu(); } var response = new TwilioResponse(); response.Say("You'll be connected shortly to your planet.", new { voice = "alice", language = "en-GB" }); var number = new Number(agent.PhoneNumber, new { url = Url.Action("ScreenCall", "Agent")}); response.Dial(number, new {action = Url.Action("Call", "Agent", new {agentId = agent.Id})}); return TwiML(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 void ProcessRequest(HttpContext context) { string customerPhone = context.Request.QueryString.Get("customerPhone"); context.Response.Clear(); context.Response.ContentType = "text/xml"; context.Response.ContentEncoding = System.Text.Encoding.UTF8; var twiml = new Twilio.TwiML.TwilioResponse(); //twiml.Say("Hello Seba"); //twiml.Enqueue("QueueDemo"); DialCallProperties cp = new DialCallProperties(customerPhone); twiml.Dial("+17202822740", cp); context.Response.Write(twiml.ToString()); context.Response.End(); //string accountSid = "AC910947335f85f6b222394231ac5f064d"; //string authToken = "44e9b67a8f82209656db45e7575759c5"; //var twilio = new TwilioRestClient(accountSid, authToken); //var call = twilio.InitiateOutboundCall("+17209615246", "+17202822742", "http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient"); }
public HttpResponseMessage Get() { var client = new RestClient() { Timeout = 10000, BaseUrl = new System.Uri("https://<subdomain>.pagerduty.com/api/") }; client.AddDefaultParameter(new Parameter { Name = "Authorization", Value = "Token token=<token>", Type = ParameterType.HttpHeader }); var onCallRequest = new RestRequest("v1/escalation_policies/on_call", Method.GET); IRestResponse onCallResponse = client.Execute(onCallRequest); var content = onCallResponse.Content; dynamic pagerDutyOnCall = JsonConvert.DeserializeObject(content); dynamic user = pagerDutyOnCall.escalation_policies[0].escalation_rules[0].rule_object; User userObject = new Models.User(); userObject.id = user.id; userObject.name = user.name; userObject.email = user.email; var userRequest = new RestRequest("v1/users/" + userObject.id + "/contact_methods", Method.GET); IRestResponse userResponse = client.Execute(userRequest); var userDetails = userResponse.Content; dynamic userMobile = JsonConvert.DeserializeObject(userDetails); var contactCounts = userMobile.contact_methods.Count; for(int i = 0; i < contactCounts; i++) { if(userMobile.contact_methods[i].type == "phone") { userObject.mobile = "+" + userMobile.contact_methods[i].country_code + userMobile.contact_methods[i].address; } } var twilioResponse = new TwilioResponse(); twilioResponse.Say("Welcome to the Support Centre. Please wait while we route your call."); twilioResponse.Dial(userObject.mobile); return this.Request.CreateResponse(HttpStatusCode.OK, twilioResponse.Element, new XmlMediaTypeFormatter()); }
public HttpResponseMessage Message(string companyId, string departmentId, string messageId, string callSid) { var message = _directoryService.GetMessageById(int.Parse(messageId)); string media; var response = new TwilioResponse(); switch (message.MessageType) { case MessageType.Gumtree: media = ConfigurationManager.AppSettings.Get("GumtreeMessageUrl"); response.Play(media); break; case MessageType.Zoopla: media = ConfigurationManager.AppSettings.Get("ZooplaMessageUrl"); var silence = ConfigurationManager.AppSettings.Get("SilenceUrl"); //silence needed as zoopla IVR will cut off the first 2 seconds of the message file without it response.Play(silence); response.Play(media); response.Dial("+441202638560"); break; } _callService.UpdateCallBySid(new Call { Sid = callSid, CallStatus = CallStatus.MessageDelivered, DateReceived = DateTime.Now, QueueId = int.Parse(messageId) }); _logger.Debug($"Twiml generated for call {callSid}. {response.Element}"); return Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter()); }
public IActionResult HandleCall(string From) { var contact = _db.Contacts.FirstOrDefault(s => s.Number == From); var twiml = new TwilioResponse(); if (contact != null) { // It is a contact. // check whether they're allowed through if(!contact.Blocked){ return Content(twiml.Dial(Environment.GetEnvironmentVariable("MY_NUMBER")).ToString(), "text/xml"); } else{ return Content(twiml.Say(contact.Message).ToString(), "text/xml"); } } else{ return Content(twiml.Say("This number is only for contacts.").ToString(), "text/xml"); } }
private TwilioResponse AddToResponse(TwilioResponse response, Agent agent) { var dialAttributes = new { method = "GET", action = GetEcho("dial"), timeout = agent.TimeOut, record = agent.Record ? "record-from-answer" : "do-not-record" }; switch (agent.Answer) { case AnswerType.Number: var number = new Number(agent.RedirectToNumber); AddUrlAttr(number, GetEcho("client")); response.Dial(number, dialAttributes); break; case AnswerType.Client: var client = new Client(agent.ClientID); AddUrlAttr(client, GetEcho("client")); response.Dial(client, dialAttributes); break; case AnswerType.Sip: response.Dial(new Sip(agent.ClientID), dialAttributes); break; } return response; }
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; }
public HttpResponseMessage DialQueueOrNumber(DialQueueParameters clientParameters) { var response = new TwilioResponse(); if (string.IsNullOrEmpty(clientParameters.PhoneNumber)) { _logger.Debug($"Dialling queue {clientParameters.QueueName} for client {clientParameters.ClientName}"); var queue = _queueService.ResolveByName(clientParameters.QueueName); var call = _queueProvider.GetFirstCallFromQueue(queue); response.DialQueue(clientParameters.QueueName, new { record = "record-from-answer" }); _queueStateHandler.DecreaseQueueByName(clientParameters.QueueName); _callService.FlagCallConnected(call.Sid, clientParameters.ClientName); } else { var agentName = ""; var agent = new Agent(); string number; if (!string.IsNullOrEmpty(clientParameters.From)) { agentName = clientParameters.From.Split(':')[1]; var agentNamePeriod = agentName.Replace("_", "."); agent = _agentService.GetAgentByAgentEmail(agentNamePeriod + "@letme.com"); } if (agent.TeamId == "10") //Lead gen { number = WebConfigurationManager.AppSettings["TwilioNumberLeadGen"]; } else if (agent.TeamId == "12") { number = WebConfigurationManager.AppSettings["TwilioNumberPM"]; } else { number = WebConfigurationManager.AppSettings["TwilioNumber"]; } var callId = _callService.LogOutboundCall(new Call { Dialled = clientParameters.PhoneNumber, CallStatus = CallStatus.Initiated, DateReceived = DateTime.Now, ClientName = agentName }).CallId; var attributes = new { callerId = number, record = "record-from-answer", action = $"/api/CallStatus/Update?callId={callId}" }; response.Dial(clientParameters.PhoneNumber, attributes); } return Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter()); }