php 将Twilio呼叫预订出队到会议室

qmelpv7a  于 2023-01-24  发布在  PHP
关注(0)|答案(1)|浏览(96)

我正在尝试使用PHP/Symfony和JavaScript Voice SDK将排队的入站呼叫出队到会议室。
我现在要做的是将呼叫从队列中取出给单个代理。但是我想启用监督监控和指导。为此,我似乎需要一个会议室。
在服务器端,我使用默认的“分配给任何人”工作流将呼叫排队...

$voiceResponse = new VoiceResponse;
        $enqueue = $voiceResponse->enqueue('',['workflowSid' => $ccmanager->getWorkflowSid()]);
        $xml = $voiceResponse->asXml();
        $response = new Response($xml, Response::HTTP_OK, ['context-type' => 'text/xml']);
        return $response;

客户端,当其中一个代理决定接听电话时,我会取消预订...

this.dequeueReservation = function(data)
{
    let contactUri = self.getContactUri();
    let reservation = self.getReservation(data.phone_number);
    if(reservation) {
        console.log('before reservation dequeue');
        reservation.dequeue(
            null,
            null,
            'record-from-answer',
            30, // seconds to answer
            'https://d72d-76-18-83-142.ngrok.io/anon/voice/status', // status callback url
            'initiated,ringing,answered,completed',
            contactUri,
            (error, newReservation) => onDequeue(data, error, newReservation)
        );
    }
}

其中getContactUri()是...

this.getContactUri = function() {
    switch(self.agent.call_routing) {
        case 'workstation':
            return 'client:' + self.agent.worker_name;
        case 'business_phone':
            return '+1' + self.agent.business_phone;
        case 'other_phone':
            return '+1' + self.agent.other_phone;
        default:
            return null;
    }
}

因此,所有这些都工作得很好,但没有办法用这种方法添加监督员功能(显然)。我需要做的(显然)是将预订出队到会议室,然后单独将代理连接到会议室。
如果我能够为会议室创建一个contactUri,这将是很容易的。然而,似乎没有"conference_room:“形式的contactUri。
或者,我可以在服务器端先将入站呼叫路由到一个会议室,然后在会议室排队。
在任何情况下,我都需要任务队列作为解决方案的一部分,这样我就可以正确地将呼叫路由到各个代理。
我该怎么做呢?

rm5edbpk

rm5edbpk1#

要使会议出队,您需要使用REST API不是Twiml。在客户端中,使用REST API将成员资源出队到活动会议。根据您提供的代码,服务器将提供一种方法,用于使呼叫出队到会议。客户端将在决定接受呼叫后调用该方法。
Update a Member Resource

// Download the helper library from https://www.twilio.com/docs/node/install
// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);

client.queues('QUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
      .members('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
      .update({url: 'https://example.com'})
      .then(member => console.log(member.callSid));

上面例子中的url是返回会议Twiml的url。
A Simple Conference

const VoiceResponse = require('twilio').twiml.VoiceResponse;

const response = new VoiceResponse();
const dial = response.dial();
dial.conference('Room 1234');

console.log(response.toString());

简单会议产生的Twiml:

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

相关问题