Table of Contents

Redirect User Based on Language Input (DeepL)

Abby Updated by Abby

DeepL is a language translation tool which allows you to use their free API for translations.

They currently support 26 languages for more information on supported languages check out their docs.

The purpose of this article is to show how to set up the API call for DeepL, in the example below we're going to detect the users language and then direct them to a new bot depending on the language they entered.

DeepL API key

In order to get our API key we'll need to sign up here, the free plan is perfect for our use case.

After verifying your bank card you'll be able to access your account.

The free account comes with up to 500,000 characters which should be more than enough.

You can go directly to the API docs, and you'll see REST and CURL examples with your api key.

Setting up the bot

The bot is very simple to set up, we'll just start with an open question in the welcome message, it will look like this (go here to change the placeholder):

The user input will automatically be saved in the variable @welcome.

Webhook

Next is setting up the webhook, we'll do a POST request with the following:

https://api-free.deepl.com/v2/translate

Then in the params, we'll add the API key, the user input, and the language we want the text to be translated to (optional).

In order to save the output as variables we should first test the request with a test phrase:

The output should look like this:

So, we'll save both 'detected_source_language' and 'text' as variables:

Adding the conditions

Last part! Now we'll add conditions, that will direct the user based on the language input:

Demo

How did we do?

Contact