Yuriy P.
Yuriy P.

Reputation: 131

How to get a callback when the agent is connected to the customer waiting the queue?

I have a simple setup where there's 1 queue and a few agents that are managed on my side with the help of PHP.

When the customer calls, the call gets enqueued like so:

$response = new VoiceResponse();
$response->enqueue('support', ['waitUrl' => 'wait-music.xml','action' => 'queue-action.php']);
$call = $client->account->calls->create($agent_number, $queue_number, [
    "url" => 'queue.php',
]); 

echo $response;

queue-action.php, in this case, is only called when the call is ended as it should do. Also, I start a call to an agent to connect him to the queue.

queue-action.php contents:

$response = new VoiceResponse();
$dial = $response->dial('',[
        'action' => 'dial-callback.php',
    ]);
$dial->queue('support');

dial-callback.php here is also triggered after the call is ended.

My goal is to receive a callback when the calls are connected together, so I can mark a certain call as in-progress and assign an agent to it, to later know that this agent is busy on the line.

It feels like I would need to use statusCallbackEvent and statusCallback properties on $dial, but it's only available for <Dial><Number>, <Dial><Sip> and <Dial><Client>.

In other words, I want to record all queued calls in DB and updated their statuses accordingly (initiated / ringing / answered / completed) based on call status updates and assign relations with agents.

Would it be possible to accomplish it somehow using callbacks, without using TaskRouter?

Thank you

Upvotes: 0

Views: 181

Answers (1)

Yuriy P.
Yuriy P.

Reputation: 131

I got it working now, don't know how I missed it in the docs but the key is to use

$dial->queue('support', ['url' => 'queue-connect.php']);

the url parameter on Queue just in case someone will read this in the future.

Upvotes: 1

Related Questions