Home / DialogFlow ES / Dialogflow NodeJS Webhook – the 10 minute guide
DialogFlow ES | NodeJS | Webhooks

Dialogflow NodeJS Webhook – the 10 minute guide

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.

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 those gaps. Here are the steps to make use of the library to deploy your NodeJS based webhook.

1 Create an intent in your agent

In my case, I am building a calculator app. The first intent is an intent which adds two numbers and this is how I have defined my intent.

Note that I have toggled the “Enable webhook call for this intent” switch at the bottom of the intent.

2 Copy code from GitHub to inline editor

Copy the code from index.js in the GitHub library located here and paste it into your inline webhook editor.

3 Add a handler function for AddIntent

In your inline editor, add the following code.

4 Map the code to the newly added intent

In index.js, right below the other mappings, add a mapping from the name of the intent you just created to the add function.

5 Deploy the inline webhook

Click on the blue Deploy button at the bottom of the inline editor to deploy the code to Cloud Functions for Firebase.

6 Test the webhook in the console

Now test if the webhook is working by invoking the intent to add two numbers in your Dialogflow test console.

Congratulations! Your NodeJS webhook now works.

Some things to note:

  • the inline webhook cannot be used (to the best of my knowledge) to save data to a DB. You need to use the Google Cloud CLI (Command Line Interface) on your dev machine to enable that
  • the code works with both v1 and v2 API
  • there is a lot of sample code in the same project which helps you understand how to extract relevant information from the JSON coming from Dialogflow, as well as how to send back rich responses


By learning how to deploy webhook code using the inline webhook editor, you can get started with your webhook very quickly. Once you understand the basic structure of the code, you will be able to do more complex business logic in your webhook (for this you will most likely need to use the Google Cloud CLI).

Similar Posts