In our backend, we are placing a call to multiple clients and everything works as intended, when the call completes the webhook is sent to our statusCallback URL as intended. From there, we are doing more work on the call and responding with Twiml with the intent to keep the call alive if nobody answers and play a message/etc. The endpoint is returning Twiml as intended but the call is dropping regardless. Not sure whats going on but any insight is appreciated.
Here is the part of the code to place the call to the client, it works as intended and the statusCallback is called after the call is ‘completed.’:
await dial.client(
{
statusCallbackEvent: "completed",
statusCallback: `handleFinishedCall?customerId=${customerId}&widgetId=${
nextWidget ? nextWidget : ""
}&caller=${caller}`,
statusCallbackMethod: "POST",
},
idToCall
);
And here is the endpoint that receives the callback:
router.post("/handleFinishedCall", async (req, res) => {
var twimlObject = new VoiceResponse();
twimlObject.say('some message');
res.type("text/xml");
res.send(twimlObject.toString());
res.status(200).send();
});
Once the callback URL finishes here is the response being sent back
<?xml version="1.0" encoding="UTF-8"?><Response><Say>some message</Say></Response>
I cant quite figure out why the call just ends rather than proceeding with the Twiml being returned.