0

As per this documentation, I have done all the things and got the final URL as mentioned below:

https://dialogflow-twilio-4syckuoz4a-uc.a.run.app

set this URL in the messaging webhook as HTTP POST method. When I checked this URL in the browser and no output received, it shows as "Cannot GET /".

Disabled the SSL validation in Twilio settings. Checked with http and https but both are not working. Received Error 11200 in twilio debugger. What I missed out. Please help me out.

this is the server.js script as per the documentation

const express = require('express');   
const request = require('request');   
const app = express();   

const dialogflowSessionClient =
    require('../botlib/dialogflow_session_client.js');
const bodyParser = require('body-parser');

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));


const projectId = 'xxxxxxxxxx';
const phoneNumber = "xxxxxxxxxx";
const accountSid = 'xxxxxxxxxx';
const authToken = 'xxxxxxxxxxxxxxx';

const client = require('twilio')(accountSid, authToken);
const MessagingResponse = require('twilio').twiml.MessagingResponse;
const sessionClient = new dialogflowSessionClient(projectId);

const listener = app.listen(process.env.PORT, function() {
  console.log('Your Twilio integration server is listening on port '
      + listener.address().port);
});

app.post('/', async function(req, res) {
  const body = req.body;
  const text = body.Body;
  const id = body.From;
  const dialogflowResponse = (await sessionClient.detectIntent(
      text, id, body)).fulfillmentText;
  const twiml = new  MessagingResponse();
  const message = twiml.message(dialogflowResponse);
  res.send(twiml.toString());
});

process.on('SIGTERM', () => {
  listener.close(() => {
    console.log('Closing http server.');
    process.exit(0);
  });
});
Arun
  • 728
  • 4
  • 16
  • 30
  • Hi @Shenbagavalli, since it is a POST method I think you cannot do a GET request to that URL. Have you tried using the [Twilio Sandbox for WhatsApp](https://www.twilio.com/docs/whatsapp/sandbox)?. In order to corroborate that you have not skipped a step, [this](https://www.youtube.com/watch?v=3KSitm7X6rA) video could be helpful. – Mariana Angeles Nov 19 '20 at 05:14
  • @MarianaAngeles Yes, already I setup the Twilio sandbox for whatsapp. As per the video I have done everything but same error received. – Arun Nov 19 '20 at 05:38
  • Based on [Twilio Docs](https://www.twilio.com/docs/api/errors/11200) it seems that it could be an issue between Dialogflow and Twilio connection or the agent is taking too long to return. Based on that, could you please gather the following information: 1. A screenshot of the complete error message 2. Did you modify the [Dockerfile](https://github.com/GoogleCloudPlatform/dialogflow-integrations/blob/03676af04840c21c12e2590393d5542602591bee/Dockerfile#L9) setting the integration variable to “twilio”? 3. Did you copy your Service Account JSON key file to the desired platform subdirectory? – Mariana Angeles Nov 23 '20 at 22:55
  • 4. When executing the [deployment to live](https://github.com/GoogleCloudPlatform/dialogflow-integrations/tree/master/twilio#deploying-the-integration-using-cloud-run), did you replace the “YOUR_KEY_FILE” with the name (not path) of your Service Account JSON key file?. Please don’t forget to add the JSON extension (example: test_key.json) 5. Have you tested the agent from the [Dialogflow simulator](https://cloud.google.com/dialogflow/es/docs/console#simulator)?, in order to discard some issue within the agent. – Mariana Angeles Nov 23 '20 at 22:56
  • @MarianaAngeles Thanks for your response. I have edited the question, please review it – Arun Nov 27 '20 at 10:13
  • @Aruna It isn't clear but it looks like your edit was an answer? If so, pls post it as an answer. If it is a request for more info, pls add it as a comment. – Don't Panic Nov 27 '20 at 10:37

1 Answers1

0

It resolved now. Just I deleted everything and followed again as per the documentation.

Arun
  • 728
  • 4
  • 16
  • 30