All checks were successful
Build and push Doorman UI / API / docker (push) Successful in 1m27s
23 lines
668 B
JavaScript
23 lines
668 B
JavaScript
/**
|
|
* Fallback behavior, if the code is wrong or unspecified, then we should dial the fallback numbers
|
|
*/
|
|
exports.handler = function(context, event, callback) {
|
|
let twiml = new Twilio.twiml.VoiceResponse();
|
|
|
|
let config = JSON.parse(event.config);
|
|
console.log(config);
|
|
let configQuery = `config=${encodeURIComponent(JSON.stringify(config))}`;
|
|
|
|
// If no valid answer after timeout, dial all residents until someone picks up
|
|
let dial = twiml.dial({
|
|
action: `/text-me?Method=call&${configQuery}`,
|
|
timeLimit: 20,
|
|
timeout: 20
|
|
});
|
|
|
|
config.fallbackNumbers.forEach(number => {
|
|
dial.number(number);
|
|
});
|
|
|
|
return callback(null, twiml);
|
|
} |