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

The most important tip for building Dialogflow webhooks

Website Name Change

I have changed the name of this website from Mining Business Data to BotFlo. I am offering a 60% off discount on both my Dialogflow ES and Dialogflow CX courses till April 20th 2021 for people who can help me spread the word about my new website.

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.


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

Similar Posts