【发布时间】:2017-09-01 17:27:46
【问题描述】:
我构建了一个系统,可以进行浏览器到浏览器的调用。
当有来电时,使用接受,他们可以毫无问题地沟通! twilio 万岁。
所以现在我们有两个人 - 接听电话的人(我们称他们为接听者)和拨打电话的人(我们称他们为拨号器)
然后,接收器有一个按钮 l,称为 Place on Hold。单击此按钮时,它会将接收器重定向到循环消息您有一个呼叫保持,还将拨号器重定向到队列 - 他们会听到一些时髦的音乐。
如果再次点击,接收方拨入队列并获取呼叫方。这也很有效,他们可以再次交流。
但是.....如果我将拨号器放回队列中它可以工作,但是当我通过修改呼叫更新方法检索它并将其重定向到与呼叫未更新之前相同的部分时。
这不会引发错误。就好像 twilio 甚至没有尝试将调用重定向到 URL,因为日志什么也不返回。由于没有错误,我的应用认为一切正常。
发生这种情况有什么原因吗?有限制还是什么?
需要明确的是,这是第一次有效 - 完美。只是不是下一次,只是在检索呼叫时。
这是调用实例上的更新命令的问题。
我使用 Laravel 作为我的框架
这是我的 Routes.php
// Hold music and Client Message
Route::post('voice/queue/music', ['uses' => 'API\VoiceController@queueHoldMusic']);
Route::post('voice/queue/client-message', ['uses' => 'API\VoiceController@clientHoldMusic']);
// Routes containing Twiml XML
Route::post('voice/inbound/enqueue-call', ['uses' => 'API\Voice\InboundCallHoldController@placeInboundCallOnHold']);
Route::post('voice/inbound/dequeue-call', ['uses' => 'API\Voice\InboundCallHoldController@dialHeldInboundCall']);
// Place Outbound Call on Hold
Route::post('inbound/enqueue', ['uses' => 'API\Voice\InboundCallHoldController@holdInboundCall']);
Route::post('inbound/dequeue', ['uses' => 'API\Voice\InboundCallHoldController@getInboundCallOnHold']);
这是我的 InboundCallHoldController.php
class InboundCallHoldController extends Controller
{
public function placeInboundCallOnHold(Request $request){
$CallSid = $request['CallSid'] !== null ? $request['CallSid'] : null;
$response = new Twiml();
$queue = 'call-hold:'.$CallSid;
Log::info("---> Inbound Call | placeInboundCallOnHold --> Enqueuing Caller ".$CallSid." to ".$queue);
$response->enqueue($queue, ['waitUrl' => env("API_URL").'/api/voice/queue/music']);
return response($response)->header('Content-Type', 'text/xml');
}
public function dialHeldInboundCall(Request $request){
$callSid = $request['ParentCallSid'] !== null ? $request['ParentCallSid'] : null;
$response = new Twiml();
$dial = $response->dial();
$queueName = 'call-hold:'.$callSid;
Log::info("---> Inbound Call | dialHeldInboundCall --> Dialing a queue to get a caller ".$queueName);
$dial->queue($queueName);
$response->redirect(env('API_URL')."/api/voice/queue/client-message");
return response($response)->header('Content-Type', 'text/xml');
}
public function getInboundCallOnHold(Request $request){
$callSid = $request['CallSid'] !== null ? $request['CallSid'] : null;
$account = Account::where("twilio_sid", "TWILIO_ACCOUNT_SID")->first();
$client = new Client($account->twilio_sid, $account->twilio_auth_token);
Log::info("---> Inbound Call | getInboundCallOnHold --> Updating Live call and redirecting Caller ".$callSid . " to Queue");
$call = $client->calls($callSid)->fetch();
$client->calls($call->sid)->update([
"url" => env('API_URL')."/api/voice/inbound/dequeue-call",
"method" => "POST"
]);
Log::info("---> Inbound Call | getInboundCallOnHold --> ".$callSid . " status is now ".$call->status);
return response([
"status" => "fetched-inbound-call",
"success" => true
], 200);
}
public function holdInboundCall(Request $request){
$callSid = $request['CallSid'] !== null ? $request['CallSid'] : null;
$account = Account::where("twilio_sid", "TWILIO_ACCOUNT_SID")->first();
$client = new Client($account->twilio_sid, $account->twilio_auth_token);
Log::info("---> Inbound Call | Hold Initiated");
$call = $client->calls($callSid)->fetch();
$parentCall = $client->calls($call->parentCallSid)->fetch();
if($parentCall->status === "in-progress" and $call->status == "in-progress"){
// find the child - this is the receiver - Play the hold music
Log::info("---> Inbound Call | holdInboundCall --> Redirect Receiver ".$call->sid . " to wait message");
$call->update([
"url" => env('API_URL')."/api/voice/queue/client-message",
"method" => "POST"
]);
// find the parent - this is the inbound caller - Add them to a queue
Log::info("---> Inbound Call | holdInboundCall --> Redirect Inbound Caller ".$parentCall->sid . " to queue");
$parentCall->update([
"url" => env('API_URL')."/api/voice/inbound/enqueue-call",
"method" => "POST"
]);
return response([
"status" => "on-hold-inbound",
"success" => true
], 200);
}
return response()->json(["call_hold_failed" => ["A call not be placed on hold until it has been answered"]], 422);
}
}
这是第二次后没有更新的地方。
$client->calls($call->sid)->update([
"url" => env('API_URL')."/api/voice/inbound/dequeue-call",
"method" => "POST"
]);
这很奇怪,因为这是失败之前的过程;
- 保持通话 --> 成功
- 拨号队列并从队列中获取呼叫者 --> 成功
- 保持通话 --> 成功
- 拨号队列并从队列中获取呼叫者 --> FAIL
正如我所说,不会引发任何错误。
我正在使用调用以下 URL 的 Javascript 调用这些
// Place Outbound Call on Hold
Route::post('inbound/enqueue', ['uses' => 'API\Voice\InboundCallHoldController@holdInboundCall']);
Route::post('inbound/dequeue', ['uses' => 'API\Voice\InboundCallHoldController@getInboundCallOnHold']);
这是输出的日志;
[2017-09-04 13:42:47] local.INFO: ---> Inbound Call | Hold Initiated
[2017-09-04 13:42:47] local.INFO: ---> Inbound Call | holdInboundCall --> Redirect Receiver CA784af9a0419cde8dc3ab2379ad93e5b2 to wait message
[2017-09-04 13:42:48] local.INFO: ---> Inbound Call | holdInboundCall --> Redirect Inbound Caller CA3c31e8169647a7d90455058ce7bfa70f to queue
[2017-09-04 13:42:49] local.INFO: ---> Inbound Call | placeInboundCallOnHold --> Enqueuing Caller CA3c31e8169647a7d90455058ce7bfa70f to call-hold:CA3c31e8169647a7d90455058ce7bfa70f
[2017-09-04 13:43:09] local.INFO: ---> Inbound Call | getInboundCallOnHold --> Updating Live call and redirecting Caller CA784af9a0419cde8dc3ab2379ad93e5b2 to Queue
[2017-09-04 13:43:10] local.INFO: ---> Inbound Call | getInboundCallOnHold --> CA784af9a0419cde8dc3ab2379ad93e5b2 status is now in-progress
[2017-09-04 13:43:10] local.INFO: ---> Inbound Call | dialHeldInboundCall --> Dialing a queue to get a caller call-hold:CA3c31e8169647a7d90455058ce7bfa70f
[2017-09-04 13:43:10] local.INFO: ---> Inbound Call | dialHeldInboundCall --> Call Sid is CA3c31e8169647a7d90455058ce7bfa70f
[2017-09-04 13:43:36] local.INFO: ---> Inbound Call | Hold Initiated
[2017-09-04 13:43:37] local.INFO: ---> Inbound Call | holdInboundCall --> Redirect Receiver CA784af9a0419cde8dc3ab2379ad93e5b2 to wait message
[2017-09-04 13:43:43] local.INFO: ---> Inbound Call | holdInboundCall --> Redirect Inbound Caller CA3c31e8169647a7d90455058ce7bfa70f to queue
[2017-09-04 13:43:44] local.INFO: ---> Inbound Call | placeInboundCallOnHold --> Enqueuing Caller CA3c31e8169647a7d90455058ce7bfa70f to call-hold:CA3c31e8169647a7d90455058ce7bfa70f
[2017-09-04 13:44:06] local.INFO: ---> Inbound Call | getInboundCallOnHold --> Updating Live call and redirecting Caller CA784af9a0419cde8dc3ab2379ad93e5b2 to Queue
[2017-09-04 13:44:07] local.INFO: ---> Inbound Call | getInboundCallOnHold --> CA784af9a0419cde8dc3ab2379ad93e5b2 status is now in-progress
【问题讨论】:
-
您检查客户端日志了吗? twilio 有任何已知的错误吗?如果没有代码,我认为我们无法解决最可能出现的问题。
-
调试器中没有内部错误。这就像一个鬼!它说执行更新命令(我认为它不会抛出任何错误)但实际上并没有重定向调用。
-
我回到办公桌后会发布一些代码
-
很高兴听到您要添加一些代码,我也打算这样做。很高兴在您将其添加到问题时提供帮助:)
-
嘿@philnash 我已经添加了一些代码,非常感谢一些帮助:)