twiml - Hunt Group for Twilio, using Twilio Functions. (aka FindMe ) -
i trying set hunt group twilio twiml
do have set different twimlbin each number in hunt group?
or there way join single twimlbin?
twimlbin 1: <response> <dial action="http://www.ourapp.com/webhook;failurl=/twimlbin 2" timeout="10" callerid="555-555-5555"> number1 </dial> </response> twimlbin 2: <response> <dial action="http://www.ourapp.com/webhook;failurl=/twimlbin 3" timeout="10" callerid="555-555-5555"> number2 </dial> </response> ... repeat n times each agent ...
thank :-)
twilio developer evangelist here.
twiml bins great static bits of twiml, use case needs bit more that.
i recommend check out twilio functions allow run node.js code in twilio's infrastructure. i've built , tested version of works twilio functions.
here's explanation of how works:
start array of numbers:
const numbers = [...];
then, in function, check if callstatus completed , hang if is.
exports.handler = function(context, event, callback) { const response = new twilio.twiml.voiceresponse(); if (event.dialcallstatus === "complete" || event.finished) { // call answered , completed or no 1 picked response.hangup(); } else {
if it's not, work out next number call. if have next number in url. if save variable, otherwise pick first number in array:
const numbertodial = event.nextnumber ? event.nextnumber : numbers[0];
then, assign next number dial array.
let url; const currentnumberindex = numbers.indexof(numbertodial); if (currentnumberindex + 1 === numbers.length) { // no more numbers call after this. url = "/hunt?finished=true"; } else { const nextnumber = numbers[currentnumberindex + 1]; url = "/hunt?nextnumber=" + encodeuricomponent(nextnumber); }
then generate twiml dial next number , pass url action. can add own url statuscallbackurl keep track of statuses.
const dial = response.dial({ action: url }); dial.number({ statuscallback: "https://yourapp.com/statuscallback" }, numbertodial); } callback(null, response); }
i can't promise work, hope see i'm going it. let me know if helps @ all.
Comments
Post a Comment