我正在构建一个呼叫中心功能,该功能将在接收入站呼叫时拨出座席电话号码列表(由另一段代码确定),并在第一个电话号码连接上断开编写代码并运行一个单独的功能,以将代理连接到客户正在等待的队列中。这是在Laravel 5.7中构建的,因为将来还会创建其他一些仪表板,我想将其放置在团队要使用的代码中。
最初的客户排队并将座席连接到呼叫似乎正常。
我正在寻找以下代码的帮助:
public function findAgentByPriority($agentCount) {
$twilio = new Client(env('TWILIO_SID'),env('TWILIO_SECRET'));
// test numbers
$agentArr[] = ["agent" => env('TWILIO_TEST_AGENT1')];
$agentArr[] = ["agent" => env('TWILIO_TEST_AGENT2')];
// $agentArr = json_encode($agentArr);
//build the array by querying /api/v1/agile/users
$numbers = $agentArr;
// this part of the code will call one person after the next
// call the next number
if($agentCount == NULL){
$agentCount = count($numbers);
echo "in if<br>";
$call = $twilio->calls
->create(
$numbers[0],
env('TWILIO_MAIN_NUMBER'),
[
"url" => "https://{$_SERVER['HTTP_HOST']}/ivr/connect-agent",
"statusCallback" => "https://{$_SERVER['HTTP_HOST']}/ivr/next-agent?c=$agentCount",
"timeout" => 20
]
);
}elseif($agentCount > 0){
// when we run out of numbers move out of the loop
$agentCount = 0;
}else{
// when we run out of numbers move out of the loop
}
// once there are no more agents that were logged in today we
// will move to dial cell phone fallback for 40s
// and last we'll call on the voicemail function
}
这是connect-agent路由正在调用的connectAgent函数。
public function connectAgent() {
$response = new Twiml\VoiceResponse;
$dequeue = $response->dial('');
$dequeue->queue('main');
}
当我读到存在“ no-answer”并拨打下一个电话号码时,我本以为基本上是将“ statusCallback”拍摄为一种新方法。我不知道如何通过回调传递变量来跟踪剩下的数字。将其设置为数据库会更好,是否会进行类似的操作以查找仍存在记录的任何剩余arrayID,然后拨下一个?我可以在第一个函数调用时在数据库中建立数组及其参数。
我可以避免两个人一次打电话并弄乱代码的问题,只需建立不同的arrayID并一次只处理一组即可。
任何指导表示赞赏!
更新 PHP的服务器导致了无限循环。将测试移至无所事事的盒子已解决了这一问题,因此现在我可以从同一台服务器调用Laravel路由,而不会出现问题。这与通过回调传递数组的答案一起帮助我解决了这个问题。更新了代码以供参考。
以下问题帮助我找出第二个请求卡住的问题:Calling route from same server causes an infinite loop
答案 0 :(得分:3)
这里是Twilio开发人员的传播者。
您可以做的是将当前数字作为查询参数添加到statusCallback
URL中。这样,在调用回调时,您可以在号码列表中找到该号码,然后转到下一个号码。这样,您无需在数据库中存储任何内容。
让我知道是否有帮助。