I am using TaskRouter Twilio with Laravel.
Here is what I am doing right now
-
I have attached a twiml app to a phone number.
-
Added a webhook to that twiml app.
-
On that webhook I am hitting this code
$response = new VoiceResponse();$taskAttributes = [ 'channel' => 'voice', // Specify that it's a voice call ]; $enqueue = $response->enqueue('WSDSupport',['workflowSid' => $workflowSid, 'action' => url('ivr/testQueue')]); $enqueue->task(json_encode($taskAttributes),['timeout' => 200]); return response($response)->header('Content-Type', 'text/xml');
-
Now on frontend I received the reservation created event (reservation.created)
-
I get a prompt to accept the reservation. When I do.
if (confirm('Incoming call. Accept?')) { reservation.accept(); } else { reservation.reject(); }
Worker is selected but nothing happens. On the Workflow callback URL I am running this code.
return response()->json([
"instruction"=> "dequeue",
"from"=> $taskAttributes['from'],
"post_work_activity_sid"=> config('services.twilio')['postWorkActivitySid']
]);
I need to connect my agent via a call to the customer. I have searched everwhere but did not find any help.
2
Answers
I figured it out
Just return this. This will look for the worker who has accepted the reservation and call that worker contact_uri, which is set in his/her profile on Twilio. It can be a phone number or browser client id.
The dequeue instruction requires four parameters. Your code sample is missing the "to" parameter:
Updated code: