Articles on: Developers

How can I create an AI chatbot with Dialogflow?

In this tutorial, you will learn how to connect Dialogflow with Crisp to create an AI chatbot that leverages the power of our chatbot API. If you are a complete novice about Dialogflow platform or new to the Crisp API, no worries, everything will be explained.

➡️ Want to know more about Crisp Chatbot pricing and features? Click here: Crisp Chatbot Software
➡️ Want to know more about Crisp Chatbot API pricing and features? Click here: Crisp Chatbot API

What is Dialogflow?

Dialogflow is a complete platform for artificial intelligence. It is based on natural language processing (NLP), a very powerful technology. Currently maintained by Google, it is one of the most used service to create AI chatbots.

Bots created with Dialogflow can be integrated anywhere: mobile application, web application, device, robot, interactive voice response system, etc.

Advantages of Dialogflow

Bleeding edge machine learning algorithms from Google.
The robustness of the solution and its inclusion in the Google universe (Cloud platform, Home) which makes it reliable, durable and rich in interactions. Thus, the Google Small talk feature allows to capitalize on the interactions frequently used by users.
It can handle 14 different languages.

Dialogflow is completely free for new users and low traffic websites.

How Dialogflow chatbots work with AI?

The base component of each chatbot is an agent, it is the name for a bot in Dialogflow. Each incoming message will be matched to an intent within the concerned agent. After matching, the intent will decompose the message using actions, and extract interesting parameters from the message. Then, Dialogflow will call your custom code to handle the request: this is called the fulfilment.

How dialogflow handles a new request.


Setup your Dialogflow chatbot

Browse to:

If you already have an agent and an intent, you can go to the next section.

Create an agent.

If you do not have an account, create one.
Click on Create new agent in the left navigation and fill in the fields.
Give a name and set a default language to your agent. Then, click the Create button.

Build your first intent

In this section, we will create a simple ping pong intent. It will be easily extendable.

In the intent pane, click on Create intent and give it a name.
Now, press Add training phrases in the Training phrases section of your intent. Just add "ping" training phrase.
Switch to Responses, and add "pong" response.
Click on Save

Current intent definition.

Test your intent

In the right Try it now pane, write: ping. You should see: pong has a response.

Expected response

Get your Dialogflow API credentials

Follow Google's guide:
In your service account, add the role: Dialogflow API client.
Download credentials in the json format.

Setup your code

Clone the GitHub repository: and get the project dependencies: npm install
Get your Crisp API token:
Add respectively the identifier and key inside the cloned repo, fields: crispIdentifier, crispKey.
Add your Dialogflow project ID (or agent ID) in dialogflowProjectId.
Append your environnement variables with: macOS/Linus: export GOOGLE_APPLICATION_CREDENTIALS=PATH_KEY_FILE.json , Windows: $env:GOOGLE_APPLICATION_CREDENTIALS="KEY_PATH"
In the same terminal, switch to project root and execute: node lib/index.js

Test your chatbot

As a customer, send a "ping" message.

Expected response from Dialogflow.

Next steps

You now have a working communication between Crisp chatbot and Dialogflow. The next step is to create an intent that matches your need, you can find a lot of documentation on Internet thanks to the extensive Dialogflow community.

Dialogflow tutorials from Google:
Google's how to guides:
Samples and learning material:

Updated on: 13/03/2024

Was this article helpful?

Share your feedback


Thank you!