skip to Main Content

I am using TaskRouter Twilio with Laravel.

Here is what I am doing right now

  1. I have attached a twiml app to a phone number.

  2. Added a webhook to that twiml app.

  3. 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');
    
  4. Now on frontend I received the reservation created event (reservation.created)

  5. 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


  1. Chosen as BEST ANSWER

    I figured it out

    return response()->json([
                "instruction"=> "dequeue"
            ]);
    

    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.


  2. The dequeue instruction requires four parameters. Your code sample is missing the "to" parameter:

    {
      "instruction": "dequeue",
      "to": "{the Worker's phone number, sip uri, or client uri. Required.}"
      "from": "{the caller ID that you want to send to the Worker. Required.}"
      "post_work_activity_sid": "{the ActivitySid that should be assigned to the Worker after the call ends. Optional.}"
    }
    

    More about these fields:

    instruction specifies the assignment activity to perform. Use
    ‘dequeue’ to dequeue a call to a Worker. For a full list of assignment
    instructions, read about handling assignment callbacks here.

    to specifies the Worker recipient’s phone number.

    from specifies the caller ID that should be sent when extending the call to the Worker.

    post_work_activity_sid specifies the ActivitySid that you want to
    assign to the Worker after the call completes. Use this to transition
    your worker to a status that makes sense for their after-call, work
    for example "Wrapping up".

    Updated code:

    return response()->json([
                     "instruction"=> "dequeue",
                     "from"=> $taskAttributes['from'],
                     "to"=> $workersPhoneNumberInE164,
                     "post_work_activity_sid"=> config('services.twilio')['postWorkActivitySid']
                 ]);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search