Skip to content

Instantly share code, notes, and snippets.

@ambiorixg12
Created July 4, 2022 22:44
Show Gist options
  • Save ambiorixg12/23a4de11f99f67da8bf65db25447b32d to your computer and use it in GitHub Desktop.
Save ambiorixg12/23a4de11f99f67da8bf65db25447b32d to your computer and use it in GitHub Desktop.
requesting a flow from a function
exports.handler = function(context, event, callback) {
var to_num =event.From;
var did =event.To;
// Here's an example of setting up some TWiML to respond to with this function
const TwilioClient = context.getTwilioClient();
TwilioClient.studio.v1.flows('FWac0dsssssss4')
.executions
.create({to: 'did', from: 'to_num',parameters: {
phone: to_num
}})
.then((execution) => {
console.log('SMS successfully sent');
console.log(execution.sid);
return callback(null, `Success! Flow SID: ${execution.sid}`);
})
.catch((error) => {
console.error(error);
return callback(error);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment