Apply Custom Locale to Chatbot
You can set up a conversation flow to control the language of your chatbot response. This feature is called custom locale. The following object will be used in the application of custom locale:
Expected Outcome
When user types a keyword to indicate a switch to a specific language (i.e. "English"), the subsequent chatbot response will be changed to that specific locale group (i.e. "en").
Sample Chatbot Structure
Create a General Node - "Language Switch - Success"
- Before creating this general Node, you should set up any specific language you want to use in Stella. To do so, please follow this guide. In this standard procedure, you should set up "en" and "zh-HK" locale groups.
In Bot Builder, create a general node for informing user that the chatbot language has been switched successfully. You can rename is as "Language Switch - Success".
Create a new response. Create a text message to inform users that the chatbot language has been switched. This will be the fallback language in case the system fails to recognize a language.
- Open the "Platform Tab", select "+ Add Locale Group" under "Default*.
- Select the locale group you have previously created in settings.
- In the new locale group, enter the same text in the corresponding language.
- Now you can repeat Step 4-6 create one more locale group for "en". As a result, now you have a default locale and other locale groups under the same response.
- Save this response and node.
Create a Global Node - "Chinese Switch Global"
Create a Global Node and rename is as "Chinese Switch Global". This node is to trigger the custom locale action for switching the chatbot language to the "zh-HK" locale.
Create a Trigger with a specific keyword. You can use "Chinese" or "δΈζ".
- Create an Action and select "Change Language". Then, select the "Language to be switched to".
Note
If you wish to change to another locale, you may change the array behind this.member.customLocale in the code. You may check for the Supported Locale.
- Toggle on the redirect to the General Node - "Language Switch - Success".
Create a Global Node - "English Switch Global"
Create a Global Node and rename is as "English Switch Global". This node is to trigger the custom locale action for switching the chatbot language to the "zh-HK" locale.
Create a Trigger with a specific keyword. You can use "English".
- Create an Action and select "Change Language". Then, select the "Language to be switched to".
tip
If you wish to change to another locale, you may change the array behind this.member.customLocale in the code.
- Toggle on the redirect to the General Node - "Language Switch - Success".
- Test your chatbot and see if you can get the expected outcome.