I would like to setup twilio to call person A if person A doesn't answer I want to call person B and so on.
From my understanding twilio will request the URL provided once the call is answered, either by machine or human (provided machine detection is enabled).
Currently I have it setup so that if an answering machine is detected it serves TWIML XML to hangup and if a person answers it serves the TWIML XML message. but I can't find a way in which to call the next person on the list.
`
client.calls.create({
to: "+1" + numbers[i],
from: process.env.TWILIO_NUMBER,
url: "https://publically.accessable/url-of_mine",
machineDetection: "Enabled",
method: "GET"
})
.catch((err) => {
console.log(err)
})
here is the function inside my publicly available URL
const params = event.queryStringParameters;
if (params.AnsweredBy == "machine_start") {
let xml = `
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Hangup/>
</Response>`
return Response(xml, mimetype = 'text/xml')
} else{
let xml = `
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="alice" loop='3'>Wildfire Alert. """ + memberCount + """ PURE members are within 15 miles of """ + fireName + """ fire. Please refer to Incident Monitor for further information.</Say>
</Response>`
return Response(xml, mimetype='text/xml')
}
`