Integration Guide
Language Selector Integration Guide
Below is the guide to propagate the language you select on your webpage into the agent.
Note: The language must be a valid ISO 639-1 code with a country code.
Example formats:
es-ES
da-DE
it-IT
ja-JP
ko-KR
pt-BR
STATE 1: Agent is already open
If your webpage has a language selector and does not reload when the language is changed, you can directly pass the selected language into the agent via the postMessage
API.
You should see the agent's language update immediately. Additionally, you’ll receive a notification event emitted by the agent, which you can listen for like this:
STATE 2: Language is selected before agent is opened
If the language is chosen before the agent is opened, or your page reloads after selecting the language, you’ll need to wait until the agent has loaded before posting the language.
You can do this by attaching a listener to the element that opens the agent (typically a button):
Tip: If the agent is still loading, it may not receive the event.
You can work around this by using setTimeout
or setInterval
to retry sending the message until you receive the "notification language-selected"
event — then clear the interval.