Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. exports.handler = function(context, event, callback) {
  2.  
  3. const workspace = context.TWILIO_WORKSPACE_SID;
  4. const workflowSid = 'WW';
  5.  
  6. let client = context.getTwilioClient();
  7.  
  8. let twiml = new Twilio.twiml.VoiceResponse();
  9.  
  10. console.log(event);
  11.  
  12. client
  13. .taskrouter.workspaces(workspace)
  14. .tasks
  15. .create(
  16. {
  17. attributes: JSON.stringify(
  18. event),
  19. workflowSid: workflowSid,
  20. taskChannel: 'custom1'
  21.  
  22. })
  23. .then(task => {
  24. twiml.say("Your message has been received. An agent will call you back soon.");
  25. twiml.hangup();
  26. callback(null, twiml.toString());
  27. })
  28. .catch((error) => {
  29. console.log("error");
  30. console.log(error);
  31. callback(error)
  32. });
  33. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement