How To Create Your Very Own Facebook Messenger Bot with Dialogflow and Node.js In Just One Day

How To Create Your Very Own Facebook Messenger Bot with Dialogflow and Node.js In Just One Day

Pilar is a software engineer at Crowdbotics specializing in chatbots, test automation, and frontend development.

So, you?re here because you want to create your first chatbot. Or maybe you?ve already built one, and you want to know how you can improve your chatbot?s responses with NLP.

Today, I?m going to show you exactly how to do that! We?ll build a chatbot with rich NLP features using Dialogflow,, and Node.js. The best part? It?ll take us just one day.

Let?s review. What is a chatbot?

Chatbots are computer programs that mimic conversation with people through the use of artificial intelligence.

In a nutshell, when someone types in a message, the bot responds with the right reply.

Out of the thousands of chatbots that exist today, most are messenger apps designed to communicate with customers. They work with Natural Processing Language (NLP) systems which translate everyday language into a form that the bot can understand and learn new interactions from.

Through the help of that technology, bots now hold endless possibilities. You can use them to read everyday news, get the weather, transfer money, buy your favorite items, schedule a meeting, or even get service assistance. And all from the convenience of your favorite messenger app.

People are now spending more mobile screen time on messaging than on social media. A lot of companies have noticed the trend and are taking advantage of chatbots as a new channel to talk to us. Turns out that a whopping 60% of online adults in the US use online messaging, voice or video chat services.

Even stranger? It?s thought that by 2020, we?ll have more conversations with bots than with our actual spouses.

Choose your tech: Dialogflow or

We?re choosing between two popular platforms when building our chatbot: Dialogflow and


Dialogflow (once known as is a service owned by Google that allows developers to build speech to text, natural language processing and artificially intelligent systems that you can train with your own custom functionality. This incredible tool uses machine learning to understand what users are saying and it?s beyond simple to set up nonlinear bots quickly.


  1. It?s Useful: It integrates NLP without much hassle.
  2. It?s Easy: Dialogflow contains lots of pre-built agents that are a breeze to activate.
  3. It?s Integrated: You can connect your favorite platforms such as Facebook, Twitter, Slack, Telegram, etc?
  4. It?s Multilingual: It recognizes more than 15 languages.
  5. It?s Cheap: You?ll be glad to know it?s totally free.


  1. It?s Not So Customizable: If you want to create a customizable bot, you will need to implement a code flow, and these examples are not shown in any of its documentation.
  2. It?s Not So Implementable: It can be tricky to figure out how to perform platforms implementations as it is not documented. (owned by Facebook) works similarly to Dialogflow: it also processes human speech patterns and filters useful data like intent and context from it. Like Dialogflow, it provides a UI to help developers with creating intents, entities and agents.

What Are Its Pros?

  1. It?s Also Useful: also integrates NLP.
  2. It?s Also Easy: The Quickstart tutorial is very practical in order to get started.
  3. It?s Also Integrated: You?ll also be able to integrate with several platforms, like Facebook, Twitter, Slack, Telegram, etc?
  4. It?s Also Cheap: Totally free!
  5. It?s Adaptable: You?ll be able to build your bot with Node.js, Python or Ruby.
  6. It?s Pragmatic: Enjoy an easy to read ?Recipes? section for common problems and how you can solve them.

What Are Its Cons?

  1. It?s Not-So Fast: Since the learning curve is steep, you?ll need to invest time into figuring out how to implement it.
  2. It?s Not-So Visual: Given that there?s no visual development environment, you?ll need to be comfortable with code.

So which did we pick?

Given that Dialogflow provides junior developers with the best documentation and a great user experience for developing a bot without being an expert in the field, we?ve decided to give it a shot for this tutorial.

A step-by-step guide to building the chatbot

In this tutorial, we?ll be using Node.js to build a simple bot, so please make sure it?s installed on your computer.

So let?s get started!

Step 1: Setting up your development environment

Let?s create a simple webserver with one webhook endpoint. I?ll use Express.js.

1. Writing webhook server with Express

First of all, we need to know that a webhook (also called a web callback or HTTP push API) is a way for an app to provide other applications with real-time information. It delivers data to other applications as it happens, meaning you get data immediately, unlike typical APIs where you would need to poll for data very frequently in order to get it in real-time.

In order to get started, you will have to create a new directory, where you?ll store your entire project. We are going to name it ?Bot Tutorial?.

Image for post

Building A Web Or Mobile App?

Crowdbotics is the fastest way to build, launch and scale an application.

Developer? Try out the Crowdbotics App Builder to quickly scaffold and deploy apps with a variety of popular frameworks.

Busy or non-technical? Join hundreds of happy teams building software with Crowdbotics PMs and expert developers. Scope timeline and cost with Crowdbotics Managed App Development for free.


No Responses

Write a response