本文整理汇总了C#中Twilio.TwiML.TwilioResponse.Dial方法的典型用法代码示例。如果您正苦于以下问题:C# TwilioResponse.Dial方法的具体用法?C# TwilioResponse.Dial怎么用?C# TwilioResponse.Dial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twilio.TwiML.TwilioResponse
的用法示例。
在下文中一共展示了TwilioResponse.Dial方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PingTeamMember
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;
}
示例2: Dial
private static TwiMLResult Dial(string phoneNumber)
{
var response = new TwilioResponse();
response.Dial(phoneNumber);
return new TwiMLResult(response);
}
示例3: Connect
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);
}
示例4: Index
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);
}
示例5: Index
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);
}
示例6: ForwardCall
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);
}
示例7: Connect
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);
}
示例8: VoiceTwiML
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("");
}
示例9: Connect
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);
}
示例10: HandleGather
// /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);
}
示例11: ProcessRequest
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");
}
示例12: Get
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());
}
示例13: Message
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());
}
示例14: HandleCall
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");
}
}
示例15: AddToResponse
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;
}