I am using task Router with twilio. I have added three Workers (Users) e.g USER_A,USER_B and USER_C. Each user has attributes which has name and company. USER_A and USER_B belongs to same company lets say Company_A and USER_C belongs to other company lets say COMPANY_C.
I have added code for my voice callback url here as in //example.com/routing.php :
<?php
header('Content-Type: application/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
?>
<Response>
<Gather action="enqueue-call.php" numDigits="1" timeout="10">
<Say>Press One for Company A</Say>
<Say>Press Two For Company C</Say>
</Gather>
</Response>
And here is my enqueue-call.php :
<?php
$digit_pressed = $_REQUEST['Digits'];
if ($digit_pressed == '1') {
$company = "company_a";
} else {
$company = "company_c";
}
header('Content-Type: application/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
<Enqueue workflowSid="xxxxxxxxxxxxxxxxxxxxx">
<Task>{"selected_company": "<?php echo $company ?>"}</Task>
</Enqueue>
</Response>
Everything here is completely working.
The requirement in my case is i want to call the selected worker on browser not on worker's mobile. According to this tutorial : https://www.twilio.com/docs/quickstart/php/taskrouter/twiml-dequeue-call They are calling the worker's mobile number.
I have added the agent screen to my each worker as well by following this tutorial : https://www.twilio.com/docs/quickstart/php/taskrouter/agent-ui-add-project I have added this code in my agent.php file.
So the requirement is to transfer the incoming call for selected worker on my agent.php
This is my Assigment Callback URL exapmle.com/assignment.php :
<?php
$assignment_instruction = [
'instruction' => 'dequeue',
'post_work_activity_sid' => '{WA0123401234...}',
'from' => '+15556667777' // a verified phone number from your twilio account
];
header('Content-Type: application/json');
echo json_encode($assignment_instruction);
What should be code for me to add here to call the selected worker which is available ?