Detect language used in a HubSpot property /
with Operations Hub


In the world of customer relationship management, HubSpot has emerged as a powerhouse for managing and automating customer interactions. However, when dealing with multilingual content and global audiences, it's crucial to employ tools that can identify the language of your customers effectively. One such tool is Operations Hub pro with this language detection Custom Coded Action, which can be seamlessly integrated into HubSpot workflows to enhance customer communication and content personalization.


How language detect works in HubSpot ?

Text_LanguageDetect is a PHP library renowned for its language detection capabilities. Although natively designed for PHP, you can harness its power within your HubSpot workflows using a custom code block in JavaScript. Let’s explore how this library can benefit your HubSpot environment.

Language Identification

The primary feature of This Custom Coded Action is its accurate language identification. In a CRM like HubSpot, where interactions occur in multiple languages, this Custom Coded Action can automatically categorize and sort text content based on language. This facilitates more targeted and relevant communication, ensuring that your customers receive information in their preferred language.

Personalized Customer Communication

HubSpot’s strength lies in personalizing customer interactions. By incorporating this Custom Coded Action you can take personalization to the next level. Create workflows that adapt based on detected language, sending emails, responses, or content in the language your customers prefer. This enhancement improves the overall customer experience, making it more engaging and satisfying.

Language-Specific Automation

Use this Custom Coded Action to trigger automation based on language. For instance, you can set up workflows that route customer inquiries to language-specific support teams. This ensures that your customers receive support and information in their preferred language, enhancing engagement and satisfaction.

Integration with HubSpot Workflows

Integrating this Custom Coded action into your HubSpot workflows is seamless using the custom code block feature. This integration empowers you to create dynamic, language-aware processes within your CRM.

This Custom Coded action is a powerful tool for enhancing your HubSpot CRM when dealing with multilingual content and global customer interactions. By accurately identifying languages, personalizing customer communication, automating language-specific processes, you can provide a more tailored and effective customer experience.

Deploying Language Detection Code in HubSpot

Follow these steps to integrate the language detection functionality into your CRM:

1. Create a Blank Workflow

Start by creating a new workflow in your HubSpot account. This workflow will be the foundation for implementing the language detection code.

2. Create a Trigger with a Filter

Within your workflow, establish a trigger with a filter to specify when language detection should occur. For instance, if you want to detect the language based on a description, you can set a filter such as « Description is known. » This filter will determine when this custom code will be executed.

3. Add a Custom Code Block

To integrate language detection into your workflow, you’ll need to use a custom code block. This is where you’ll include the JavaScript code responsible for language detection.

4. Include Properties in the Code

Within the custom code block, you should define the properties you want to analyze. For example, if you’re detecting language based on a product description, you might use a variable like textToAnalyze to represent the description text.

5. Copy Code from the Repository

To make this integration even more straightforward, we’ve provided a repository with pre-compiled code for language detection. You can access this repository at github Detect-language.

Inside the repository, navigate to the dist folder and copy the contents. These pre-compiled files contain the necessary code to execute language detection using this custom code.

6. Set Output Variables

In your custom code block, you need to specify the output variables and their types. For language detection, you typically want to capture the detected language and the confidence level. Define the following variables:

This step ensures that the detected language and the confidence score are made available for use in your HubSpot workflow.

By following these steps, you’ll seamlessly integrate language detection into your HubSpot workflow, enabling you to automate language detection and enhance your CRM’s capabilities for personalized customer communication and content organization.

The source code

Do not copy this code, it’s the source code use the code in the /dist folder of this repo : github Detect-language.

const LanguageDetect = require('languagedetect');

exports.main = async (event, callback) => {

    const textToAnalyze = event.inputFields.textToAnalyze;

    if (!textToAnalyze) throw new Error('textToAnalyze is not set, are you sure you put textToAnalyze in the "properties to include in code" ? ');

    const lngDetector = new LanguageDetect();

    const languageFound = lngDetector.detect(textToAnalyze,2);

    if(languageFound.length === 0) throw new Error('We failed to indentify the language');

    const [language, confidance]= languageFound[0];

    if(!language) throw new Error('Error when identifing the language');

    if(!confidance) throw new Error('Error when identifing the language no confidance data');

        outputFields: {