Multilingual agents

Dialogflow supports many languages. For the complete list, see the languages reference page. The language you choose when creating an agent is set as the default language, and you can add additional languages.

Root and locale-specific languages

There are two categories of languages:

  • Root languages: These are languages like English (en) that do not specify a locale.
  • Locale-specific languages: These are languages like English-US (en-US) that do specify a locale as a specific region or country.

Some languages act as both root and locale-specific. There are significant differences between locales for these languages, so the locales cannot share a common root language. Examples:

  • Chinese-Cantonese (zh-HK)
  • Chinese-Simplified (zh-CN)
  • Chinese-Traditional (zh-TW)
  • Portuguese-Brazil (pt-BR)
  • Portuguese-Portugal (pt)

You should primarily design your agent for root languages, and only customize for locale-specific languages as needed.

Add a language

To add a language or locale with the Dialogflow Console:

  1. Open the Dialogflow CX Console.
  2. Choose the Google Cloud project for the agent.
  3. Find the agent in the list.
  4. Click the agent display name.
  5. Click Agent Settings.
  6. Click the Languages tab.
  7. Add or remove languages as needed.
  8. Click Save.

Language-specific data

Most agent data is common for all languages of a multilingual agent. However, text used to interact with an end-user is language-specific. When building a multilingual agent, you must supply this language-specific data for each language. When you select a language from the console or provide a language to the API, you can access this language-specific data for the given language. The following is a complete list of language-specific data:

To access language-specific data with the console, click the language button at the top of the console.

Select language screenshot

For example, the size entity type below is used for ordering t-shirts. The agent was originally configured in English, so the entity has entries like "S" with the synonym "small". When Spanish is added as a language, the entity is created by Dialogflow for the new language, but you need to supply entity entries in Spanish.

Entity screenshot

To access language-specific data with the API, provide the languageCode parameter when getting, creating, or updating EntityType, Intent, or Page types.

Select a protocol and version for the EntityType reference:

Protocol V3 V3beta1
REST EntityType resource EntityType resource
RPC EntityType interface EntityType interface
C++ EntityTypesClient Not available
C# EntityTypesClient Not available
Go EntityTypesClient Not available
Java EntityTypesClient EntityTypesClient
Node.js EntityTypesClient EntityTypesClient
PHP Not available Not available
Python EntityTypesClient EntityTypesClient
Ruby Not available Not available

Select a protocol and version for the Intent reference:

Protocol V3 V3beta1
REST Intent resource Intent resource
RPC Intent interface Intent interface
C++ IntentsClient Not available
C# IntentsClient Not available
Go IntentsClient Not available
Java IntentsClient IntentsClient
Node.js IntentsClient IntentsClient
PHP Not available Not available
Python IntentsClient IntentsClient
Ruby Not available Not available

Select a protocol and version for the Page reference:

Protocol V3 V3beta1
REST Page resource Page resource
RPC Page interface Page interface
C++ PagesClient Not available
C# PagesClient Not available
Go PagesClient Not available
Java PagesClient PagesClient
Node.js PagesClient PagesClient
PHP Not available Not available
Python PagesClient PagesClient
Ruby Not available Not available

You must make separate API calls for each language to access all language-specific data. If your API calls update language-generic data, that data is updated for all languages.

Test in the simulator

When using the simulator, choose the language you want to use by selecting it below the agent name.

Supply a language using the API

When sending requests via the API, set the queryInput.languageCode field of the detectIntent method. For more information, see the Sessions type.

Select a protocol and version for the Session reference:

Protocol V3 V3beta1
REST Session resource Session resource
RPC Session interface Session interface
C++ SessionsClient Not available
C# SessionsClient Not available
Go SessionsClient Not available
Java SessionsClient SessionsClient
Node.js SessionsClient SessionsClient
PHP Not available Not available
Python SessionsClient SessionsClient
Ruby Not available Not available

Language auto detection

If the end-user's query language differs from the language specified in the request, Dialogflow can detect it and automatically switch to the end-user's language. See the language reference page for a list of languages available for this feature. The LanguageInfo field in a WebhookRequest identifies the input language, resolved language, and confidence score when language detection is enabled.

Enable language auto detection

You must enable language auto detection at both the agent and flow levels.

  1. Go to Agent settings and select the Languages tab.

  2. Check the box next to Enable language auto detection and switching to enable this feature for the agent. Click Save to save your changes.

  3. Select a flow and navigate to Flow settings. In the flow settings panel, check the box next to Enable language auto detection and switching.

  4. In the Languages drop-down menu, select the languages you want Dialogflow to be able to respond in. Make sure that you only select languages that are supported by the language auto detect feature.

  5. Click Save to save your changes.

Requests that do not supply an agent's language

When Dialogflow receives a request that does not supply a language supported by the agent, the following rules apply:

  • When a request does not supply a language, Dialogflow automatically determines the input language and responds in that language if automatic language detection is enabled. If automatic language detection is disabled, Dialogflow handles the request using the default language.
  • When a request supplies a locale-specific language that is not supported by the agent, but the associated root language is supported by the agent, Dialogflow handles the request using the root language.
  • System entity extraction is an exception to the previous rule. System entity extraction uses the supplied locale-specific language, even if the locale-specific language is not supported by the agent.

Integrations

Agent interactions through text-based integrations only use the default language of the agent.