I have a Dialogflow agent integrated with Twillio. Before the integration model change, all agent responses came smoothly. Since I changed the integration method following the instructions published by Dialogflow, the agent's responses fail intermittently generating the message 14103-Invalid Body in Twilio:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Message/>
</Response>
The agent's response comes to Twilio in some cases but not in others. I observe this behavior repeating the same intent several times in the agent.
The fullfillment webhook was developed in NodeJs and is deployed in a different Google Cloud project than the Agent.
I did try two methods:
- Direct method
if (estCuenta.msg == 'OK') {
console.log('trace 1');
await validaDisclaimer(`${cedula}`);
if (!disclaimerOk) {
console.log('trace 2');
agent.context.set({ 'name': 'esperadisclaimer-followup', 'lifespan': 1 });
agent.add('Some message')
sendWhatsAppMedia('https://someFile.pdf?alt=media&token=18ebc493-27fc-4c46-96eb-e80f05716acc',
'someFileDescription');
}
- Function method
if (estCuenta.msg == 'OK') {
console.log('trace 1');
await validaDisclaimer(`${cedula}`);
if (!disclaimerOk) {
console.log('trace 2');
agent.context.set({ 'name': 'esperadisclaimer-followup', 'lifespan': 1 });
await sendAgentResponse(agent, 'Some message')
sendWhatsAppMedia('https://someFile.pdf?alt=media&token=18ebc493-27fc-4c46-96eb-e80f05716acc',
'someFileDescription');
}
... the funtion that try to send response to Dialogflow agent
function sendAgentResponse(agent, message) {
const promise = new Promise(resolve => {
// logic goes here
resolve(agent.add(message));
});
return promise;
}