Table of Contents

Dialogflow in Unsupported Languages (& Multilingual)

Abby Updated by Abby

Unfortunately, Dialogflow is limited to the languages it supports, however, with the help of translation API's such as Google Translate or DeepL we can still use it!

Keep in mind that the language of your Dialogflow agent should be one of the supported languages.

Here's how to set up Dialogflow in Landbot

After we've built the agent we'll use the translation api to translate the input and output, here's an example of what it will look like:

We save the detected language after every input, and the response will be returned in the detected language each time.

The builder

We'll start with an open question, as we're unable to change the variable name for the welcome message, we'll send a request in the API with @welcome as the variable.

Next, we need to set up the first translation webhook, after the first webhook we have the Dialogflow block, which we'll connect to a loop, this loop will translate the response to the detected language, display the translated response in the welcome message, which will then continue the loop.

As the first variable @translatedtext will be empty, we won't have to worry about it appearing when the user opens the bot for the first time, instaed they'll just see the input option.

Google Translate

In order to use the cloud translation API you'll need to create a project, enable billing in your Google Cloud account, and then create credentials. To do this go to the Google Docs for Cloud Translation.

Setting up the first webhook

The first request we'll make is to translate the input of the user to the language of our bot.

We'll set up a POST request using the following URL, followed by your API key provided by Google:

https://translation.googleapis.com/language/translate/v2?key=YOUR-GOOGLE-API-KEY-HERE

In Customize Headers, we'll add Content-Type application/json

In the body, we'll add the following:

{

"q": ["@welcome"],

"target": "en"

}

Keep in mind that if you copy and paste the snippet, you may need to remove the quotation marks and add them again, as sometimes they're pasted in a different format.

Another thing to keep in mind is that the 'target' should be the language of your Dialogflow agent, mine's in English so I added "target": "en".

In order to be able to save the parts of the payload we want we should add a test variable, I added the following (be sure to change it back after):

{

"q": ["como estas"],

"target": "en"

}

Then press, 'Test the request'. This is the response:

We need to save both the translated text (to send to Dialogflow), and then the detected source language, to later use as a target to display the response in.

Dialogflow block

In the Dialogflow block we'll set up the request using @dfinput that we just saved from the webhook, and we'll also save the response as @dfresponse

We'll then connect all outputs to the next webook.

Setting up the second webhook

The second webhook will be set up exactly like the first, with two exceptions.

In the request body the variable will be @dfresponse instead of @welcome and the 'target' will be @detectedlanguage which is the input language the user originally wrote to us in.

We'll test it the same way, and save the variables as @translatedtext and @detectedlanguage

We'll then connect it to the welcome message, adding the variable @translatedtext to the welcome message.

Arabic and Hebrew

If the use case for your bot is Dialogflow in Arabic or Hebrew, you should set the target language in the second webhook as "ar" for Arabic, or "iw" for Hebrew.

You can also use the RTL CSS code we have prepared

Extra: Keyword and Bot Jump

We can also add a formula to check the intent, in this case, I have a different Dialogflow agent and bot for a different type of request, so with Formulas I'll check to see if the input matches that intent and if it does I'll jump to the bot with that agent, if not I'll continue the flow.

The first thing to do is add the formula to check the intent, here's how:

GetValue(@queryresponse, "intent", "displayName")

We then add a keyword jump block and add any intents that we may need, connecting them to the appropriate bots. We'll connect the default option back to the flow:

How did we do?

Dialogflow Integration Dashboard

Dialogflow - How to get JSON Key

Contact