Localize a bot
Localizing a bot for different languages, markets, and/or cultures is a common use case. This is accomplished in Teneo through branching, where we have the option of creating a 'Master' version of a solution and its own 'Local' versions for each of the different languages we are interested in. In this way, Teneo allows us to create local solutions with all of the parts of the master solution that we want to include, making it an efficient way to create bots for different languages and markets. You can read more about localization here.
In this guide, we will demonstrate how it is possible to localize the 'Longberry Baristas' solution, which is in English, to another language with resources, Swedish. More on branching can be found in the Documentation.
Prepare your solution
We will start by preparing the solution we want to localize. In this case, it is the 'Longberry Baristas' solution that's included in the environment you can request access at Teneo Developers.
- Select the solution, 'Longberry Baristas'.
- Click on 'Open' above the Solutions field.
Include relevant content for branching
It is time to include the relevant content from Longberry Baristas for branching.
Flows
We will start off with two of the bots' key flows.
- Select the flows 'User wants to order a coffee' and 'User asks about coffees we offer'.
- Click on 'Include' in the 'Branching' section in the ribbon bar. The buttons in the 'Branching' section look like this:
A more detailed explanation of these steps can be found here.
Classes
These flows use Class Match, which also means that they depend on Classes. These are stored in the Class Manager.
- Open the 'Class Manager' by selecting the 'Class Manager' button located in the 'Solution' section.
- Select the classes 'ANOTHER_ONE_PLEASE', 'ORDER_A_COFFEE' and 'TELL_ME_ABOUT_YOUR_COFFEE'.
- Finally, click on the 'Include' button in the 'Branching' section.
Entities
Entities are also used in these flows, and also need to be included for branching.
- Select the 'Language Objects' folder.
- Select 'COFFEES_SERVED.ENTITY'. Click the ‘Include’ button in the ‘Branching’ section.
Variables
The 'User wants to order a coffee' flow also makes use of a global variable that needs to be included for branching.
- Click on the 'Solution' tab.
- Click on 'Globals'.
- Under 'Variables', select the variable 'coffeeTypeInFocus'.
- Click on the 'Include' button.
- Finally, click on the 'Save All' button located on the sidebar in the solution backstage. This will make sure everything you selected to be included for branching inside the solution will be stored and saved.
Other solution content
At this point, we would also need to go over any other content we may need to include, such as Integrations, Contexts, Global Scripts and Listeners. However, for the two key flows we have selected in Longberry Baristas, no other content is used. Therefore, we can go ahead and start localizing!
Forget something?
Don't worry! It is possible to update your 'Master' solution if you forgot to include something before branching. Simply go back to the 'Master' Longberry Baristas solution, and include it. Then return to your 'Local' solution, go to the Solution backstage, and click on the 'My Work' section. We can now see the changes from the 'Master' solution, where we can either select Update All items to update everything or Update Selected items to only update relevant parts. Once updated, the local solution will pull in the changes from the Master solution.
Localizing Longberry Baristas
Now that we have prepared our solution, let’s branch our English Longberry Baristas bot to a different language. This process is fairly similar regardless of language; we will be using Swedish for this example.
- While in the Solution window, select the 'Longberry Baristas' solution.
- Click on 'Branch' above the solutions field.
- Make sure the 'Solution Language' for this first bot is Swedish. This will be the mother tongue of your bot.
- Under 'Solution Content', click on 'Master and Template' and select the latest version of 'Teneo Dialogue Resources Swedish' from the list.
- Fill in a name for your solution, for example
Longberry Baristas - Swedish (svenska)
.
- Finally, click 'OK' and wait for the branching to complete.
Identify Warnings and steps to take
Warnings in Tryout appear as yellow warning triangles. To see more detailed warning messages, open the Try Out window and navigate to the Messages section. More information on warnings can be found here.
User asks about coffees we offer
The most important aspect when localizing bots is for the final language to actually make sense for the target audience. Both in respect to the language that they actually use and the language that fits the market and culture. Flow triggers with Class-based match requirements are usually the easiest to localize. They usually use a limited number of Language Objects, where the only parts that need any localization are the training examples. To localize a Class-based match requirement trigger, do the following:
- Open the 'User asks about coffees we offer' in edit mode.
- Select the trigger and change its name to the local version of your selected language; for Swedish this is,
Vad har ni för utbud?
. - Replace the Intent examples with these Swedish translations,
example-inputs
1Vad har ni för utbud?
2Har ni bryggkaffe
3Har ni cappuccino
4Serverar ni macchiato
5Vilka kaffesorter har ni tillgängliga?
6Vilka typer av kaffe har ni
7Vilken kaffesort serverar ni
8Har ni latte?
9Vilka olika kaffedrinkar har ni
10Vad säljer ni?
11Vad har Longberry Baristas för utbud?
12Vad för kaffeutbud har ni?
13
- Open the selected Class Match by holding Ctrl and clicking once on the class name. This will open the 'Class Manager'.
- Edit the same class and rename it
BESKRIV_KAFFEUTBUD
. - Replace the training examples from the translated examples above.
- Replace the TLML Syntax in the Match section with
(%KAFFE.NN.LEX/%DRYCK.NN.LEX)
. - Press 'Save' and return to your flow.
Now that we are done with the class, next up we have the transition and the outputs to be localized.
- Select the transition 'Coffee type mentioned and served' and rename it to
Kaffedryck nämns och serveras
. - Go down the same path and select the Output node, 'We serve coffee type!' and replace its name with
Vi serverar kaffedrycken!
. While at it, replace the output answer withJa, ${mentionedCoffee} finns med bland vårt utbud!
. - Go ahead and select the other Output node and replace its name with
Vi erbjuder en mängd olika handgjorda kaffesorter...
. - Replace the Answer with the Swedish translation,
Vi erbjuder en mängd olika handgjorda kaffesorter från espresso till macchiatos, flat whites och ännu fler.
. - Hit 'Save'.
Congratulations, you have now localized part of your solution! Let us move on to the next flow.
User wants to order a coffee
Some flows will have multiple triggers with multiple match requirements. Localizing these is simply a matter of going trigger by trigger and match requirement by match requirement. Let us start by going through the triggers one by one.
Order a coffee trigger (Class and Entity)
- Open the 'User asks about coffees we offer' in edit mode.
- Let us start with the trigger 'Order a coffee'. Replace its name with
Jag vill beställa kaffe
. - Replace the Intent examples with
example-inputs
1En vanlig kaffe, tack!
2Jag vill beställa kaffe!
3Har ni Espresso?
4Skulle jag kunna få en macchiato?
5Jag vill ha en flat white.
6En latte tack!
7Jag vill ha en latte tack!
8Har ni vanligt bryggkaffe?
9En bryggkaffe
10
- Open the selected Class Match by holding Ctrl and clicking once on the class name. This will open the 'Class Manager' in a new window.
- Edit the same class and rename it
BESTÄLL_KAFFE
. - Replace the training examples with the translated examples above.
- Press 'Save' and return to your flow.
Another one please Trigger (Class)
- Next, let's move on to the trigger 'Another one please'. Replace its name with
En till tack
. - Replace the Intent examples with
example-inputs
11 till
2En till
3En till beställning
4får jag beställa en till
5Jag vill lägga en till beställning
6Kan jag få en till kopp
7
- Open the selected Class Match by holding Alt and pressing once on the class name. This will open the 'Class Manager'.
- Edit the same class and rename it
EN_TILL_TACK
. - Replace the training examples from the translated examples above.
- Press 'Save' and return to your flow.
Can I have one of those trigger (TLML Syntax and Context)
- Finally, let's move on to the trigger 'Can I have one of those?'. Replace its name with
Kan jag få en sån?
. - Replace the Intent examples inside the trigger with the following:
example-inputs
1Kan jag få en sån?
2Då tar jag en sån
3Kan jag få en sån, tack!
4
In the same trigger, the Global Variable Context Match will continue to work, but the TLML Syntax Match will need some updating. As you’ve already translated the examples, you can let Teneo generate a condition for you as done here.
- Expand the Advanced Options under the syntax panel and click on ‘Draft’.
Localize the transitions
Next in line is the localizing of the transitions with conditions found inside the flow.
User responds with coffee type
This transition has a condition for 'COFFEES_SERVED.ENTITY' which needs to be localized by doing the following,
-
Select the transition 'User responds with coffee type' and rename it to
Användaren svarar med kaffesort
. -
Scroll down to the 'Match' section. Open the mentioned Entity in edit mode by holding Alt and clicking once on the 'COFFEES_SERVED.ENTITY'. This will open the entity in a new window.
-
Replace the current entity with the following:
Coffee name coffeeType americano americano %CAPPUCCINO.NN.LEX cappuccino cortado cortado %ESPRESSO.NN.LEX espresso frappuccino frappuccino latte latte lungo lungo macchiato macchiato ristretto ristretto flat white flat white kokkaffe kokkaffe bryggkaffe bryggkaffe brygg kaffe bryggkaffe bryggd kaffe bryggkaffe bryggkaffen bryggkaffe -
Save and return to your flow.
Get user name
Lastly, we have the final transition, which includes 'PERSON.NER' as a Match.
- Select the transition called 'Get user name' and rename it to
Användaren svarar med namn
. - Leave the condition as it is. For languages without language resources we suggest you replace 'PERSON.NER' with the Language Object created in the earlier steps here.
Localize the outputs
Next up we need to localize the outputs found inside the flow.
Ask for coffee type
- Select the first output node called 'Ask for coffee type'. This will open the output configuration panel.
- Rename the output node to
Fråga om kaffesort
. - Locate the 'Answers' field and replace the answer with
Ok, vilket kaffe vill du beställa?
. - There is also a Resume Prompt that should be replaced with
Vi fortsätter med din beställning. Vilket kaffe vill du ha?
.
Ask for name
- Select the third output node called 'Ask for name'. This will open the output configuration panel.
- Rename the output node to
Fråga om namn
. - Locate the 'Answers' field and replace the answer with
Ok, vilket namn ska jag skriva ner för beställningen?
.
Summarize Order
Last in line is the final output node where the user's order is summarized.
- Select the third output node called 'Summarize Order'. This will open the output configuration panel.
- Rename the output node
Sammanfatta order
. - Locate the 'Answers' field and replace the answer with
Tack för din beställning, ${userNameForOrder}. En ${orderedCoffeeType} är redo att hämtas om fem minuter.
. - Save your flow.
Try it Out
You are now done with the key flows in your first localization of the whole solution. Let us test it in Tryout!
- Open the 'Tryout' window located in the 'Solution' section.
- Let us try the flows we just localized. In this case, you can test your flow by trying out the following examples:
Vad för kaffeutbud har ni?
Jag vill ha en bryggkaffe
Test Yourself
Go ahead and include more flows to localize from the original 'Longberry Baristas'. Use your local solution language when following the steps above.