Guide: Four Ways to Change Your Bot's Language
# 📖tutorials
e
Tutorial by @acceptable-kangaroo-64719 Here are a few different ways you can change the language your bot speaks! Companion video:

https://youtu.be/fBwSLPbPqn8

. The bot from this video is embedded below! Remember to enable your Translator Agent! Method 1: Hard-coding the language with the Set User Language card Difficulty: Lowest 1. Add a Set User Language card to the start of the conversation to set the bot language. The value should be a language code like
en
or
fr
ℹ️ Your bot will now speak that language and translate all messages to it! You can use your preferred language's two-digit code here as long as it is within the ~90 or so languages ChatGPT speaks. See a list here: https://botpress.com/blog/list-of-languages-supported-by-chatgpt and a list of language codes here: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes Method 2: Hard-coding the language with a Execute Code card Difficulty: Low 1. Add an execute code card with this content (remember to change the language code)
Copy code
js
user.TranslatorAgent.language = 'fr'
Method 3: Let the user pick language with buttons Difficulty: Medium 1. Create a capture card with each possible language as a choice. 2. After the use selects a language use a Execute Code card with a content like this, but tailored to the language choices from step 1:
Copy code
js
if (event.preview == '🇬🇧') {
  user.TranslatorAgent.language = 'en'
} else if (event.preview == '🇫🇷') {
  user.TranslatorAgent.language = 'fr'
} else if (event.preview == '🇪🇸') {
  user.TranslatorAgent.language = 'es'
}
Method 4: Automatically detect the user's language and respond in kind Difficulty: Low In your Translator Agent, make sure the options for "Automatically Detect Language" and "Detect Language at Each Turn" are enabled. Now the bot will change the language whenever the user speaks a new language.
p
where can i get help?
a
you can make a post in #1111009377525186570
r
How can i upload this file language-demo-bot.bpz in my botpress account?
q
check this
s
🇧🇷
j
guys
cant you just do a set user language "en" and then connect it to the next node ?
a
yes you can do that, too!
j
awesome !
so im not wrong
n
Nice guide! Is there a way to NOT translate a link? I want the text to be translated, but not the links to the website. Currently it is also translating the links. Thanks
g
Hi @acceptable-kangaroo-64719 was just watching your video and trying out the template... very practical, thanks! There's one issue I'm encountering with the auto translation... with certain languages (I tried Slovak/SK), it gives the initial response in the desired language, but than it either doesn't continue with the small talk (just repeats the same message) or even more commonly, turns into what seems to be Romanian lol Do you know why that can be? I also tested German and Russian and there it works perfectly (also with the small talk) If you're able to look into it, please let me know what you'd need from my end. Thanks 🙂
a
Hey @gifted-helmet-37393 , that's interesting that chatGPT isn't very good in Slovak. Here are a couple things you can try to improve consistency: * Use a knowledge source in the desired language * Prompt the knowledge agent or AI task to output a shorter response * Include the desired language in the prompt Finally if none of those work, you can try running your answer through a second AI task with instuctions to translate it to Slovak.
p
I'm possibly having the same problem, did you manage to solve it?
t
Hi gusy, I have a question. After the user has selected their desired language, how can the bot consistently use the selected language to respond throughout the entire workflow? thanks
not just on one card...
e
Hello @tall-apple-15573, you can use the first method after the user selects a language from a menu.
Make sure that "Detect Language on Every Turn" is on
t
cool! thanks
p
Hello guys, can I add this bot language to my current workflow? Thanks.
f
any one can help me
c
Hey, im trying to apply items to my variable language but looking for insite on how to go about doing so? Cant seem to find where i can apply the language options.
h
@acceptable-kangaroo-64719 Thank you very much for the detailed instructions. The question arose how to make a reverse translation of messages that the user enters. I need to search in the table at the user's request, and the data in the table is in English, but when communicating, the user enters a search request in French. That is, I need to somehow translate this request back into English and search in the table, and then issue the received data again in French
a
If you're doing a semantic search over vectorized data, language itself shouldn't have too much of an impact. The beauty of vector searches is that it finds similar meaning, not merely similar words. If you require a translation for something like a keyword search, I'd recommend using an AI Task card to explicitly translate the user's message, and then used the saved translation in further cards as needed.
h
Thank you very much - I did it! Everything works!
4 Views