static void Main() { var response = new VoiceResponse(); var dial = new Dial(callerId: "+1888XXXXXXX"); dial.Number("858-987-6543"); dial.Client("jenny"); dial.Client("tommy"); response.Dial(dial); System.Console.WriteLine(response.ToString()); }
static void Main() { var response = new VoiceResponse(); var dial = new Dial(callerId: "+1888XXXXXXX"); dial.Number("858-987-6543"); dial.Client("joey"); dial.Client("charlie"); response.Append(dial); Console.WriteLine(response.ToString()); }
public ActionResult Index(VoiceRequest request) { var response = new VoiceResponse(); 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\\+\\-\\(\\) ]+$")) { var number = new Dial(callerId: callerId); number.Number(Request.To); response.Dial(number); } else { var number = new Dial(callerId: callerId); number.Client(Request.To); response.Dial(number); } } else { response.Say("Thanks for calling!"); } return(Content(response.ToString(), "text/xml")); }
public ActionResult Index(string to) { var callerId = ConfigurationManager.AppSettings["TwilioCallerId"]; var response = new VoiceResponse(); if (!string.IsNullOrEmpty(to)) { var dial = new Dial(callerId: callerId); // 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(to, "^[\\d\\+\\-\\(\\) ]+$")) { dial.Number(to); } else { dial.Client(to); } response.Dial(dial); } else { response.Say("Thanks for calling!"); } return(Content(response.ToString(), "text/xml")); }
static void Main() { var response = new VoiceResponse(); var dial = new Dial(); dial.Client("jenny"); response.Append(dial); Console.WriteLine(response.ToString());; }
public ActionResult Index(string to) { var callerId = ConfigurationManager.AppSettings["TwilioCallerId"]; var response = new VoiceResponse(); if (!string.IsNullOrEmpty(to)) { var dial = new Dial(callerId: callerId); // 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 (to.Contains(myPhoneNumber)) { dial.Client("Jose"); // this works! } else if (Regex.IsMatch(to, "^[\\d\\+\\-\\(\\) ]+$")) { dial.Number(to); } else { dial.Client(to); } response.Dial(dial); } else { var dial = new Dial(callerId: callerId); dial.Number("+15555557898"); response .Say("Transferring your call to the Twilio client, Jose.") .Dial(dial); } return(Content(response.ToString(), "text/xml")); }
static void Main() { var response = new VoiceResponse(); var dial = new Dial(); dial.Client("jenny", statusCallbackEvent: "initiated ringing answered completed", statusCallback: "https://myapp.com/calls/events", statusCallbackMethod: "POST"); response.Dial(dial); System.Console.WriteLine(response.ToString()); }
static void Main() { var response = new VoiceResponse(); var dial = new Dial(); dial.Client("joey", statusCallbackEvent: new [] { Client.EventEnum .Initiated, Client.EventEnum.Ringing, Client.EventEnum.Answered, Client.EventEnum.Completed }.ToList(), statusCallback: new Uri("https://myapp.com/calls/events"), statusCallbackMethod: Twilio.Http.HttpMethod.Post); response.Append(dial); Console.WriteLine(response.ToString()); }
public ActionResult Connect(string phoneNumber) { var response = new VoiceResponse(); var dial = new Dial(callerId: _credentials.PhoneNumber); if (phoneNumber != null) { dial.Number(phoneNumber); } else { dial.Client("support_agent"); } response.Dial(dial); return(TwiML(response)); }
public void TestNestedDial() { Dial dial = new Dial(hangupOnStar: false, timeLimit: 100); dial.Client("client", method: "GET", url: "www.twilio.com"); var vr = new VoiceResponse(); vr.Dial(dial); Assert.AreEqual( vr.ToString(), "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Response>" + Environment.NewLine + " <Dial hangupOnStar=\"false\" timeLimit=\"100\">" + Environment.NewLine + " <Client method=\"GET\" url=\"www.twilio.com\">client</Client>" + Environment.NewLine + " </Dial>" + Environment.NewLine + "</Response>" ); }
public TwiMLResult Incoming([FromForm] string from) { if (enablePrivacyMode) { logger.LogInformation($"Receiving call from {MaskPhoneNumber(from)}"); } else { logger.LogInformation($"Receiving call from {from}"); } var response = new VoiceResponse(); var dial = new Dial(); logger.LogInformation($"Calling blazor_client"); dial.CallerId = from; dial.Client("blazor_client"); response.Append(dial); return(TwiML(response)); }
static void Main() { var response = new VoiceResponse(); var dial = new Dial(); dial.Client("jenny", statusCallbackEvent: new List <EventEnum>( new EventEnum[] { EventEnum.Initiated, EventEnum.Ringing, EventEnum.Answered, EventEnum.Completed } ), statusCallback: new Uri("https://myapp.com/calls/events"), statusCallbackMethod: HttpMethod.Post); response.Append(dial); Console.WriteLine(response.ToString());; }
private VoiceResponse AddToResponse(VoiceResponse response, Agent agent) { var dial = new Dial(method: "POST", action: GetEcho("dial"), timeout: agent.TimeOut, record: agent.Record ? "record-from-answer" : "do-not-record"); switch (agent.Answer) { case AnswerType.Number: response.Dial(dial.Number(agent.PhoneNumber, method: "POST", url: GetEcho("client"))); break; case AnswerType.Client: response.Dial(dial.Client(agent.ClientID, "POST", GetEcho("client"))); break; case AnswerType.Sip: response.Dial(dial.Sip(agent.ClientID, method: "POST", url: GetEcho("client"))); break; } return(response); }
//public ActionResult Index(string to) public ContentResult Index(string to) { // If there's a caller ID setup, grab it here var callerId = ConfigurationManager.AppSettings["TwilioCallerId"]; // Instantiate a new VoiceResponse var response = new VoiceResponse(); // If 'to' isn't empty or null, this is an outgoing call -- this should always have something if (!string.IsNullOrEmpty(to)) { // Build the Dial object for placing the call var dial = new Dial(callerId: callerId); /* Wrap the phone number or Constituent name in the appropriate TwiML verb * by checking if the number given has only digits and format symbols */ if (Regex.IsMatch(to, "^[\\d\\+\\-\\(\\) ]+$")) { dial.Number(to); } else { dial.Client(to); } // Append the caller ID response.Append(dial); } // 'to' was empty or null -- this is an incoming call (SHOULD NEVER HAPPEN) else { // Default voice playback when an incoming call is placed -- not going to be used response.Say("Thanks for calling!"); } // Send the information to Twilio return(Content(response.ToString(), "text/xml")); }
public void TestElementWithChildren() { var elem = new Dial(); elem.Client( "identity", new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, Promoter.ListOfOne(Client.EventEnum.Initiated), new Uri("https://example.com"), Twilio.Http.HttpMethod.Get ); elem.Conference( "name", true, Conference.BeepEnum.True, true, true, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, 1, Conference.RecordEnum.DoNotRecord, Conference.RegionEnum.Us1, "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", Conference.TrimEnum.TrimSilence, Promoter.ListOfOne(Conference.EventEnum.Start), new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, Promoter.ListOfOne(Conference.RecordingEventEnum.InProgress), new Uri("https://example.com"), Conference.JitterBufferSizeEnum.Large, "participant_label" ); elem.Number( new Twilio.Types.PhoneNumber("+15017122661"), "send_digits", new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, Promoter.ListOfOne(Number.EventEnum.Initiated), new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, "BYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); elem.Queue( "name", new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, "reservation_sid", "post_work_activity_sid" ); elem.Sim("DEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); elem.Sip( new Uri("https://example.com"), "username", "password", new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, Promoter.ListOfOne(Sip.EventEnum.Initiated), new Uri("https://example.com"), Twilio.Http.HttpMethod.Get ); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Dial>" + Environment.NewLine + " <Client url=\"https://example.com\" method=\"GET\" statusCallbackEvent=\"initiated\" statusCallback=\"https://example.com\" statusCallbackMethod=\"GET\">identity</Client>" + Environment.NewLine + " <Conference muted=\"true\" beep=\"true\" startConferenceOnEnter=\"true\" endConferenceOnExit=\"true\" waitUrl=\"https://example.com\" waitMethod=\"GET\" maxParticipants=\"1\" record=\"do-not-record\" region=\"us1\" coach=\"CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\" trim=\"trim-silence\" statusCallbackEvent=\"start\" statusCallback=\"https://example.com\" statusCallbackMethod=\"GET\" recordingStatusCallback=\"https://example.com\" recordingStatusCallbackMethod=\"GET\" recordingStatusCallbackEvent=\"in-progress\" eventCallbackUrl=\"https://example.com\" jitterBufferSize=\"large\" participantLabel=\"participant_label\">name</Conference>" + Environment.NewLine + " <Number sendDigits=\"send_digits\" url=\"https://example.com\" method=\"GET\" statusCallbackEvent=\"initiated\" statusCallback=\"https://example.com\" statusCallbackMethod=\"GET\" byoc=\"BYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\">+15017122661</Number>" + Environment.NewLine + " <Queue url=\"https://example.com\" method=\"GET\" reservationSid=\"reservation_sid\" postWorkActivitySid=\"post_work_activity_sid\">name</Queue>" + Environment.NewLine + " <Sim>DEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Sim>" + Environment.NewLine + " <Sip username=\"username\" password=\"password\" url=\"https://example.com\" method=\"GET\" statusCallbackEvent=\"initiated\" statusCallback=\"https://example.com\" statusCallbackMethod=\"GET\">https://example.com</Sip>" + Environment.NewLine + "</Dial>", elem.ToString() ); }
public ActionResult Receive(string CallerName) { //CallerName = CallerName.Replace("+1", ""); //CallerName = "Phonenum" + CallerName; var from = Request["From"]; var to = Request["To"]; var callsid = Request["CallSid"]; var callaction = Request["action"]; var digits = Request["Digits"]; var steps = Request["step"]; var fromcode = Request["CallerCountry"]; var tocode = Request["ToCountry"]; var callerId = ConfigurationManager.AppSettings["TwilioCallerId"]; try { var liasionid = _db.Liaisons.AsNoTracking().Where(x => x.TwilioCallerId == to).FirstOrDefault()?.Id; var callHistory = new CallHistory() { To = to.Replace(HelperExtensions.TelCodes.Where(x => x.Iso == tocode).FirstOrDefault().Pfx, ""), From = from.Replace(HelperExtensions.TelCodes.Where(x => x.Iso == fromcode).FirstOrDefault().Pfx, ""), Status = "Incoming/Not Answer", StartTime = DateTime.Now, TwilioCallId = callsid, Direction = "Incoming", LiaisonId = liasionid ?? 0 }; _db.CallHistories.Add(callHistory); _db.SaveChanges(); } catch (Exception ex) { WriteErrorLog(ex); } //test var response = new VoiceResponse(); if (Request["Digits"] == "0") { var dial = new Dial(callerId: to, record: "Record-from-answer", action: Url.ActionUri("VoiceMail", "Voice"), recordingStatusCallback: Url.ActionUri("SaveRecordings", "Voice"), recordingStatusCallbackMethod: Twilio.Http.HttpMethod.Post); dial.Client(CallerName); response.Dial(dial); return(TwiML(response)); } else { // var dial = new Dial(callerId: to, record: "Record-from-answer"); var dial = new Dial(record: "Record-from-ringing", recordingStatusCallback: Url.ActionUri("SaveRecordings", "Voice"), recordingStatusCallbackMethod: Twilio.Http.HttpMethod.Post); dial.Client(CallerName); //dial.Action = new Uri("/Voice/SaveRecordings"); //dial.Method = Twilio.Http.HttpMethod.Post; //var gather = new Gather(action: Url.ActionUri("Receive", "Voice",""), numDigits: 1, method: Twilio.Http.HttpMethod.Post, timeout: 5); //gather.Say("Thank you for calling " + // "Press 0 to make a call.", voice: Say.VoiceEnum.Woman, loop: 2); response.Append(new Say("Thank you for calling " + "Please wait we are connecting your call.", voice: Say.VoiceEnum.Woman, loop: 1)).Append(dial).Append(new Say("Please record voice mail after beep if not answer", voice: Say.VoiceEnum.Woman)).Append(new Record(action: Url.ActionUri("VoiceMail", "Voice"), method: Twilio.Http.HttpMethod.Post, timeout: 3, playBeep: true)); return(TwiML(response)); } //var response = new VoiceResponse(); //response.Say("Thanks for calling!"); //return Content(response.ToString(), "text/xml"); }