public TwiMLResult Call(string agentId, string dialCallStatus) { if (dialCallStatus == "completed") { var emptyResponse = new XDocument(new XElement("Root", "")); return(new TwiMLResult(emptyResponse)); } var response = new VoiceResponse(); response.Say( body: "It appears that no agent is available. " + "Please leave a message after the beep", language: "en-GB", voice: "alice" ); response.Record( maxLength: 20, playBeep: true, action: Url.Action("Hangup"), transcribeCallback: Url.Action("Create", "Recording", new { agentId }) ); response.Say( body: "No record received. Goodbye", language: "en-GB", voice: "alice" ); response.Hangup(); return(TwiML(response)); }
static void Main() { var response = new VoiceResponse(); response.Record(); Console.WriteLine(response.ToString());; }
static void Main() { var response = new VoiceResponse(); response.Record(timeout: 10, transcribe: true); System.Console.WriteLine(response.ToString()); }
public TwiMLResult RecordMessage() { var response = new VoiceResponse(); response.Say("Please record your message after the beep. press the pound key when you are done", voice: "alice", language: "en-US"); response.Record(action: "/Welcome/SaveMessage", finishOnKey: "#", timeout: 10); return(TwiML(response)); }
static void Main() { var response = new VoiceResponse(); response.Record(transcribe: "true", transcribeCallback: "/handle_transcribe.php"); System.Console.WriteLine(response.ToString()); }
static void Main() { var response = new VoiceResponse(); response.Record(transcribe: true, transcribeCallback: new Uri("/handle_transcribe.php")); Console.WriteLine(response.ToString()); }
public ActionResult Index() { var response = new VoiceResponse(); response.Say("Hi! I want to know what do you think about coding."); response.Record(maxLength: 10, action: new Uri("/recording", UriKind.Relative)); response.Hangup(); return(TwiML(response)); }
static void Main() { var response = new VoiceResponse(); response .Say("Please leave a message at the beep.\nPress the star key when finished."); response.Record(action: new Uri("http://foo.edu/handleRecording.php"), method: HttpMethod.Get, maxLength: 20, finishOnKey: "*"); response.Say("I did not receive a recording"); Console.WriteLine(response.ToString());; }
public TwiMLResult VerifyCustomer(string phoneNumber, string digits) { var response = new VoiceResponse(); if (digits == "2") { return(TwiML(response.Redirect("/Welcome/GetCustomer", method: "GET"))); } else if (digits == "1") { SalesRepository repo = new SalesRepository(); Customer customer = repo.FindCustomerByPhoneNumber(phoneNumber); if (customer != null) { Order order = repo.GetOrderByCustomerId(customer.CustomerID); if (order != null) { response.Say("we found an order associated with this phone number, you will now be redirected to the review option", voice: "alice", language: "en-US"); Session["customerId"] = customer.CustomerID; Session["orderId"] = order.OrderID; response.Redirect("/Review/CheckForBalanceOwed"); return(TwiML(response)); } else { Order o = new Order { CustomerID = customer.CustomerID, OrderDate = DateTime.Now, TotalQuantity = 0, TotalCost = 0, TotalAmountPaid = 0 }; repo.CreateOrder(o); Session["orderId"] = o.OrderID; return(ChooseItem()); } } else { response.Say("Please record your name and address after the beep. press the pound key when you are done", voice: "alice", language: "en-US"); response.Record(action: "/Welcome/CaptureRecording?phoneNumber=" + phoneNumber, finishOnKey: "#"); return(TwiML(response)); } } else { return(TwiML(response.Say("Invalid choice").Redirect("/Welcome/VerifyNumber?digits=" + phoneNumber))); } }
public void TestRecord() { var vr = new VoiceResponse(); vr.Record(transcribe: true, method: "GET", action: "www.twilio.com"); Assert.AreEqual( vr.ToString(), "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Response>" + Environment.NewLine + " <Record transcribe=\"true\" action=\"www.twilio.com\" method=\"GET\" />" + Environment.NewLine + "</Response>" ); }
public ActionResult Index() { var response = new VoiceResponse(); // 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 Content(response.ToString(), "text/xml") }
public ActionResult Index() { var response = new VoiceResponse(); // 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(transcribe: true, maxLength: 30); // End the call with <Hangup> response.Hangup(); return(Content(response.ToString(), "text/xml")); }
private void AddRecordOrGatherCommands(VoiceResponse response) { QuestionType questionType = this._question.Type; switch (questionType) { case QuestionType.Voice: response.Record(action: GenerateUrl(this._question), transcribe: true, playBeep: true, transcribeCallback: GenerateTranscribeUrl(this._question)); break; case QuestionType.Numeric: case QuestionType.YesNo: response.Gather(action: GenerateUrl(this._question), timeout: 30, numDigits: 1); break; } }
private void AddRecordOrGatherCommands(VoiceResponse response) { var questionType = _question.Type; switch (questionType) { case QuestionType.Voice: response.Record(action: GenerateUrl(_question)); break; case QuestionType.Numeric: case QuestionType.YesNo: response.Gather(action: GenerateUrl(_question)); break; } }
// /Voice/HandleGather public ActionResult HandleGather() { var response = new VoiceResponse(); switch (Request.Form["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(maxLength: 30, action: "/Voice/HandleRecord"); break; default: response.Redirect("/Voice"); break; } return(Content(response.ToString(), "text/xml")); }
public void TestElementWithChildren() { var elem = new VoiceResponse(); elem.Dial( "number", new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, 1, true, 1, "caller_id", Dial.RecordEnum.DoNotRecord, Dial.TrimEnum.TrimSilence, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, Promoter.ListOfOne(Dial.RecordingEventEnum.InProgress), true, Dial.RingToneEnum.At ); elem.Echo(); elem.Enqueue( "name", new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, "workflow_sid" ); elem.Gather( Gather.InputEnum.Dtmf, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, 1, "speech_timeout", 1, true, "finish_on_key", 1, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, Gather.LanguageEnum.AfZa, "hints", true ); elem.Hangup(); elem.Leave(); elem.Pause(1); elem.Play(new Uri("https://example.com"), 1, "digits"); elem.Queue( "name", new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, "reservation_sid", "post_work_activity_sid" ); elem.Record( new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, 1, "finish_on_key", 1, true, Record.TrimEnum.TrimSilence, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, true, new Uri("https://example.com") ); elem.Redirect(new Uri("https://example.com"), Twilio.Http.HttpMethod.Get); elem.Reject(Reject.ReasonEnum.Rejected); elem.Say("message", Say.VoiceEnum.Man, 1, Say.LanguageEnum.DaDk); elem.Sms( "message", new Twilio.Types.PhoneNumber("+15558675310"), new Twilio.Types.PhoneNumber("+15017122661"), new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, new Uri("https://example.com") ); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Response>" + Environment.NewLine + " <Dial action=\"https://example.com\" method=\"GET\" timeout=\"1\" hangupOnStar=\"true\" timeLimit=\"1\" callerId=\"caller_id\" record=\"do-not-record\" trim=\"trim-silence\" recordingStatusCallback=\"https://example.com\" recordingStatusCallbackMethod=\"GET\" recordingStatusCallbackEvent=\"in-progress\" answerOnBridge=\"true\" ringTone=\"at\">number</Dial>" + Environment.NewLine + " <Echo></Echo>" + Environment.NewLine + " <Enqueue action=\"https://example.com\" method=\"GET\" waitUrl=\"https://example.com\" waitUrlMethod=\"GET\" workflowSid=\"workflow_sid\">name</Enqueue>" + Environment.NewLine + " <Gather input=\"dtmf\" action=\"https://example.com\" method=\"GET\" timeout=\"1\" speechTimeout=\"speech_timeout\" maxSpeechTime=\"1\" profanityFilter=\"true\" finishOnKey=\"finish_on_key\" numDigits=\"1\" partialResultCallback=\"https://example.com\" partialResultCallbackMethod=\"GET\" language=\"af-ZA\" hints=\"hints\" bargeIn=\"true\"></Gather>" + Environment.NewLine + " <Hangup></Hangup>" + Environment.NewLine + " <Leave></Leave>" + Environment.NewLine + " <Pause length=\"1\"></Pause>" + Environment.NewLine + " <Play loop=\"1\" digits=\"digits\">https://example.com</Play>" + Environment.NewLine + " <Queue url=\"https://example.com\" method=\"GET\" reservationSid=\"reservation_sid\" postWorkActivitySid=\"post_work_activity_sid\">name</Queue>" + Environment.NewLine + " <Record action=\"https://example.com\" method=\"GET\" timeout=\"1\" finishOnKey=\"finish_on_key\" maxLength=\"1\" playBeep=\"true\" trim=\"trim-silence\" recordingStatusCallback=\"https://example.com\" recordingStatusCallbackMethod=\"GET\" transcribe=\"true\" transcribeCallback=\"https://example.com\"></Record>" + Environment.NewLine + " <Redirect method=\"GET\">https://example.com</Redirect>" + Environment.NewLine + " <Reject reason=\"rejected\"></Reject>" + Environment.NewLine + " <Say voice=\"man\" loop=\"1\" language=\"da-DK\">message</Say>" + Environment.NewLine + " <Sms to=\"+15558675310\" from=\"+15017122661\" action=\"https://example.com\" method=\"GET\" statusCallback=\"https://example.com\">message</Sms>" + Environment.NewLine + "</Response>", elem.ToString() ); }
public void TestElementWithChildren() { var elem = new VoiceResponse(); elem.Connect(new Uri("https://example.com"), Twilio.Http.HttpMethod.Get); elem.Dial( "number", new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, 1, true, 1, "caller_id", Dial.RecordEnum.DoNotRecord, Dial.TrimEnum.TrimSilence, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, Promoter.ListOfOne(Dial.RecordingEventEnum.InProgress), true, Dial.RingToneEnum.At ); elem.Echo(); elem.Enqueue( "name", new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, "workflow_sid" ); elem.Gather( Promoter.ListOfOne(Gather.InputEnum.Dtmf), new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, 1, "speech_timeout", 1, true, "finish_on_key", 1, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, Gather.LanguageEnum.AfZa, "hints", true, true, true, Gather.SpeechModelEnum.Default, true ); elem.Hangup(); elem.Leave(); elem.Pause(1); elem.Play(new Uri("https://example.com"), 1, "digits"); elem.Queue( "name", new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, "reservation_sid", "post_work_activity_sid" ); elem.Record( new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, 1, "finish_on_key", 1, true, Record.TrimEnum.TrimSilence, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, Promoter.ListOfOne(Record.RecordingEventEnum.InProgress), true, new Uri("https://example.com") ); elem.Redirect(new Uri("https://example.com"), Twilio.Http.HttpMethod.Get); elem.Reject(Reject.ReasonEnum.Rejected); elem.Say("message", Say.VoiceEnum.Man, 1, Say.LanguageEnum.Arb); elem.Sms( "message", new Twilio.Types.PhoneNumber("+15558675310"), new Twilio.Types.PhoneNumber("+15017122661"), new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, new Uri("https://example.com") ); elem.Pay( Pay.InputEnum.Dtmf, new Uri("https://example.com"), Pay.BankAccountTypeEnum.ConsumerChecking, new Uri("https://example.com"), Pay.StatusCallbackMethodEnum.Get, 1, 1, true, "postal_code", 1, "payment_connector", Pay.PaymentMethodEnum.AchDebit, Pay.TokenTypeEnum.OneTime, "charge_amount", "currency", "description", Promoter.ListOfOne(Pay.ValidCardTypesEnum.Visa), Pay.LanguageEnum.DeDe ); elem.Prompt( Prompt.ForEnum.PaymentCardNumber, Promoter.ListOfOne(Prompt.ErrorTypeEnum.Timeout), Promoter.ListOfOne(Prompt.CardTypeEnum.Visa), Promoter.ListOfOne(1) ); elem.Start(new Uri("https://example.com"), Twilio.Http.HttpMethod.Get); elem.Stop(); elem.Refer(new Uri("https://example.com"), Twilio.Http.HttpMethod.Get); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Response>" + Environment.NewLine + " <Connect action=\"https://example.com\" method=\"GET\"></Connect>" + Environment.NewLine + " <Dial action=\"https://example.com\" method=\"GET\" timeout=\"1\" hangupOnStar=\"true\" timeLimit=\"1\" callerId=\"caller_id\" record=\"do-not-record\" trim=\"trim-silence\" recordingStatusCallback=\"https://example.com\" recordingStatusCallbackMethod=\"GET\" recordingStatusCallbackEvent=\"in-progress\" answerOnBridge=\"true\" ringTone=\"at\">number</Dial>" + Environment.NewLine + " <Echo></Echo>" + Environment.NewLine + " <Enqueue action=\"https://example.com\" method=\"GET\" waitUrl=\"https://example.com\" waitUrlMethod=\"GET\" workflowSid=\"workflow_sid\">name</Enqueue>" + Environment.NewLine + " <Gather input=\"dtmf\" action=\"https://example.com\" method=\"GET\" timeout=\"1\" speechTimeout=\"speech_timeout\" maxSpeechTime=\"1\" profanityFilter=\"true\" finishOnKey=\"finish_on_key\" numDigits=\"1\" partialResultCallback=\"https://example.com\" partialResultCallbackMethod=\"GET\" language=\"af-ZA\" hints=\"hints\" bargeIn=\"true\" debug=\"true\" actionOnEmptyResult=\"true\" speechModel=\"default\" enhanced=\"true\"></Gather>" + Environment.NewLine + " <Hangup></Hangup>" + Environment.NewLine + " <Leave></Leave>" + Environment.NewLine + " <Pause length=\"1\"></Pause>" + Environment.NewLine + " <Play loop=\"1\" digits=\"digits\">https://example.com</Play>" + Environment.NewLine + " <Queue url=\"https://example.com\" method=\"GET\" reservationSid=\"reservation_sid\" postWorkActivitySid=\"post_work_activity_sid\">name</Queue>" + Environment.NewLine + " <Record action=\"https://example.com\" method=\"GET\" timeout=\"1\" finishOnKey=\"finish_on_key\" maxLength=\"1\" playBeep=\"true\" trim=\"trim-silence\" recordingStatusCallback=\"https://example.com\" recordingStatusCallbackMethod=\"GET\" recordingStatusCallbackEvent=\"in-progress\" transcribe=\"true\" transcribeCallback=\"https://example.com\"></Record>" + Environment.NewLine + " <Redirect method=\"GET\">https://example.com</Redirect>" + Environment.NewLine + " <Reject reason=\"rejected\"></Reject>" + Environment.NewLine + " <Say voice=\"man\" loop=\"1\" language=\"arb\">message</Say>" + Environment.NewLine + " <Sms to=\"+15558675310\" from=\"+15017122661\" action=\"https://example.com\" method=\"GET\" statusCallback=\"https://example.com\">message</Sms>" + Environment.NewLine + " <Pay input=\"dtmf\" action=\"https://example.com\" bankAccountType=\"consumer-checking\" statusCallback=\"https://example.com\" statusCallbackMethod=\"GET\" timeout=\"1\" maxAttempts=\"1\" securityCode=\"true\" postalCode=\"postal_code\" minPostalCodeLength=\"1\" paymentConnector=\"payment_connector\" paymentMethod=\"ach-debit\" tokenType=\"one-time\" chargeAmount=\"charge_amount\" currency=\"currency\" description=\"description\" validCardTypes=\"visa\" language=\"de-DE\"></Pay>" + Environment.NewLine + " <Prompt for=\"payment-card-number\" errorType=\"timeout\" cardType=\"visa\" attempt=\"1\"></Prompt>" + Environment.NewLine + " <Start action=\"https://example.com\" method=\"GET\"></Start>" + Environment.NewLine + " <Stop></Stop>" + Environment.NewLine + " <Refer action=\"https://example.com\" method=\"GET\"></Refer>" + Environment.NewLine + "</Response>", elem.ToString() ); }