How to create a TaskRouter Worker capability token in apex class

232 views Asked by At

How to create a TaskRouter Worker capability token in apex class.

I have created a taskrouter on twilio and need to update my worker activity from break to wait for that I need a taskRouter compatibility token through which I can proceed further. In my Apex class page I am unable to get taskRouter compatibility token.

Attaching snapshots for my apex class page and my visualforce page. enter image description here

enter image description here

1

There are 1 answers

0
Andrés Andrade On

You are creating a Twilio Capability Token which is used to sign communications from devices to Twilio. What you need is Task Router Capability Token to use the TaskRouter's JavaScript SDK:

public class TwilioClientController {
        TwilioTRCapability capability;

        public TwilioClientController() {
                string workspaceSid = 'WS%$#%#$^$#^$#^$#^$#^#$$#^#$^#';
                string workerSid = 'WK^$#^$#^#^#$^$#^#$^$#^$#%$#';

                capability = TwilioAPI.createTRCapability(workspaceSid, workerSid);

                // Set policies
                capability.allowWorkerActivityUpdates();
        }

        public String getToken() { return capability.generateToken(); }
}