I've made an IVR using Twilio Studio. In my API I have something like this
await validateForm(form);
await twilioIvrService(phone);
await saveData(form);
return res.json({message "Ok"})
Is there a way to wait for the twilioIvrService
response? I mean, at the end of the IVR flow (on Twilio Studio) it should return a value
(Boolean
) depending on the user's choice, and saveData
should store the form on a DB only if value
is true
. I want to get that value
before calling saveData
. The form
parameter is almost 5KB.
This is how I run the Twilio flow using REST API Trigger
const twilioIvrService = async (phone) => {
try {
const { data } = await axios.post(
url,
new URLSearchParams({
To: phone,
From: TWILIO_PHONE,
}),
{
auth: {
username: twilioAccountSid,
password: twilioAuthToken,
},
},
);
console.log(data);
} catch (error) {
console.log(error);
}
};