Skip to main content


Identifies the text language using the fastText NLP model.


The method accepts an array of strings as the only argument. The method returns an array of ISO language codes that the corresponding texts are written in.

"This is an English sentence.",
"Yy kaa koo",
"Les hommes naissent et demeurent libres et égaux en droits."
]); // => ["en", "fi", "fr"]
The method may return unpredictable results when dealing with strings consisting only of numbers, punctuation, or other special characters, as well as texts in multiple languages at once.

How to use

The following example illustrates how to use the method for routing unrecognized requests.

state: CatchAll
event!: noMatch
$temp.language = $caila.detectLanguage([$parseTree.text])[0]; // Identify the language.
$session.catchAllCounter = $session.catchAllCounter + 1 || 1; // Increment the counter of unrecognized requests.
# If the client does not speak English, transfer to the agent immediately.
# If they do, transfer to the agent as soon as the counter exceeds the threshold.
if: $temp.language !== "en" || $session.catchAllCounter > 3
go!: /Switch
a: I’m sorry, I didn’t catch that. Could you repeat, please?
a: I didn’t quite get it. Would you mind repeating that for me?
a: Could you say that again? I can’t hear you very well.