【问题标题】:Twilio (TwiML): Dial another phoneTwilio (TwiML):拨打另一部电话
【发布时间】:2016-01-20 07:40:45
【问题描述】:

我想在该流程中连接两个电话号码:

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/>
    }

}

是否可以在&lt;Dial&gt; 标签内添加第二个数字?

【问题讨论】:

    标签: twilio twilio-twiml


    【解决方案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"));
    }
    

    希望对你有帮助

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多