DEV Community

Discussion on: Creating a Whatsapp chatbot using Node JS, Dialogflow and Twilio

 
newtonmunene_yg profile image
Newton Munene • Edited

Hi,
From my understanding, what you're looking to achieve is something like this:

  1. User send message from whatsapp
  2. You get the message and send it over to dialogflow for intent matching and await a response
  3. Use dialogflow fulfilment webhook to do something in your server
  4. Send back a response for the fulfilment webhook
  5. Receive the response from Dialogflow (this is the response you're awaiting in step 2)
  6. Send the response back to whatsapp.

I have updated the repo to include a controller for Dialogflow webhook. github.com/newtonmunene99/wa-chatbot

When you receive the webhook from dialogflow, do whatever you need to do with the intent and parameters and then return the response to dialogflow. In BotController.ts, or wherever you execute the runQuery function, just await the result then send that to Whatsapp.

Thread Thread
 
kleiton profile image
Kleiton Moraes

Thank you so much @newton !
I'll look at it right now, have a great day my friend!