I am trying to develop a virtual block list in Twilio. I was directed to their reject documentation. I set it up as a function in the function area. I'm trying to figure out how to incorporate it into my Studio - Flow. So I have Trigger > VirtualBlockList (Run function) > then inbound call process. I have the number set to A call comes in: Studio > Flow. Not sure how to do the config in the flow:I am completely new to Twilio, i'm just trying to help out our dev team because they are swamped. Any assistance would be helpful! Also, I removed our account SID and flow SID for security so I have the placeholder in there.
exports.handler = function(context, event, callback) {
// List all blocked phone numbers in quotes and E.164 formatting, separated by a comma
let numberBlock = event.block || [ "+11234567896"" ];
let twiml = new Twilio.twiml.VoiceResponse();
let blocked = true;
if (numberBlock.length > 0) {
if (numberBlock.indexOf(event.From) === -1) {
blocked = false;
}
}
if (blocked) {
twiml.reject();
}
else {
// if the caller's number is not blocked, redirect to your existing webhook
twiml.redirect("https://webhooks.twilio.com/v1/Accounts/<account_sid>/Flows/<flow_sid>");
}
callback(null, twiml);
};