Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.handler = function(context, event, callback) {
- const workspace = context.TWILIO_WORKSPACE_SID;
- const workflowSid = 'WW';
- let client = context.getTwilioClient();
- let twiml = new Twilio.twiml.VoiceResponse();
- console.log(event);
- client
- .taskrouter.workspaces(workspace)
- .tasks
- .create(
- {
- attributes: JSON.stringify(
- event),
- workflowSid: workflowSid,
- taskChannel: 'custom1'
- })
- .then(task => {
- twiml.say("Your message has been received. An agent will call you back soon.");
- twiml.hangup();
- callback(null, twiml.toString());
- })
- .catch((error) => {
- console.log("error");
- console.log(error);
- callback(error)
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement