---
title: "Setting up a Translation System Using Contentstack Webhooks, AWS Lambda, and XTM Machine Translation"
description: "Translate content using Contentstack Webhook , AWS Lambda, and XTM Machine Translation"
url: "https://www.contentstack.com/docs/developers/how-to-guides/setting-up-a-translation-system-using-contentstack-webhooks-aws-lambda-and-xtm-machine-translation"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-08-11"
---

# Setting up a Translation System Using Contentstack Webhooks, AWS Lambda, and XTM Machine Translation

XTM is a cloud-based content translation management solution. With its integrated CAT tool, it helps organizations to streamline complex localization processes and maximize translation reuse.

Its scalable and flexible architecture allows it to integrate with apps such as Contentstack seamlessly. In this guide, we will go through the steps required to set up a language translation system using Contentstack Webhooks, AWS Lambda, and XTM machine translation.

**Process overview**: We will first set up the essentials in Contentstack, such as creating a stack and adding a few languages (locales). We will then create a workflow and add four stages to it. We will add a template in XTM, configure it for machine translation, and then set up our lambda function to help us create the bridge between Contenstack and XTM for translation.

We'll also set up a webhook such that when the workflow stage in an entry changes (let's say from **Draft** to **Send for Translation**), the webhook will issue a trigger to our lambda function. It will initiate the translation process with XTM by creating a JSON file of our entry and uploading it to the XTM project.

The content will get translated and our lambda function will update the entry with the translated content and change its workflow stage to “Review.”

## Prerequisites

