Can I switch language using script node?

Is there a variable I can set within a Script node that tells Kore.ai that I want to use a different language? I am trying to onboard customers with the language that they were using in the original application before control was passed to Kore.ai. I have a script node that detects the incoming language and I have an if statement that correctly prints “NEED GERMAN COMMAND HERE” or “NEED ENGLISH COMMAND HERE” in the Metrics log. So, I detect the language I want to us, I just don’t know how to actually change it. For example, can I call the cheat command inside javascript somehow or something like that?

Hi @ben.hartman,

Please check if the following snippet works

context.currentLanguage = “Es”

image
Here, Es is the language code of Spanish.

Let us know if the above snippet suffice your requirement,

Regards,
Yoga Ramya

This does not seem to work.
I have a dialog being triggered by OnConnect from the Web channel. My bot supports English and French.
For testing, the dialog prints a message, then uses a script node to run:
context.currentLanguage = “fr”;
then another message node.
Both the message nodes mentioned above get printed in English. I would expect the second message to appear in French, and for the bot to remain in French mode.

I am able to successfully identify the users browser language, which we wish to greet then in, but I cannot influence the language that Kore is using for their messages. So as the original poster asks, how can we script ‘cheat lang fr’?

@swagata.sengupta Any suggestions on this?

@paul.osborn
As per my understanding, once you are in the middle of a conversation (script node is usually within a dialog) you cannot change the language abruptly. While executing a dialog, a particular language’s version of the task is fetched from the server and the same is executed. Now if there is a change in language, it will require a re-fetch of the dialog.

If you are setting the currentLanguage in one task (example - on connect task - just set it there maybe), the execution following task should pick up the language in the currentLanguage.

@paul.osborn
To change the language you may also try one more option if you are using Bot-Kit. disable language

OK, from your explanation I understand that the displayed language may not change within the task which sets currentLanguage. Your explanation of this is good, and we can get around that by using Logic nodes to select different Message nodes to fake the multi-language Welcome behaviour.
However, in the debug window display of the Context we can see that currentLanguage is not changed after the end of the dialog, so does not persist. So any later dialogs, or smalltalk, remain in the original language. I have verified this with a new bot, with English/French default smalltalk, and a single task which sets “context.currentLanguage = “Fr”;”.
The fundamental problem we are trying to solve is “How do we greet new French visitors in their own language?”. We don’t want them to see any English messages. Kore should be adopting their browser-language as the default. Is this possible?

After further discussion with Kore Support, a promising solution is the set
botOptions.botInfo.customerData.interactiveLanguage = ‘fr’;
in the kore-config file of webkit. This forces the bot to start in French (solving our welcome message problem), but likely to cause the bot to only speak French.
We are looking to add a language selection dropdown to the web UI, so we can re-connect the bot session if a new language is selected, forcing the bot to that language. We think this should give a solid experience to users.

2 Likes