Home / DialogFlow ES / The most important tip for building Dialogflow webhooks
Debugging | DialogFlow ES | Webhooks

The most important tip for building Dialogflow webhooks

Yeah, I cannot help exaggerating sometimes. 🙂

But this one is not much of an exaggeration.

Why webhook development is a big pain in the backside

Not just Dialogflow webhooks, but the way webhooks work in general, you might believe that the best way to debug these webhooks is to sprinkle your code with very insightful print statements.

While insightful print statements do have a role, there is a better way.

ngrok

Here is the definition of nGrok:

Ngrok is a multiplatform tunnelling, reverse proxy software that establishes secure tunnels from a public endpoint such as internet to a locally running network service while capturing all traffic for detailed inspection and replay.

OK, that may sound quite complicated. But here is what it means for you:

1 Install ngrok and follow setup instructions

2 Go to your webhook URL in Dialogflow

3 Replace it with a URL which will be generated by your nGrok installation

4 Make sure you configure your IDE to use the correct port

What happens when you use ngrok

1 User types a message to your Dialogflow agent

2 Dialogflow decides that it needs to call a webhook based on your setting

3 It looks up the webhook URL and finds the nGrok generated URL

4 Dialogflow sends the JSON post request to the nGrok generated URL

5 Some ngrok magic happens behind the scenes

6 The JSON post request is sent to your local development machine

7 If you configured everything properly in your IDE, you can set a breakpoint in your webhook code and that breakpoint should be hit by the incoming JSON post request

8 Now you can patiently step through the code and see if something is broken


This website contains affiliate links. See the disclosure page for more details. 
"The magic key I needed as a non-programmer"

The custom payload generator was the magic key I needed (as a non-programmer) to build a good demo with rich responses in DialogFlow Messenger. I've only used it for 30 minutes and am thrilled. I've spent hours trying to figure out some of the intricacies of DialogFlow on my own. Over and over, I kept coming back to Aravind's tutorials available on-line. I trust the other functionalities I learn to use in the app will save me additional time and heartburn.

- Kathleen R
Cofounder, gathrHealth
In this free course, I provide some tips for managing large Dialogflow ES bots without compromising on accuracy.

Similar Posts