DialogFlow | Python | Webhooks

How to debug Dialogflow Python webhook using ngrok

In this tutorial I will explain how you can debug your Python Flask webhook for your Dialogflow bot using ngrok. I use the PyCharm professional IDE (you can also download the free PyCharm community edition) in this tutorial. 1 Create a new Pure Python project You can just start with a regular old Python project. No need to do anything more fancy. 2 Install flask inside the virtual environment Open the Terminal inside your PyCharm IDE. Use pip install Flask to install the Flask web framework inside your virtual environment. 3 Add a new Python file and call it app.py Create a new Python file called app.py. Your project structure should look like below. Add the following code into your…

DialogFlow | Python | Webhooks

Dialogflow Python webhook tutorial

One of the things that I have mentioned before is that you need to have a programmer on your team if you would like to build a non-trivial Dialogflow bot. At the same time, all Dialogflow bot makers would still benefit from understanding the basics of webhooks. This tutorial will be helpful if you are technical, but not a programmer. I will explain just enough about Dialogflow webhooks to make you dangerous. 🙂 If you are a programmer, this guide will still be helpful if you are new to Dialogflow. Hello World Let us start with a simple Hello World program. First, sign up for a free account at Repl.it. You can use your Google account to sign in. Create…

DialogFlow | NodeJS | Webhooks

Deploy NodeJS Webhook to Google Cloud

This tutorial was a series of posts which was first published in October 2017. There have been many updates in Google Cloud after this tutorial was first created, so it may not be the best learning resource for this topic. A couple of things to note: almost certainly, the interface will look different today and the screenshots may not be up to date whenever I ask you to click on a certain link, it is understood that you are already logged in to your Google account (that is, many of these links take you directly to specific feature pages inside the Google Cloud Console) If you would like me to update this tutorial, please leave a comment below. If I…

DialogFlow | Webhooks

How to send carousel to Viber from Dialogflow webhook

I got a question recently on this topic. Now this isn’t an actual answer to this specific question. Rather, I will explain the approach you should use to handle these kinds of messages in general. At the same time, I think the general answer is becoming more important now because of an important reason. Static Rich responses for Google Assistant vs static Rich Responses in other channels If you take a look at the Response section inside Dialogflow, you will notice something very interesting. The number of possible Rich Responses for Google Assistant is quite a lot more than the number of possible rich responses for the other channels. There are 10 rich responses for Google Assistant you can specify…

DialogFlow | Webhooks

Want to learn Dialogflow webhooks systematically?

Some time back, I put up a survey on my website asking readers what they find most challenging about learning Dialogflow. The most challenging topic, not too surprisingly, was webhooks a.k.a fulfillment. This prompted me to write an article about why it is so hard to find good documentation for Dialogflow webhooks. And unfortunately it has only gotten even more difficult since I wrote it. And in this article I am going to explain why. Challenges with learning Dialogflow webhooks There is a lot of documentation you see for Dialogflow webhooks which is quite out of date. This is actually due to a combination of 4 different factors. API version change Did you know that the API version you set…

DialogFlow | Webhooks

The easiest way to understand Dialogflow webhooks

Are you tired of Dialogflow fulfillment tutorials which seem to be out of date by the time you read them? What if I said there is a way to understand how Dialogflow fulfillment works without using code? Since there is no code, there is very little chance for this approach to become obsolete. Use a REST API mock service There is a service called Mockable.io which allows you to mock your API in no time. First, go to the website and log in using your Google account. You should see a dashboard like this. Click on the blue Manage button, and then create a new REST Mock. At the top of the page, add test to the existing URL (note:…

DialogFlow | Webhooks

7 things to consider before choosing your Dialogflow webhook language

Wondering which language to use for your Dialogflow webhook? In this article, I discuss some things you need to consider before choosing it. 1 NodeJS is asynchronous While NodeJS is clearly exploding in popularity, if you are not already proficient in NodeJS, you might want to use it to build a toy project first before using it for your webhook. For example, I got a question recently where someone was pointing out that the inline editor code “does not wait” for a request sent to a different API to return. The reason this happens is because NodeJS is inherently asynchronous, and to make your code “wait” for a request to complete you need to learn how to use the concept…

DialogFlow | NodeJS | Webhooks

You can use only NodeJS in the inline editor of Dialogflow

I got this question in a comment recently: I have been asked this question a few times, so this might be a good opportunity to clarify. The inline editor uses Firebase cloud functions The code editor inside the Dialogflow console, also called as the Inline Editor, is actually used only for writing Firebase cloud functions. And even the type of code you can write within the inline editor using cloud functions is a bit limited. (For example, right now, if you want to write code that saves to a database you cannot do so from the inline editor, to the best of my understanding. You need to go to the regular webhook in that case.) Summary The inline editor in…

DialogFlow | NodeJS | Webhooks

Dialogflow NodeJS Webhook – the 10 minute guide

NOTE: the code samples that the Dialogflow team used to provide have either been deleted or moved to some completely different GitHub project. I don’t have the bandwidth at the moment to retrace my steps and get the old code. So I suggest you skip this tutorial and find other material elsewhere. Recently Dialogflow announced (rather, provided) a new library for helping people get started with building out a NodeJS webhook in very quick time. It is called the Dialogflow Fulfillment library and it is intended to help you build a NodeJS webhook inside your inline webhook editor. While the library is super helpful, the documentation on the GitHub page misses a few things. This article is intended to fill…

Debugging | DialogFlow | 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…

DialogFlow | NodeJS | Webhooks

Handling multiple intents in your NodeJS webhooks

In a previous article, I explained how you can get started with Firebase for your Dialogflow agent. I got a question from a reader asking how we can handle multiple actions in the same Firebase code. I will explain the process in this tutorial. Since we already wrote some code to handle a single intent in the tutorial, we can derive an example for handling multiple intents by adding to the old index.js file. The display message intent The actual intent is quite simple. The user will type “display message”, and we will have an action called displayMessage, and the intent will call the webhook which will send a message to be displayed in the console. Since the index.js already…