Created
July 4, 2022 22:44
-
-
Save ambiorixg12/23a4de11f99f67da8bf65db25447b32d to your computer and use it in GitHub Desktop.
requesting a flow from a function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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