2

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;
    }
Nimantha
  • 6,405
  • 6
  • 28
  • 69
  • can you provide more data and some sample fulfillment code. Also provide the raw data from the history where the event fails. – Adi.P Aug 02 '20 at 04:37
  • Thank you for you response. I did try two methods: - Direct method – Bluepoint Developer Aug 03 '20 at 00:53
  • `code` 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'); } `code` – Bluepoint Developer Aug 03 '20 at 00:53
  • - Function method `code` 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'); } `code` – Bluepoint Developer Aug 03 '20 at 00:54
  • this is the function that try to send response to Dialogflow in the second method: `code` function sendAgentResponse(agent, message) { const promise = new Promise(resolve => { // logic goes here resolve(agent.add(message)); }); return promise; } `code` – Bluepoint Developer Aug 03 '20 at 00:55

0 Answers0