我正在使用 twiml 创建一个呼叫排队系统,一切正常,就像我可以接听电话和排队呼叫,但我无法从队列中接听电话,我写了这段代码,但它不工作当有来电时,这是我的 twiml:我接到第一个电话,其他后续电话排队,但现在第一个电话结束后,我无法选择排队的电话。当我挂断电话时,它会将第一个呼叫者排在队列中。header("Content-type: text/xml");$name = $_POST['name'];$email = $_POST['email'];$message = '<?xml version="1.0" encoding="UTF-8"?><Response> <Say>Please wait and one of our agents will be with you shortly.</Say> <Dial> <Client>joey</Client> <Parameter name="name" value="'.$name.'" /> <Parameter name="email" value="'.$email.'" /> </Dial> <Say>Our agents are still busy please hold.</Say> <Enqueue waitUrl="waiting.php">Support</Enqueue></Response>';echo $message;因此,要从队列中接听电话,我发现了这个 Twilio PHP 代码:use Twilio\TwiML\VoiceResponse;$support = $_REQUEST['To'];$response = new VoiceResponse();$response->say("You will now be connected to the first caller in the queue.");$dial = $response->dial('');$dial->queue($support, ['url' => 'about_to_connect.php']);echo $response;使用此 JavaSCript 代码 queueButton.click(function() { Twilio.Device.connect({ To: 'Support' }); });在这里,我想按照这个答案Twilio 将代理连接到队列中的呼叫但是当我单击一个按钮来接听电话时,什么也没有发生,而是我收到了这个 js 错误twilio.js:7100 Received an error from the gateway: {code: 31002, connection: Connection, message: "Connection Declined", twilioError: Errorcode: 31005description: "Connection error"explanation: "A connection error occurred during the call"总而言之,我只需要一个关于如何将代理连接到队列的解决方案,例如查看队列中有多少呼叫并能够从队列中选择它们
1 回答

凤凰求蛊
TA贡献1825条经验 获得超4个赞
我想到了。
所以要调用队列,我需要第二个号码,我可以用它来调用队列,但我没有第二个号码,所以因为我有 twiml Gather 的 input.php 文件,我做了一个 if 语句检查是否用户呼叫是代理或只是客户,如果是代理我拨打队列
if($_POST['user_type'] == 'agent'){
<Response>
<Dial>
<Queue url="about_to_connect.xml">my_queue_name</Queue>
</Dial>
</Response>
}else{
//My Gather here
}
为了能够检查用户是代理还是客户,当我调用队列时,我传递了一个名为 user_type 的自定义变量:
let connection = Twilio.Device.connect({
"user_type": "agent"
});
所以我可以打电话给我的队列。那时我意识到 twiml 很棒,它的工作是控制调用。
我建议您购买第二个号码以避免减慢您的通话速度。
添加回答
举报
0/150
提交
取消