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
- Dialogflow Knowledge Connector : Pros and Cons
- How to integrate Telegram with Dialogflow
- Why I avoid using slot filling (required parameters) in Dialogflow
- Free Tool: Convert your WordPress website into a Dialogflow FAQ chatbot
- Dialogflow Mega Agent Tutorial
- Reader Question: Will followup events work when an intent has an input context?
- How to learn Dialogflow in a week
- Reader Question: Do I need a contextual fallback intent for every single context?
- Reader Question: Can I use a single agent for Facebook, WhatsApp and website bot?
- Five ways to integrate a Dialogflow chatbot into your website