Watson Assistant: Identifying Languages
One of the user behaviors that you might notice when your virtual assistant is live in production, is that users sometimes try to ask questions in a different language which your assistant doesn’t recognize.
This behavior might be because the user thinks it can answer in multiple languages (you might be offering different assistants for each language) or just trying to trick your bot. What will happen is that your assistant will fail to answer or even give an irrelevant response (makes it look stupid).
With the help of Watson Language Translator service and Cloud Functions to help integrate both services, you can identify the language in which the user asked his/her question and be able to decide accordingly. Whether to refuse to respond but acknowledge that the user is speaking in a different language or point the user to another assistant to help.
Cloud Functions
To do this, you will first need to deploy a Watson Language Translator service from IBM Cloud and Cloud Functions.
Cloud Functions offers various packages to help you integrate as fast as possible with the available Watson services. You can install the Watson Language Translator package easily by following these steps.
If you successfully completed these steps, you will be able to see the installed packages on your Actions page.
The Language Translator package comes with different actions that you can use in other scenarios, but to correct the user behavior noticed you can use the ‘identify’ action.
This action will expect the following parameters to be able to identify a language. You can check the service’s API documentation here.
Watson Assistant
Now from Watson Assistant’s side, you will need to connect to the installed Cloud Functions action. To do that you need to get the Cloud Functions API key and paste it in Watson Assistant.
Next, add your credentials to Watson Assistant…
This part is up to your design, but as an example I will add a node to check if the text sent by the user is in English or not.
The next node will then check the response stored in “$result_variable” and make sure if the text is in English or not.
Now your virtual assistant will be able to identify the language of the user’s input as follows.
It all goes back to your conversational design and how you want to tackle this behavior. This is the Watson Assistant Skill I used for this tutorial.