*   [AWS account](https://aws.amazon.com/) and access to AWS Lambda, AWS API Gateway, and AWS IAM
*   [Contentstack account](https://www.contentstack.com/login)
*   [XTM Project Manager account](https://www.xtm-cloud.com/saas-manager/#!/login)
*   Working knowledge of [AWS Lambda and API Gateways](https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html)

**Note**: For this example, we assume that you already have a Project Manager and a Linguist account in XTM that will help you create projects and translations in XTM. If not, please sign up and get your account created. You will receive all the details required to log in to XTM such as URL, username, password, and so on.

## Steps for Execution

Here are the steps required to set up this translation system:

1.  [Set up and configure your project template in XTM](#set-up-and-configure-your-project-template-in-xtm)
2.  [Set up the essentials in Contentstack](#set-up-the-essentials-in-contentstack)
3.  [Set up the workflow for translation in Contentstack](#set-up-the-workflow-for-translation-in-contentstack)
4.  [Set up the AWS lambda functions for translation](#set-up-the-aws-lambda-function)
5.  [Trigger a webhook to initiate translation](#trigger-a-webhook-to-initiate-translation)
6.  [Try out the steps](#try-out-the-steps)

Let's get started!

1.  ### Set up and Configure Your Project Template in XTM
    
    For this exercise, you need a project manager (or an admin) account with XTM so that you can create templates in the XTM app. You can sign up with one of their plans and get started with setting up your account.
    
    #### Activate Machine Translation in XTM
    
    Assuming that you have a project manager account in XTM and have logged in the app, the first thing that you need to do is to activate machine translation in XTM. To do this, follow the steps given below:
    
    1.  Once you [log in](https://api-test.xtm-intl.com/saas-manager/login.jsp#!/login) to the XTM app, you will be on the **Projects** page. Click on the **Settings** gear icon as shown below:  
          
        ![XTM\_settings.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/bltb76428480ce041ff/608fe4533aa0431020f5ec4d/XTM_settings.png)  
          
        
    2.  On the page that opens, click on the **Settings** option.
    3.  From the left navigation panel, click on **Translation** as shown below:  
          
        ![XTM\_Translation.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/blt7461f8b5dbe6a9a3/608fe4a41671db1046c1a000/XTM_Translation.png)  
          
        
    4.  Then, select the **Machine translation** option from the menu and select your preferred MT engines. For our example, we have used **Amazon Translate** as shown below:  
          
        ![AWS\_Selected.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/blt95dba2251025400d/608fe4c9f07013101daf2379/AWS_Selected.png)  
          
        
        **Note**: You can select the MT engine you like but ensure you have the necessary keys for using that engine. You will need to enter those keys in the next step.
        
    5.  Leave the default options under the **General** options section untouched. 
    6.  Scroll down to the **Amazon Translate** section (because we selected AWS Translate, if you select a different provider such as Google Translate, this section will change to Google Translate and you need to provide the necessary details specific to Google Translate), and keep the **Default setting** option checked.
    7.  Provide **AWS access key ID**, **AWS secret access key**, and click on **Synchronize**. You will get a message when it synchronizes successfully as shown below. Click on **Save**.  
          
        ![AWS\_Translate\_keys\_added.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/bltadd067e5fecbaf39/608fe57c3aa0431020f5ec53/AWS_Translate_keys_added.png)  
          
        
    
    We have now activated the machine translation. Let's now go ahead and create a project in XTM.
    
    #### Create a Project Template in XTM
    
    To create the project template in XTM, follow the steps given below:
    
    1.  From the top menu, click on the **Projects** tab and then **Add project** as shown below:  
          
        ![Add\_project\_in\_XTM.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/blte4b1a8b5b525ca77/608fe62d71e79f1024c9a3c2/Add_project_in_XTM.png)  
          
        
    2.  On the page that opens, under the **General information** section, the **Customer name** is auto-populated. You can provide a new name if you want and leave the remaining options blank.
    3.  Under the **Translation** section, provide the **Source language** (English USA in our example) and **Target languages** \[Chinese (simplified), French (France) in our example\]. You can add more languages if you like and leave the other options unchanged.
    4.  Leave the options Inside the **Workflow** and **Settings** sections to their default value.
    5.  Inside the **Machine translation** section, check the **Use Amazon machine translation** option, to enable machine translation of your content.  
          
        Leave other options to their default values and click on the **Save as template** button.  
          
        
    6.  The **Create template** modal will open. Provide a **Name** to your template and an optional **Description**. You can leave the default **Customer** specific option selected for **Type** as shown below:  
          
        ![New\_MT\_Template.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/blt6506865eeace1cf5/608fe6e61022211019ccc6ff/New_MT_Template.png)  
          
        
    7.  Click on the **Save** button and you will get a success message upon creation. Click on **Close** to close the **Create** **template** modal.
    8.  Your template is now ready. Go to the **Templates** option, next to **Project list**, and you will see the template that you just created listed.
    9.  Now hover over the "i" icon to the right corresponding to your template and you should be able to view the template ID. Make a note of it.  
          
        ![Template\_ID.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/blt0eee270da0b88ecf/608fe7412d1d2210321940af/Template_ID.png)  
          
        
    
    The XTM template is now ready. Similarly, you can create multiple templates for your project. We have created a couple of templates for the purpose of this exercise. We will require the template IDs while creating a content type in Contentstack.
    
    Let's move ahead and set up the essentials in Contentstack.
    
2.  ### Set up the Essentials in Contentstack
    
    To set up the essentials, [log in to your Contentstack account](https://app.contentstack.com/#!/login) and follow the steps given below: 
    
    1.  [Create a stack](/docs/headless-cms/create-a-new-stack), add a [content type](/docs/headless-cms/create-a-content-type) (for our exercise, we have created a [Single Content Type](/docs/headless-cms/single-vs-multiple-content-types#single) named **XTM**).  
          
        In our example, we have used “title,” “url,” “single\_line (named Heading),” “rich\_text\_editor (named Body)”, and Select fields. We will translate the content of these fields. Content of special fields such as File, Boolean, Reference, Select will not be translated.![XTM\_Machine\_1\_no\_highlight.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/blt17af0e24cb3490c2/60dcb6b99648f1650fe19b8b/XTM_Machine_1_no_highlight.png)  
          
          
          
        The Select field that we have added (named **XTM Project Templates** in the above screenshot) is where you will add the template IDs you created in the above step. Ensure that the ID of this select field is the same shown in the screenshot below (xtm\_project\_templates).  
          
        ![XTM\_Machine\_2\_highlighted.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/bltf2703d70cd7e903e/60dcb6d2063bbd63cd739894/XTM_Machine_2_highlighted.png)  
          
        If you are using our code example, ensure that the format of adding the IDs is similar to the one shown below:  
          
        ![XTM\_Machine\_3\_highlighted.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/blt3dba92169eade438/60dcb6e14763af56bad5bb95/XTM_Machine_3_highlighted.png)  
          
        
        **Note**: You can add Template-33928, Template-30684, and so on so that it's easier for you to identify and select the required template in the entry. We will use the ID separated by a hyphen for identifying them in the entry page.
        
    2.  [Create a management token](/docs/headless-cms/generate-a-management-token) for your stack which we will use later while setting up the lambda function.
    3.  Next, [create languages](/docs/headless-cms/add-a-language) (locales) in your content type (XTM). In our example, we have added a few languages:  
          
        English \[en-us\] which is the source and our [master language](/docs/headless-cms/set-the-master-language)  
        Chinese - China \[zh-cn\] is another language  
        French - France \[fr-fr\] which will be our target language  
          
        
        **Note**: Ensure that the languages you add are [supported by XTM](https://xtm-cloud.atlassian.net/wiki/spaces/XKB/overview). Also, the language code for the target languages that you add should be the same in Contentstack and XTM.
        
    
    With these steps, we have set up the essentials in Contentstack. Let's now move ahead with creating a workflow.
    
3.  ### Set up the Workflow for Translation in Contentstack
    
    To set up workflows for the translation process, perform the following steps:
    
    1.  Hover over the **Settings** gear icon and click on **Workflows**.
    2.  On the **Workflow Settings** page, click on **\+ ADD WORKFLOW**.
    3.  Provide a suitable name to your workflow and an optional description.
    4.  Under the **Scope** option, select if this workflow should be applied to **All Content Types** or **Specific Content Type(s)**. For our example, we will select the **Specific Content Types(s)** option and then select our content type, **XTM**, and then click on **Ad**d as shown below: ![XTM\_Machine\_4\_no\_highlight.gif](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/bltb44901c3ccac2df5/60dcb71c1558ad5582219791/XTM_Machine_4_no_highlight.gif)  
          
          
          
        
    5.  Inside the **WORKFLOW STAGES** option, [add four stages](/docs/headless-cms/add-workflows-and-stages#add-workflow-stages) (for example, Draft, Send for Translation, Review, and Completed).  
          
        
        **Additional resource**: Learn more about workflow and its stages, refer to the [set up workflows](/docs/headless-cms/add-workflows-and-stages) guide.
        
    6.  Lastly, click on the **Enable Workflow** checkbox and then on the **Save** button.   
          
        
    
    With these steps, our workflow is ready. When the editor changes the workflow stage from “Draft” to “Send for Translation,” the webhook will be triggered and call the lambda function (we will set these up later in the guide).
    
    Now go back to the **Workflow Settings** page and note down the **WORKFLOW ID** as shown below (we will need this ID later when we setup our lambda function):
    
    ![XTM\_Machine\_5\_highlighted.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/blt496797e849a3287e/60dcb72796b48063c7074078/XTM_Machine_5_highlighted.png)
    
      
    
    With these steps, we have created our workflow. Let's now move ahead and set up lambda functions.
    
4.  ### Set up the AWS Lambda Function
    
    The job of the lambda function is to take the content of the entry and send it to the XTM for translation. Once the translated content is ready in the required language, it updates the locale in the entry along with changing the workflow stage to "Review".
    
    To create this function, follow the steps given below:
    
    1.  Log in to your [AWS Management Console](https://aws.amazon.com/console/), select **Lambda** from the **Services** list.
    2.  Click on the **Create function** button and then the **Author from Scratch** option.
    3.  Provide a name to your lambda function inside the **Function name** field, select **Node.js 14.x** as your **Runtime language**, and click on the **Create function** button.
    4.  You will get a success message on creation of the lambda function. For this exercise, we have created the sample code for the lambda functions. If Extensions are part of your plan, contact our [Support](mailto:support@contentstack.com) team to get the code for the extension.
    5.  Once you get the code, open command prompt and move inside the folder named **contentstack-XTM-integration**.
        1.  Then, install the required dependencies by running the following command:  
              
            
            ```
            npm install
            ```
            
              
            
        2.  Now, run the following command to create a zip file:  
              
            
            ```
            npm run build
            ```
            
              
            
        3.  With the above command, you will get a zipped file named **xtm-mt.zip**. We will be uploading this file to our Lambda function.  
              
            
            **Note**: The **npm run build** command we discussed above will work for Mac and Linux users. If you are on Windows, the **npm build** command may not work. In that case, after installing the dependencies, you will have to manually zip the code file, name it **xtm-mt.zip**, and upload it to your Lambda function.
            
    6.  Now in your AWS console, inside the **Code source** section, click on the **Upload from** dropdown and select **.zip file**.
    7.  In the **Upload a .zip file** modal, click on the **Upload** button, move to the folder where you have placed the zipped above (discussed above), and select the zip file named **xtm-mt.zip**. Then, click on **Save**.
    8.  In the **Runtime settings** option, keep **Handler** as **index.handler**.
    9.  Scroll up and select the **Configuration** tab. Inside the **General configuration** section, increase the function timeout duration to 30 seconds by clicking on **Edit**.
    10.  Staying inside the **Configuration** tab, click on the **Environment variable** option on the left and add the following variables inside it by clicking on **Edit** and then **Add environment**:  
           
         ![EV\_lambda\_function.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/bltbf8e813654c1ed4d/608feeba1671db1046c1a03e/EV_lambda_function.png)  
           
         **api\_key**: <<Stack API Key>>  
         **management\_token**: <<Stack Management Token>>  
         **master\_locale**: en-us  
         **base\_url**: https://api.contentstack.io/v3/ (for Europe region, enter **base\_url**: https://eu-api.contentstack.com/v3/, for Azure NA region, enter **base\_url** value as: https://azure-na-api.contentstack.com/v3/, for Azure EU region, enter **base\_url** value as: https://azure-eu-api.contentstack.com/v3/)  
         for GCP NA region, enter **base\_url** value as: https://gcp-na-api.contentstack.com/v3/), and for GCP EU region, enter **base\_url** value as: https://gcp-eu-api.contentstack.com/v3/)  
         **customer\_id**: 23  
         **user\_company\_name**: <<XTM User company that you created while setting up the account>>  
         **user\_identifier**: 20  
         **workflow\_uid**: <<Your workflow UID generated above>>  
         **xtm\_base\_url**: https://api-test.xtm-intl.com//project-manager-api-rest/  
         **xtm\_password**: <<Your XTM password you use for login>>  
           
         
         **Note**: To get the customer\_id, click on the **Customers** tab at the top (next to **Projects**) in XTM. Then, hover over the "i" icon at the right to get it. Similarly, to get the user\_identifier key, click on the **Users** tab at the top and then hover over the "i" icon and note down the ID.  
         
    11.  Once you have added the variables, click on **Save**.
    12.  Within **Configuration**, click on **General configuration** and increase the timeout value (by clicking on **Edit**) from 3 to 30 seconds and then save it.
    13.  Your lambda function is now ready. Let's add a trigger (API Gateway) for this lambda function. To do this, scroll up to the **Function overview** section and click on **\+ Add trigger**.
    14.  On the **Trigger configuration** screen, select **API Gateway** from the **Select a trigger** dropdown.
    15.  From the **API** dropdown, select **Create an API**. Then, select **REST API** inside the **API type** block. Select **Open** from the **Security** dropdown and click on **Add**.  
           
         ![Trigger\_config.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/blt5fb44f1740992d74/608ff2ab162d47104df4a98a/Trigger_config.png)  
           
         
    16.  An API for your lambda function is now created. Inside the **Triggers** section, you will see the **Details** link. Click on it and you will find your API endpoint. Make a note of it as we will need it while setting up our webhook in Contentstack.  
           
         ![API\_Gateway\_for\_LF\_in\_Human\_Translation.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/blt2503bc9cb6e41de2/608ff2e13aa0431020f5ec9d/API_Gateway_for_LF_in_Human_Translation.png)  
           
         
    
    Let's now move ahead and create a webhook that will invoke the lambda function once the workflow stage changes to **Send for Translation**.
    
5.  ### Trigger a Webhook to Initiate Translation
    
    To create and [set up a webhook](/docs/headless-cms/create-a-webhook) in Contentstack, log in to your Contentstack account and perform the following steps:
    
    1.  Hover over the **Settings** gear icon, click on **Webhooks**, and on the **Webhooks** page, click on **\+ New Webhook**.
    2.  On the **Create Webhook** page, fill up the **Name** field (for example, XTM Translation).
    3.  In the **URL to notify** field, enter the URL (the API endpoint of the first lambda function) that you generated in the previous step.
    4.  Scroll down to the **When** section for creating a trigger for the webhook as shown below:![XTM\_Machine\_6\_no\_highlight.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/blt2e97603438e30e03/60dcb73e9ef42b4859271959/XTM_Machine_6_no_highlight.png)  
          
          
        
    5.  Ensure to check the **Enable Webhook** option and click on the **Save** button to save your settings.
    
    With these steps, we have completed the entire set up and now we are ready to try it out.
    
6.  ### Try out the Steps
    
    We are now ready to test the setup.
    
    1.  [Create an entry](/docs/headless-cms/create-an-entry) inside the content type (in the en-us locale). Select the XTM template and after you have added the details in other fields, change the workflow stage by selecting **Send for Translation** from the **WORKFLOW DETAILS** section on the right side.  
          
        
        **Note**: You can send content from your master locale only to XTM for translation. If you send the data from other locales, it will not be translated and the webhook will throw an error.
        
    2.  This will trigger the webhook and it will invoke the lambda function. The lambda function will generate the JSON file of the entry and place it in the XTM account for translation.
    3.  Now go to your entry in Contentstack and select the target locale from the dropdown (French \[France\] in our example). You will see the translated content and the workflow stage change to **Review**.