- Notifications
You must be signed in to change notification settings - Fork37
JS SDK v2 for Twilio's TaskRouter skills based routing system.
License
twilio/twilio-taskrouter.js
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
TaskRouter is Twilio's skills based routing system. With this library, you can manage your Workers in the browser or view the state of your Workspace.
This version of TaskRouter SDK can be used with Twilio Flex and TaskRouter standalone instances.
npm install twilio-taskrouter
The following is a simple example showing a Worker waiting for Reservations.For more information, refer to theAPI Docs.
constTaskRouter=require("twilio-taskrouter");constTwilio=require("twilio");constAccessToken=Twilio.jwt.AccessToken;constTaskRouterGrant=AccessToken.TaskRouterGrant;constaccountSid="";constsigningKeySid="";constsigningKeySecret="";constworkspaceSid="";constworkerSid="";consttoken=createAccessToken(accountSid,signingKeySid,signingKeySecret,workspaceSid,workerSid);constalice=newTaskRouter.Worker(token);alice.on("ready",(readyAlice)=>{console.log(`Worker${readyAlice.sid} is now ready for work`);});alice.on("reservationCreated",(reservation)=>{console.log(`Reservation${reservation.sid} has been created for${alice.sid}`);console.log(`Task attributes are:${reservation.task.attributes}`);reservation.on("accepted",(acceptedReservation)=>{console.log(`Reservation${acceptedReservation.sid} was accepted.`);});reservation.accept().then((acceptedReservation)=>{console.log(`Reservation status is${acceptedReservation.status}`);}).catch((err)=>{console.log(`Error:${err}`);});});functioncreateAccessToken(accountSid,signingKeySid,signingKeySecret,workspaceSid,workerSid){consttaskRouterGrant=newTaskRouterGrant({workerSid:workerSid,workspaceSid:workspaceSid,role:"worker",});constaccessToken=newAccessToken(accountSid,signingKeySid,signingKeySecret);accessToken.addGrant(taskRouterGrant);accessToken.identity="alice";returnaccessToken.toJwt();}
SeeCHANGELOG.md.
SeeLICENSE.md.
Fork and clone the repository. Use npm to install node 8 (other versions may run into problems).
Then, install dependencies with:
yarn install
Then run thebuild
script:
yarn build
The builds and docs will be placed in thedist/
directory.
Before commits, be sure to validate by running:
make lint
- Create a twilio account
- copy ./test/integration_test_setup/.env.example to ./test/integration_test_setup/.env
- set ACCOUNT_SID, AUTH_TOKEN, SIGNING_KEY_SID, SIGNING_KEY_SECRET
- Run ./test/integration_test_setup/RunIntegrationTestLocal.sh this will create everything needed for running E2E tests and run the tests
- SeeREADME.md
Bug fixes welcome! If you're not familiar with the GitHub pullrequest/contribution process,this is a nice tutorial.
About
JS SDK v2 for Twilio's TaskRouter skills based routing system.
Topics
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.