Advertisement
Guest User

Untitled

a guest
Sep 17th, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. exports.handler = function(context, event, callback) {
  2.   // List all blocked phone numbers in quotes and E.164 formatting, separated by a comma
  3.   let numberBlock = event.block || [ "+xxxxxxx", "+xxxxxxx" ];
  4.   let twiml = new Twilio.twiml.VoiceResponse();
  5.   let blocked = true;
  6.   if (numberBlock.length > 0) {
  7.     if (numberBlock.indexOf(event.From) === -1) {
  8.       blocked = false;
  9.     }
  10.   }
  11.   if (blocked) {
  12.     twiml.reject();
  13.     callback(null, twiml);
  14.   }
  15.   else {
  16.      const response = new Twilio.Response();
  17.      // Set the status code to 200
  18.      response.setStatusCode(200);
  19.      return callback(null, response);
  20.   }
  21. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement