【问题标题】:Announcing the name of participant joining the Conference宣布参加会议的与会者姓名
【发布时间】:2014-05-20 08:10:52
【问题描述】:

我正在使用 Twilio 构建一个简单的会议,其中一个会议由代理使用 Twilio 客户端启动,并且一个联系人被调用并添加到该会议中。在将此联系人添加到会议之前,我们想在会议室中宣布该联系人的姓名(例如:<Say>Now Joining Sam Carter </Say>)。这个人的名字是根据他们从数据库中的电话号码计算出来的。

当呼叫连接时,执行以下 TwiML 将联系人连接到会议:

<Dial callerId="+1415xxxxxxx" record="true" action="/my/action/url">
    <Conference endConferenceOnExit="true" >ConferenceRoom1</Conference>
</Dial>

有什么方法可以在&lt;DIAL&gt; 动词执行之前将消息播放到会议中。如果我在 &lt;DIAL&gt; 之前写 &lt;SAY&gt; 动词,那么它会向联系人播放消息,而不是在 CONFERENCEROOM1 中。

是否有像 onConferenceEnter 这样的事件,可用于在某个参与者进入会议时触发另一个 TwiML?请提出实现此行为的最佳方法。

【问题讨论】:

    标签: twilio


    【解决方案1】:

    对这个问题的简短回答是,它不能通过 Twiml 事件来完成,但是可以通过使用他们的 REST API 的一种 hack 来完成。

    该问题已在 SO 上提出,答案可在此处获得:

    Use Say verb to all Conference participants

    如果问题/答案被删除/删除,我已将其粘贴在下面:


    这应该类似于一个好的端到端解决方案。

    首先,用户拨入,您通过标准提示获取会议室的 PIN 及其姓名。

    <?xml version="1.0" encoding="UTF-8"?>
    <Response>
        <Gather action="/conference/pin" finishOnKey="#">
            <Say>Please the conference pin number followed by the pound key.</Say>
        </Gather>
    </Response>
    
    <?xml version="1.0" encoding="UTF-8"?>
    <Response>
        <Say>Say your name and then press the pound key.</Say>
        <Record action="/conference/name" finishOnKey="#" />
    </Response>
    

    现在,一旦您有了用户的密码和录音,就会发生两件事;帖子对 /conference/name 的响应将包含动词,将用户置于房间中:

    <?xml version="1.0" encoding="UTF-8"?>
    <Response>
      <Dial>
        <Conference>{conference ID}</Conference>
      </Dial>
    </Response>
    

    ...并且,与此异步,它将使用 REST API 向会议室发起新的呼叫。

    POST /2010-04-01/Accounts/{AccountSid}/Calls
    From = {your conference phone number}
    To = {your conference phone number}
    SendDigits = wwww{conference PIN}#
    Url = /conference/announce?name={name ID}
    

    现在,下一点变得令人困惑。 Twilio 现在将与您的呼叫传入结束的回调 URL 和您在上面为呼叫的传出结束指定的 URL 交谈。您的来电处理程序将需要检测到会议线路正在回叫自身并且行为不同;它首先需要使用简单的 TwiML 进行响应,该 TwiML 允许呼叫的呼出端输入会议室的 pin。

    <?xml version="1.0" encoding="UTF-8"?>
    <Response>
        <Gather action="/conference/announce-pin" finishOnKey="#" />
    </Response>
    

    POST 的 SendDigits 参数将提供 TwiML 位所期望的数字。然后,该操作应通过新呼叫中的会议来响应。

    <?xml version="1.0" encoding="UTF-8"?>
    <Response>
      <Dial>
        <Conference>{conference ID}</Conference>
      </Dial>
    </Response>
    

    最后一块拼图是您在 POST 中指定的 URL 发出的 TwiML。这就是将环回呼叫添加到会议后将运行的标记。

    <?xml version="1.0" encoding="UTF-8"?>
    <Response>
        <Play>/conference/name-recordings/{name ID}</Play>
        <Say>has joined the call.</Say>
        <Hangup />
    </Response>
    

    该标记运行,将呼叫者的姓名和消息播放到会议室,然后挂断。

    【讨论】:

      【解决方案2】:

      为了他人的利益,这就是我实现此行为的方式:

      1. 代理已使用 Twilio 客户端开始会议,并且他已经在会议中。一旦参与者即将加入同一个会议,请使用 REST API 修改实时电话会议的 URL。

        TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
        Map<String, String> filter = new HashMap<String, String>();
        filter.put("From", "client:AGENT1");
        filter.put("Status", "in-progress");
        CallList callList = account.getCalls(filter); 
        Call agentsCall = null;
        for (Call inProgressCall : callList) {
            agentsCall = inProgressCall;
            break; //return the first one only..there shouldn't be more
        }
        Map<String, String> agentsCallParams = new HashMap<String, String>();  
        agentsCallParams.put("Url", "http://myserver.com/twiml/agentmessage.xml");
        agentsCallParams.put("Method", "GET");
        agentsCall.update(agentsCallParams);`
        
      2. 上面的代码 sn-p 将更新现有调用的 twiml,如下所示。

        <?xml version="1.0" encoding="UTF-8"?>
        <Response>
            <Say>Now joining {name of the participant}</Say>
            <Dial>
               <Conference>Conference1</Conference>
            </Dial>
        </Response>
        
      3. 上述 Twiml 将更新呼叫以播放 &lt;SAY&gt; 动词中的消息,然后将座席放回会议中。

      4. 现在,通过返回以下 Twiml 使参与者加入同一个会议:

        <?xml version="1.0" encoding="UTF-8"?>
        <Response>
        <Dial>
            <Conference>Conference1</Conference>
        </Dial>
        

        希望对你有帮助!!!

      【讨论】:

        猜你喜欢
        • 2016-05-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多