Oracle Bots comes with platform Translation services, which you can connect to Google or Microsoft services to translate the bot to user default locale.
But what if you want to control this auto-translation and restrict the bot to only a few languages. Or want to do Intent matching properly or extracting the Entities properly depending on the language.
In the following Bot Design pattern, I will explain how to approach a development of an Oracle Bot which support multiple languages with different Intents and Entity sets.
Before I start, I have to give credit to Oracle A-Team for this, they are the one who first introduced this, I am merely a message-borrower in there. So special thanks to Tamer Qumhieh and Steven Davelaar.
The idea is to do Intent matching properly for specific languages. Ideally you code the Master Bot in the default language the bot needs to respond. So all the Intents you add is being trained for that particular language, for example English.
Then the other bots have language specific Intents and they are being trained for that language.
Advantage you achieve is, the bots are being trained separately for each language and your Intent matching works properly.
You can find more info in the dev guide : https://docs.oracle.com/en/cloud/paas/mobile-suite/develop/localization.html#GUID-997ED305-D011-4E89-9440-566092A4870A
Secondly, you can use a Custom Component to detect user language. This custom component will call an external API (Yandex) to identify user language and store the detected language in a variable.
The implementation details of this Custom component is in this blog.
What you need to do :
Advantage of this implementation is higher than my earlier technique. With this implementation you can scale to as many language specific bots you want without changing the Master bot at all.
But what if you want to control this auto-translation and restrict the bot to only a few languages. Or want to do Intent matching properly or extracting the Entities properly depending on the language.
In the following Bot Design pattern, I will explain how to approach a development of an Oracle Bot which support multiple languages with different Intents and Entity sets.
Before I start, I have to give credit to Oracle A-Team for this, they are the one who first introduced this, I am merely a message-borrower in there. So special thanks to Tamer Qumhieh and Steven Davelaar.
The Situation
You need to create a bot which can respond to multiple languages, with proper Intent matching and Entity identification. Also, the implementation later can be extended to new languages with minimal changes to existing bot implementation.The Pattern
You need to create a Master-Bot, which will hold the Intents, Entities, Dialog Flow, Custom Component mapping and Channel(Facebook, Webhook) mapping of the bot. Then you need to create language specific bots, which will only hold Intents and Entities(optionally, only if you have a requirement to match language specific entities).The idea is to do Intent matching properly for specific languages. Ideally you code the Master Bot in the default language the bot needs to respond. So all the Intents you add is being trained for that particular language, for example English.
Then the other bots have language specific Intents and they are being trained for that language.
Advantage you achieve is, the bots are being trained separately for each language and your Intent matching works properly.
Implementation Details
After you have added all required language specific bots, add the Intents and Entities to them. Make sure you train all these bots before moving on the steps mentioned below.
Now, in the Master Bot implement the below mentioned steps.
Step 1 : How to detect the language
There are couple of ways to detect user language. Oracle bot provides a out-of-the-box Translation services, which you can use to in your bot to detect the language.
Couple of steps to implement this:
1. Define a Translation Service (Google or Microsoft)
2. Add a Dialog Flow state(Detect Language) to detect and store user language.
Secondly, you can use a Custom Component to detect user language. This custom component will call an external API (Yandex) to identify user language and store the detected language in a variable.
The implementation details of this Custom component is in this blog.
Step 2 : Implement a Switch State in Dialog flow
Once the user language is detected, we have to introduce a "Switch" State in the dialog flow.
If you use the Custom Component to identify the language, you Switch state show look like below:
Step 3 : Intent Matching States
The Switch state, should direct the dialog flow to a particular Intent matching state. The Intent matching state has a variable "botName", which you can use to invoke the language specific bot match the user input.
So, in the below picture, you can see 2 different Intent matching states, invoking 2 different bots.
Finally
As a whole the complete implementation of the Dialog Flow should look like:ExtraTip
To make the Bot development more flexible, you can use Apache FreeMarker to reference the "botName" property in the "Step 3" above and completely remove the "Step 2" (switch state).What you need to do :
- Name you bot with a language tag. For example : MyBot_en, MyBot_nl, MyBot_es. So here in this example "MyBot_en" is your master bot. Also, all the Intent names need to be same in the all these bots.
- Identify the language, as explained earlier in the "Step 1".
- Refer to an Intent matching state like below. There 2 flavours of it, one if you use platform configured Translation services or use a Custom comp to detect the language.
Advantage of this implementation is higher than my earlier technique. With this implementation you can scale to as many language specific bots you want without changing the Master bot at all.
Comments
Post a Comment