Developers

Unexpected languages

Integration options when an unexpected language is detected

 
Note

For the Knowledge API to detect the language of a user intent, your Inbenta solution has to include multiple Inbenta instances in different languages.

Inbenta's language detection can only recognize the languages associated with your instances. If you need other languages to be detected as well, you may need to use another language detection system from a third-party provider.

Option 1: Redirect the user to the proper site (recommended by Inbenta)

Even if the search returns an instance of the language, a proper implementation would be to show a specific message to your users that redirects them to the Help Center in this language. That is particularly recommended for clients who use the JS Client.

This message can even be set as a parameter and bypass the user question. This way, the implementation in the other language automatically shows the results of the user question.

       

There are several possible methods to present this message to the users. 

Method 1: Use Language Detected Label in the SDK (recommended by Inbenta for SDK integrations)

The easiest way to redirect the user is to show a default label called "DIFFERENT_LANGUAGE_DETECTED". This label already exists in the SDK. Its default value is "It seems you are asking a question in a language we did not expect. Please look for the language you need in the menu.".

You can configure this label once the SDK is initialized, and use it at any moment with:

 sdk.client.labels.DIFFERENT_LANGUAGE_DETECTED
 

The advantage of this option is that is really simple to implement and does not send any extra request to the API. 

The drawback is that any change in the message requires a modification of the code deployed to production.

Method 2: Create specific contents in the KB

Create a content in Knowledge Base (either one for all languages, or one per language) that contains your message that the engine detected a different language, and how the user should proceed.

  • If you use the SDK, upon detection of an unexpected language, use the results interceptor to retrieve the specific content using the JS Client function "getContentById".
  • If you use the API, upon detection of an unexpected language, use the /contents/{contentId} endpoint to retrieve the specific content.

The advantage of this option is that you can change the message you show your users without changing the code deployed in production. 

The drawback are:

  • it requires an additional API request to implement, and
  • you need to create a content for each possible language to show the message in the detected language.
Method 3: Create messages in Extra Info in your Knowledge instance (not recommended)

Create an "Extra Info" in your Knowledge instance in Knowledge > Extra Info. Write the message you want to show when a different language is detected. You can organize messages by language if you want.

  • If you use the SDK, upon detection of an unexpected language, use the results interceptor to retrieve the specific message from the Extra Info using the JS-client function "getData".
  • If you use the API, upon detection of an unexpected language, use the /app/data/{dataId} to retrieve the specific message from the Extra Info.

The advantage of this option is that you can change the message you show your users without changing the code deployed in production. 

The drawback is that it requires an additional API request to implement. However, if you receive a large number of user questions in an unexpected language, it is possible to cache this "Extra Info" data to reduce the number of requests.

Option 2: Automatically redirect the user question to another instance

if you have an instance in the language that was detected, you can use the API to redirect the user question automatically to this other instance, as illustrated in the diagram below. Remember that this may delay the request, especially if there is no prior authorization to the other instance.

Note: In the same way the results of a user question are cached, you must also cache the language received for each user question to reduce the number of requests to the API.

You can do the same implementation using the JS Client. However, this means that you must initialize a JS Client for each instance on the same site. Make sure to handle the display and tracking of these different instances accordingly.