本文整理汇总了C#中Twilio.TwiML.TwilioResponse类的典型用法代码示例。如果您正苦于以下问题:C# TwilioResponse类的具体用法?C# TwilioResponse怎么用?C# TwilioResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TwilioResponse类属于Twilio.TwiML命名空间,在下文中一共展示了TwilioResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
// /Voice
public TwiMLResult Index(VoiceRequest request)
{
var response = new TwilioResponse();
response.Say("Hello. It's me.");
response.Play("http://howtodocs.s3.amazonaws.com/ahoyhoy.mp3");
return TwiML(response);
}
示例2: Can_Generate_Enqueue_With_Name
public void Can_Generate_Enqueue_With_Name()
{
var response = new TwilioResponse();
response.Enqueue("example");
Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
}
示例3: Can_Generate_Enqueue_With_Options_And_TaskAttributes
public void Can_Generate_Enqueue_With_Options_And_TaskAttributes()
{
var response = new TwilioResponse();
response.Enqueue(new { action = "example.xml", method = "GET", waitUrl = "wait.xml", waitUrlMethod = "GET", workspaceSid = "WSXXXXX" }, "{'task':'attributes'}");
Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
}
示例4: Index
public TwiMLResult Index(VoiceRequest request)
{
var response = new TwilioResponse();
if (!string.IsNullOrEmpty(request.Digits))
{
switch (request.Digits)
{
case "1":
response.Say("You selected sales. Good for you!");
break;
case "2":
response.Say("You need support. We will help!");
break;
default:
response.Say("Sorry, I don't understand that choice.").Pause();
RenderMainMenu(response);
break;
}
}
else
{
// If no input was sent, use the <Gather> verb to collect user input
RenderMainMenu(response);
}
return TwiML(response);
}
示例5: RedirectWelcome
private TwiMLResult RedirectWelcome()
{
var response = new TwilioResponse();
response.Redirect(Url.Action("Welcome", "IVR"));
return TwiML(response);
}
示例6: ResponseToSms
public TwilioResponse ResponseToSms(SmsRequest request)
{
var response = new TwilioResponse();
try
{
string outboundPhoneNumber = request.From;
var client = new TwilioRestClient(accountSid, authToken);
var call = client.InitiateOutboundCall(
twilioPhoneNumber,
outboundPhoneNumber,
"http://refuniteivr.azurewebsites.net/api/IVREntry");
if (call.RestException == null)
{
response.Sms("starting call to " + outboundPhoneNumber);
}
else
{
response.Sms("failed call to " + outboundPhoneNumber + " " + call.RestException.Message);
}
return response;
}
catch (Exception ex)
{
response.Sms("exception: " + ex.Message);
return response;
}
}
示例7: Dial
private static TwiMLResult Dial(string phoneNumber)
{
var response = new TwilioResponse();
response.Dial(phoneNumber);
return new TwiMLResult(response);
}
示例8: BroadcastReplyMenuSelection
public TwilioResponse BroadcastReplyMenuSelection(VoiceRequest request, int profileId, int lastBroadcastIdx, int subBroadcastIdx)
{
var response = new TwilioResponse();
var selection = request.Digits;
switch (selection)
{
case "1":
response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_REPLY_PRIVATELY, profileId, lastBroadcastIdx, subBroadcastIdx));
return response;
case "2":
response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_REPLY_PUBLICLY, profileId, lastBroadcastIdx, subBroadcastIdx));
return response;
case "3":
response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_PLAY_PUBLIC_REPLY, profileId, lastBroadcastIdx, ++subBroadcastIdx));
return response;
case "4":
response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_LISTEN_TO_ALL_PUBLIC, profileId, ++lastBroadcastIdx));
return response;
case "5":
response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_ADD_REPLIER_AS_FAVOURITE, profileId, lastBroadcastIdx, subBroadcastIdx));
return response;
default:
response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU));
return response;
}
}
示例9: Connect
public ActionResult Connect()
{
var response = new TwilioResponse();
response.Say("Connecting you to an agent");
return TwiML(response);
}
示例10: Post
//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());
}
}
示例11: Hello
public ActionResult Hello()
{
var response = new TwilioResponse();
response.Say("Hello there! Your Twilio environment has been configured.");
response.Say("Good luck during the workshop!", new { Voice = "woman" });
return TwiML(response);
}
示例12: TwilioResponseResult
public TwilioResponseResult(Action<TwilioResponse> buildResponse)
{
var response = new TwilioResponse();
buildResponse(response);
Content = response.Element.ToString();
ContentType = new MediaTypeHeaderValue("text/xml");
}
示例13: Index
public ActionResult Index(VoiceRequest request)
{
var response = new TwilioResponse();
response.Say("Hello! You will get an SMS message soon.");
response.Sms("This is the ship that made the Kessel Run in fourteen parsecs?");
return TwiML(response);
}
示例14: Can_Generate_Enqueue_With_Options_And_TaskAttributes_And_Priority_And_Timeout
public void Can_Generate_Enqueue_With_Options_And_TaskAttributes_And_Priority_And_Timeout()
{
var response = new TwilioResponse();
response.Enqueue(new { action = "example.xml", method = "GET", waitUrl = "wait.xml", waitUrlMethod = "GET", workflowSid = "WFXXXXX" }, "{'task':'attributes'}", new {priority="10", timeout="30"});
Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
}
示例15: Dial
/// <summary>
/// Action Method that returns the TwiML needed to connect an 'Agent' to the first call in the Queue
/// </summary>
/// <remarks>This method also includes the 'url' parameter in the generated TwiML. This allows you to provide a URL that can return TwiML that will be executed to the dequeued caller as a Whisper</remarks>
/// <returns></returns>
public ActionResult Dial()
{
var response = new TwilioResponse();
response.DialQueue("Demo Queue", new { url = Url.Action("Connect") }, new { });
return TwiML(response);
}