Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
Twilio Task Router

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 ?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Twilio developer evangelist here.

If you are doing a dequeue and it calls the worker's mobile number, then you must have set up the worker's contact_uri as the number.

To get it to call the worker in their browser from a dequeue action you need to set that contact_uri to their client name, like this client:USER_A.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!