Twilio(TwiML):拨打另一部电话 [英] Twilio (TwiML): Dial another phone
本文介绍了Twilio(TwiML):拨打另一部电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在该流中连接两个电话号码:
Person_1正在应答呼叫。播放了一条语音信息,询问他是否愿意参加电话会议。仅当Person_1接受电话会议时才会启动:
这就是我正在尝试做的事情:
Intro.chtml:
<Response>
<Gather numDigits="1" action="StartConferenceCall.chtml" method="GET">
<Say>Press 1 to start the conference call</Say>
</Gather>
</Response>
StartConferenceCall.chtml:
@{
var digits = Request["Digits"];
if(digits == "1")
{
<Response>
<Dial> // I would like to dial the second person
<Conference beep="false" record="record-from-start"
Room 1234
</Conference>
</Dial>
</Response>
}
else
{
<Hangup/>
}
}
是否可以在<Dial>
标记内添加第二个数字?
推荐答案
Twilio Developer传教士此处。
因为您更改了原始问题,所以我删除了上一个答案,并为您整理了另一个示例。
因为您希望自己启动呼叫,并让用户在他们想要接受问题时按1
,所以您需要使用REST API。具体地说,您希望initiate a new call然后提示用户按下按钮。下面的代码是C#。
public void CallUser(){
var client = new TwilioRestClient(AccountSid,AuthToken);
client.InitiateOutboundCall("from", "to", "/Call");
client.InitiateOutboundCall("from", "to", "/Conference");
}
在上面的代码中,我发起了两个调用。一个打给客户,另一个打给应该在线的另一个人。如果您愿意,您可以更改逻辑,但为了简化操作,我同时发起这两个呼叫。
第一次呼叫将把用户放到菜单上,他们可以在此按1加入呼叫。
public IActionResult Call()
{
var twiml = new TwilioResponse();
return TwiML(twiml.BeginGather(new { action = "/Conference", numDigits = "1" }).Say("Press 1 to start the conference call").EndGather());
}
然后,两个呼叫都被重定向到/conference
,在此创建或加入会议室。您可以使用逻辑检查用户是否在此处拨打了1
。
public IActionResult Conference()
{
var twiml = new TwilioResponse();
return TwiML(twiml.DialConference("Room 1234"));
}
希望这对您有帮助
这篇关于Twilio(TwiML):拨打另一部电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文