Skip to main content

Connecting Dialogflow to JAICF project

Dialogflow — cloud platform for natural language recognition from Google.

The platform makes it easy to integrate a conversational user interface into your mobile app, web application, device, and so on. In this article, we are looking at connecting Telegram for a JAICF project using Dialogflow.

To connect the Dialogflow channel to the JAICF project, please follow these steps:

  1. Prepare the project.
  2. Create a channel.
  3. Configure the Dialogflow.
  4. Test the skill.

Prepare the project

Before connecting a channel, prepare the JAICF project in advance:

  1. Specify the following in the dependencies of build.gradle.kts file:
dependencies {
// ...
Don’t forget to substitute $jaicfVersion with the latest framework version.
  1. Configure depending on the connection method to the platform:
  • long polling — the bot will connect to the Just AI server when interacting with the platform. Simple solution, convenient for local development, and debugging.

    For this method, specify ActionsFulfillmentDialogflow() in the JaicpPoller.kt file:

package com.just-ai.jaicf.template.connections

fun main() {
channels = listOf(
  • webhook — the bot will receive messages from the platform using the specified link. Must be configured to connect JAICP Cloud.

    For this method, specify ActionsFulfillmentDialogflow() in the JaicpServer.kt file:

package com.just-ai.jaicf.template.connections

fun main() {
botApi = templateBot,
accessToken = accessToken,
channels = listOf(
).start(wait = true)

Create a channel

Open the JAICF project on JAICP. Go to the Channels tab on the side panel, then click Inbound → Connect channel. In the Voice Assistants section, choose Dialogflow. Specify the channel name and click Create.

Click Get webhook under the name of the newly created channel. It will be copied to the clipboard. The copied webhook will be needed later when configuring the skill.

Configure the Dialogflow

Create an agent

Log in to Dialogflow CX Console. First, you need to register and create a new agent, click Create new agent.

Fill in the following fields:

  • Agent name — specify your agent name.
  • DEFAULT LANGUAGE — the default language supported by your agent. You can add additional languages after creating your agent.
  • DEFAULT TIME ZONE — the default time zone for your agent.

Click Create.

Create intents

In order for the agent to start processing requests, you need to add intents. Intent is the key unit of the Dialogflow service, which combines a set of phrases, customer intent and other meta information.

There are two default intents added in the agent:

  • Default Welcome Intent — greeting and start of the dialog;
  • Default Fallback Intent — activated if none of the other intents match.

Click Intents on the side menu. Since we have a welcome intent by default, let’s add a goodbye intent. To do this, fill in the fields:

  • Intent name — specify Bye here.
  • In the Training phrases section specify Bye and Goodbye.
  • In the Fulfillment section activate the switches Enable webhook call for this intent and Enable webhook call for slot filling.

Then click Save. Following the sample add all the necessary intents for your script.

Intents in the JAICF project script

Please note that names of the intents in Dialogflow and in the scripts of the JAICF project must match:

state("bye") {
activators {
intent("<Dialogflow intents name>")

action {
"Dialogflow intents name"

In the Dialogflow Console on the left panel, click Fulfillment. Here, in the Webhook section, insert the webhook that was created earlier when creating the channel on JAICP. Save your changes.

Next, click Integrations on the left panel, here activate the integration with Telegram.


In a few seconds, you can test how your skill works. To do this, after completing the training, click Try it now in the right panel of the Dialogflow console. Enter in the field one of the activation phrases that you specified when creating the skill.