2016-01-20 115 views
1

我想连接该流程中的两个电话号码: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> t ag?

回答

1

Twilio开发者传道士在这里。

因为你已经改变了原来的问题,我删除了我以前的答案,并为你提供了另一个例子。

因为您想自己开始呼叫并让用户按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")); 
} 

希望这有助于你

+0

增加了一个新的链接,我的回答与文档发起新的呼叫。希望这有助于 –

+0

如何在这里添加命令“从开始记录”?谢谢。 – Eyal

+0

没关系,我在这里找到它:https://sites.google.com/site/dezpatterns/cloud/twilio/twilio-dial-conference-with-attributes – Eyal