Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  DetectLanguage funtion

    Posted 28 days ago

    I'm having some issues with DetectLanguage function. Does someone knows if it required some number of words to recognize a language? I\m using it for email and whatsapp, and for an example if someone send a messege in whatsapp with the body only "Bounjour" it was not recognized as French, and for me that's really weird, or in a email with majority of the body in French but with a signature in english the language was not recognized. I checked in the execution history and the function detectlanguage(email.message.body, "") returned "", so it means that the language was not detected.

    Any ideas or suggestions?


    #Architect

    ------------------------------
    Breno Silva
    NA
    ------------------------------


  • 2.  RE: DetectLanguage funtion

    Posted 28 days ago
    Edited by Luiz Rosa 28 days ago

    Hi Breno Silva

    My suggestion is to split the text into smaller parts, run DetectLanguage in a loop, count which language appears most, and use that as the dominant one. If none are recognized, use a default language.

    Another alternative would be to use a Data Action function to create Node.js code that uses a library capable of detecting the language and returning that information for you.


    ------------------------------
    Luiz Rosa
    Full stack developer
    ------------------------------