Articles on: Developers

How to connect a Dialogflow ES chatbot to Crisp

Connect a Dialogflow ES agent to the Crisp chatbox with a backend you host. You’ll train the agent to recognize a question, then connect it to Crisp so a visitor can get the answer in the chatbox.


Dialogflow identifies what a visitor is asking, and the connector posts its response in the Crisp conversation. You’ll need a test workspace, a backend where you can run Node.js, and familiarity with environment variables. For an agent configured directly in Crisp, see Getting started with Hugo.



Understand the integration flow


An intent describes a question or task your Dialogflow agent can recognize. For example, several ways of asking about delivery can match the same intent and receive your shipping policy. An intent can also collect parameters or use fulfillment to call your own backend.


  1. A visitor sends a message through the Crisp chatbox.
  2. Your connector receives the visitor message through the Crisp RTM API and sends the text to Dialogflow.
  3. Dialogflow returns the response for the matched intent.
  4. The connector sends that text back to the same conversation through the Crisp REST API.


Crisp’s example connector uses Dialogflow ES and forwards the fulfillmentText response. Rich responses and human handoff need additional implementation. Use a workspace separate from customer conversations while adapting and testing it.



Create a Dialogflow agent and intent


If you already have an ES agent, use it for the test below. Otherwise, create one in the Dialogflow ES console. The example connector sends en-US, so set its languageCode to the language you want the agent to recognize when you configure the request below.


Create the agent


  1. Sign in to Dialogflow and select Create new agent in the agent menu in the left sidebar.
  2. Enter a name, default language, time zone and Google Cloud project.
  3. Click Create.


Create a first intent


Choose a question you want the agent to answer. An intent needs training phrases that express that question and a response the connector can post as text. If you already have a suitable intent, you can test it in the simulator and continue with the connection.


  1. Click + beside Intents and give the intent a name that describes its purpose.
  2. Under Training Phrases, add a few ways a visitor might ask the question.
  3. Under Responses → Text Response, enter the reply you want the visitor to receive.
  4. Click Save and wait for training to finish.


Test the intent


Enter a question in the Try it now panel. Check that Dialogflow selects your intent and returns the response you wrote. If it does not match, check the training phrase and selected language before connecting Crisp. Google’s agent quickstart describes the console and intent test.


Example → To test the connection with a recognizable reply, you could create a temporary intent called ping-pong, with “ping” as its training phrase and “pong” as its text response.


Dialogflow ES matches “ping” to the “ping-pong” intent and replies “pong”



Get your Dialogflow API credentials


The connector needs permission to send text to the agent’s project. Create a Google service account there and grant it the Dialogflow API Client role, which supports intent detection.


If your organization permits service account keys, open the account’s Keys tab, choose Add key → Create new key, and select JSON. Store the downloaded file on your backend host. Google’s key creation guide covers the required permissions. If key creation is disabled, ask your Google Cloud administrator to configure the authentication method approved for that host.


Keep the Google credentials file and your Crisp API token on the backend. Anyone with those credentials can make requests with their permissions.



Connect Dialogflow to Crisp


Clone crisp-im/crisp-dialogflow and install its dependencies with npm install. The repository uses the older node-crisp-api package. The changes below follow that package’s API. Check that its dependencies work with your chosen Node.js runtime. Migrating to the newer crisp-api package also requires adapting the connector code.


Configure the credentials


Use a Plugin Token for the test workspace. For a Development Token, make that workspace your Marketplace account’s Trusted Workspace. For a Production Token, request read and write access to website:conversation:messages and install the plugin on the workspace. The plugin development guide explains both stages, and the REST authentication guide covers the credentials.


In lib/index.js, uncomment crispClient.setTier("plugin") before authentication. Replace the existing config object with the following and set the three variables in your server’s environment. Use the Google Cloud project ID associated with the agent.


const config = {
crispIdentifier: process.env.CRISP_TOKEN_IDENTIFIER,
crispKey: process.env.CRISP_TOKEN_KEY,
dialogflowProjectId: process.env.DIALOGFLOW_PROJECT_ID
};


Set GOOGLE_APPLICATION_CREDENTIALS to the JSON file’s absolute path in that same environment.


  • macOS or Linux → export GOOGLE_APPLICATION_CREDENTIALS="/absolute/path/to/key.json"
  • Windows PowerShell → $env:GOOGLE_APPLICATION_CREDENTIALS="C:\absolute\path\to\key.json"


Prepare the message handler


The example sends event.content as text to Dialogflow. Inside the existing message:send handler, put this check before sendMessageToDialogFlow(event) so it only processes text messages.


if (event.type !== "text" || typeof event.content !== "string") {
return;
}


Dialogflow limits its session ID to 36 characters. Crisp conversation IDs are longer. Inside sendMessageToDialogFlow, replace the existing const request = {...} with this block. It derives a stable 32-character ID from the workspace and conversation, then uses it for Dialogflow’s session.


const dialogflowSessionId = require("crypto")
.createHash("sha256")
.update(`${event.website_id}:${event.session_id}`)
.digest("hex")
.slice(0, 32);

const request = {
session: sessionClient.projectAgentSessionPath(
config.dialogflowProjectId,
dialogflowSessionId
),
queryInput: {
text: {
text: event.content,
languageCode: "en-US" // Use your agent’s language code.
}
}
};


Continue using the original event.website_id and event.session_id in sendMessageInCrispConversation. That sends the reply to the customer’s Crisp conversation. Google’s intent-detection reference describes the Dialogflow session format.


Test a conversation and a customer question


Run node lib/index.js from the project root. Open the test workspace’s chatbox as a visitor and send a question that matched your intent in the simulator. Look for the expected reply in the chatbox and in the same conversation in the Crisp Inbox. If the simulator worked but the chatbox receives no answer, check the connector logs, token tier, workspace access and Google project credentials.


Try another phrasing and a question outside the intent to check the fallback response.


Example → A delivery-options intent might recognize “Which countries do you deliver to?” and “Do you ship internationally?”. Its response can explain the store’s shipping policy, and real customer questions provide training phrases for that intent. Google’s training-phrase guide explains how those examples help match the intent.


Before using the connector for customer conversations, catch errors from detectIntent and handle empty fulfillment text. If a teammate takes over a conversation, make sure the connector stops sending automated replies there. The backend messaging checks cover reply scope, repeated messages and handoff.


For further work on the agent, use Google’s Dialogflow ES tutorials, how-to guides and samples. The Crisp REST quickstart and RTM quickstart explain the two sides of the connector.

Updated on: 02/12/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!