Hi, I'm trying to detect what language is set on w...
# 🌎general
Hi, I'm trying to detect what language is set on website via html lang attribute, set translator agent accordingly and send user to the appropriate workflow, but somehow I can't do it. I wrote code for all languages in js (8), it didn't work so I simplified the code a lot, now it looks like this:
Copy code
let websiteLanguage = document.documentElement.lang;

  // Set Translator Agent language and redirect to workflow
  if (websiteLanguage === "cs-CZ") {
    user.TranslatorAgent.language = "cz";
    // await workflow.cz(); // Redirect to 'cz' workflow

  // Log the detected language for debugging
  console.log("Website Language:", websiteLanguage);
is there any way to achieve such a function? can i even write stuff in javascript there? I'm starting to get a little confused. these are the logs:
Hey, this code won't work because the bot doesn't have access to the document variable, it doesn't run a browser like a website does. You could achieve that on the Webchat channel with a updated version of this code
But ideally you would ask the user what language they speak