I receive a post request to a gather.js serverless function which creates an outbound call via API.
The gather.js function prompts the receiver of the call to enter some digits using the .gather() method.
gather.js
exports.handler = function (context, event, callback) {
const response = new Twilio.twiml.VoiceResponse();
// initial greeting
response.say("Hello demo gathering starting now");
console.log(event);
const gather = response.gather({
timeout: 20,
method: "GET",
numDigits: 1,
});
gather.play(
{
loop: 1,
},
);
callback(null, response);
I have another function handoff-call.js which is used as the action in .gather() above.
The receiver of the call has two options.
Option 1
If the receiver is available to take an inbound phone call they press 1.
This triggers a .dial() method and connects them to another phone number. This is working as expected.
Option 2
If the receiver is unavailable to take an inbound phone call they press 2.
Here are the next steps I need to take:
Trigger another outbound call via API to the next number in an array and repeat the gather function
Is there a better/preferred way to handle this?
Thanks in advance,
James