Skip to Content
Technical Articles

How to localize SMB Recast Bot

Dear Colleagues,

Some days ago, Yatsea Li, from Solution Architect team, published an example of how to integrate SAP Business One and SAP Business by Design with SAP Conversational AI. You can find full information on how to deploy it in your own environment and the source code in this link SMB Bot Assistant. You can easily follow the implementation steps to duplicate Yatsea’s bot so 80% of the work would be done.

I’m assuming here you have successfully deployed your bot following Yatsea’s instructions.

With this blog post, I will show how you can translate the intents. This way, when you request information to your ERP, you can do it using your own language instead of using default English.

 


STEP 1

Once you’ve forked Yatsea’s bot you will have to change the default language for your bot. Please click on and select your language in Bot default language field. In my case, I’ve set Portuguese.

You can also rename the bot. In this example, the bot is renamed to: pt-recast-bot.

if you need to add more than one language, you can set the default language as mentioned before and then you can add additional languages for your intents. If this is the case, please click on Train tab and then, when you are in Intents tabs, click on @sales-analysis.

To add a new language, click on icon and select your language. You can repeat this process for additional languages. In my environment I’ve set Spanish and Portuguese.

 


 

STEP 2

As part of the implementation process, explained by Yatsea in his documentation, you have downloaded to your PC the source code of the SMB(B1&ByD) Assistant Bot based on recast.ai. Please navigate to the folder: server → lib → recast. Here you will find two files called measures.csv and dimensions.csv. These files will help you to import your translated texts. Update the files providing your descriptions and the language as shown in next screenshot.

 

When you are done, go back to your bot, navigate to Train → Entities and click on #MEASURE entry. Now, click on icon. Upload the file measures.csv with your translations and select the appropriate import option.

 

Please repeat the same process for dimensions.csv file. Navigate to Train → Entities and click on #DIMENSION entry. Now click on icon. Upload the file measures.csv with your translations and select the appropriate import option.

 


STEP 3

Next step is to provide the expressions for the intents. Please click on Train tab and then on @sales-analysis entry. We can provide them by creating an intents.csv file like the ones used previously as a template or you can add the entries manually.  If you want to know how to create this file, check step 1 from import s CSV file screen.

Let’s try this time to add the expressions manually. First select your language by clicking on the flag icon. Then, go to Add an expression field, start entering your sentences one by one. When you finish writing the sentence just press enter key, then you can write the following one. If you’ve made a mistake, no worries, you can delete it and rewrite it as many times as you need.

After creating some expressions, your bot may start proposing some expressions by showing this:

you can extend it and select the ones you like the most.

 


STEP 4

We are almost there! We are going now to map the intents with the entities within your expressions. You can do it easily:

Click on the entry to expand it. There you will see there are no entities yet. To add them, click on the word you want to assign and then click on the entity.

In the screenshot below I’ve clicked on “clientes” and then on #DIMENSION to assign it. After that I’ve repeated the process all the others.

This is how it should look like:

You can repeat the process with all the sentences you have. This way, the bot will learn about you and the way you request information.

 


STEP 5

To be able to connect from your application to the bot, you will ask to login. If you want to personalize it, you can do it by going back to Train tab and then click on @login-erp intent.

If you click on the English flag icon, you will find the default values for that language. Now you can provide your own ones in your language tab. Instead of using B1 or ByD, here I’m using sap. Now create all the entries you need and once you are done, you have to assign them an intent as we did in previous step. It should look like this:

 


STEP 6

It’s time to check if everything is working properly. Please click on the icon , you can find it on bottom right corner.

 

  1. First ask to login with one of your own sentences:

Wait for the reply. You can also localize this reply by modifying the index.js file. We will see this later.

 

2. Let’s try now our expressions:

You can ask for the information in any of the languages you have already set up your bot for.


STEP 7

To request the information to the ERP, you will need an app and here you have many options. Yatsea explains how to use Facebook messenger. But you can choose any other of the available options.

 

I’ve decided to use Telegram instead. The process steps are available after clicking on Add new Channel icon:

 


STEP 8

We are done!

If you want to localize the reply from the bot, you can do it by changing index.js file located in server folder. Later we will upload it into our SAP Cloud foundry environment.

When editing the index.js file, look for the text provided in bot’s reply and change it for one of your choice:

 


This is how it works for Telegram:

Another cool feature is that you can talk to your app. You don’t have to use the annoying smartphone keyboard:

Cool, isn’t it?

 

I hope you’ve enjoyed reading this blog post. If you want to find more amazing projects, please visit the SMB solution architect github

1 Comment
You must be Logged on to comment or reply to a post.