I am trying to achieve a functionality to send users(who are waiting in the queue after chat is initiated with a customer care) what number are they in the queue. I am calling an endpoint which gives me a number in the queue of the particular task.
For example, my queue number starts with 10 and gradually reduce to 0.
Furthermore, I want to create a loop/async function that makes the Post(I will change it to get once the functionality is working) request until the queue number is 0.
The functionality I am trying to achieve is in a Twilio function. Below is the code I am working on, right now it only makes the post request ones, but I want to keep updating users about their queue until an agent answers them.
exports.handler = async function(context, event, callback) {
var parameters = {"queueSid" : event.queueSid, "taskSid" : event.taskSid};
const apiPath = 'https://myEndPoint';
const response = await axios.post(apiPath, parameters );
console.log('Response', response.data)
callback(null,response)
};