40 lines
982 B
TypeScript
40 lines
982 B
TypeScript
import VoiceResponse from 'twilio/lib/twiml/VoiceResponse';
|
|
import { InfoResponseClient } from '../../../doorman-api/src/functions/api/door/info';
|
|
|
|
export function doorOpenTwiml(config: InfoResponseClient): VoiceResponse {
|
|
const twiml = new Twilio.twiml.VoiceResponse();
|
|
|
|
// pause for some time
|
|
twiml.pause({ length: 1 });
|
|
|
|
// press digit
|
|
twiml.play({ digits: config.pressKey }); // configured in doorman what button to click and passed into this function
|
|
|
|
// play audio
|
|
twiml.play('https://buzzer-2439-prod.twil.io/buzzing_up_boosted.mp3');
|
|
|
|
// pause again
|
|
twiml.pause({ length: 1 });
|
|
|
|
// exit
|
|
twiml.hangup();
|
|
// @ts-ignore
|
|
return twiml;
|
|
}
|
|
|
|
export function dialFallbackTwiml(config: InfoResponseClient): VoiceResponse {
|
|
const twiml = new Twilio.twiml.VoiceResponse();
|
|
|
|
let dial = twiml.dial({
|
|
timeLimit: 20,
|
|
timeout: 20
|
|
});
|
|
|
|
config.fallbackNumbers.forEach(number => {
|
|
dial.number(number);
|
|
});
|
|
|
|
// @ts-ignore
|
|
return twiml;
|
|
}
|