Skip to content

Automations

This module allows you to add custom automations step.

Sample

index.js
const crowdinModule = require('@crowdin/app-project-module');
const app = crowdinModule.express();
const configuration = {
baseUrl: 'https://123.ngrok.io',
clientId: 'clientId',
clientSecret: 'clientSecret',
authenticationType: 'crowdin_agent',
agent: {
username: 'sample-actions'
},
name: 'Sample App',
identifier: 'sample-app',
description: 'Sample App description',
dbFolder: __dirname,
imagePath: __dirname + '/' + 'logo.png',
automationAction: [
{
name: 'List Files',
description: 'Returns project files list',
outputSchema: {
type: 'object',
properties: {
data: {
type: 'array',
items: {
type: 'object',
properties: {
data: {
type: 'object',
properties: {
id: {
type: 'integer'
},
projectId: {
type: 'integer'
},
branchId: {
type: ['integer', 'null']
},
directoryId: {
type: ['integer', 'null']
},
name: {
type: 'string'
},
title: {
type: 'string'
},
context: {
type: 'string'
},
type: {
type: 'string'
},
path: {
type: 'string'
},
status: {
type: 'string'
},
revisionId: {
type: 'integer'
},
priority: {
type: 'string'
},
importOptions: {
type: 'object',
properties: {
importTranslations: {
type: 'boolean'
},
firstLineContainsHeader: {
type: 'boolean'
},
contentSegmentation: {
type: 'boolean'
},
customSegmentation: {
type: 'boolean'
},
scheme: {
type: 'object',
properties: {
identifier: {
type: 'integer'
},
sourcePhrase: {
type: 'integer'
}
},
required: ['identifier', 'sourcePhrase']
}
},
required: ['importTranslations', 'firstLineContainsHeader', 'contentSegmentation', 'customSegmentation', 'scheme']
},
exportOptions: {
type: 'object',
properties: {
exportPattern: {
type: 'string'
}
},
required: ['exportPattern']
},
excludedTargetLanguages: {
type: 'array',
items: {
type: 'string'
}
},
parserVersion: {
type: 'integer'
},
createdAt: {
type: 'string',
format: 'date-time'
},
updatedAt: {
type: 'string',
format: 'date-time'
},
fields: {
type: 'object'
}
},
required: [
'id',
'projectId',
'branchId',
'directoryId',
'name',
'title',
'context',
'type',
'path',
'status',
'revisionId',
'priority',
'importOptions',
'exportOptions',
'excludedTargetLanguages',
'parserVersion',
'createdAt',
'updatedAt',
'fields'
]
}
},
required: ['data']
}
}
},
required: ['data']
},
inputSchema: {
type: 'object',
properties: {
projectId: {
type: 'integer',
title: 'Project ID'
},
branchId: {
type: 'integer',
title: 'Branch ID'
},
directoryId: {
type: 'integer',
title: 'Directory ID'
},
filter: {
type: 'string',
title: 'Filter'
},
recursion: {
type: 'boolean',
title: 'Recursion'
}
},
required: ['projectId']
},
execute: async ({ client, inputData, validationErrors }) => {
if (validationErrors) {
throw new Error(JSON.stringify(validationErrors));
}
const { projectId, ...options } = inputData;
return await client.sourceFilesApi.withFetchAll().listProjectFiles(projectId, {
...options
});
}
}
]
}
const crowdinApp = crowdinModule.addCrowdinEndpoints(app, configuration);
app.listen(3000, () => console.log('Crowdin app started'));

Configuration

  • name - Automation action name.
  • description - Automation action description (optional).
  • invocationWaitMode - Execution mode for the automation action (optional, default is sync). Available values:
  • outputSchema - JSON schema defining the structure of data returned by the automation action. This schema is used to validate and document the output format.
  • inputSchema - JSON schema defining the structure of input parameters expected by the automation action. This schema is used to generate the UI form and validate input data.
  • execute - Function that executes the automation action logic.
  • validateOutputData - Enables output data validation against outputSchema (optional, default is true). Set to false to skip validation when your action returns dynamic or non-schema-conforming data.

execute Function

This function contains the main logic of your automation action and is called when the automation is triggered.

Parameters
  • client - Crowdin API client instance for making API calls.
  • inputData - Input parameters object validated and cleaned according to the inputSchema definition.
  • validationErrors - Validation errors based on inputSchema (if any). If present, you can decide how to handle them (e.g., throw, return an error object, etc.).
  • context - Context object containing information about the current execution context.
  • req - Raw request payload sent to the action (optional).
Return Value

The function should return data that matches the structure defined in outputSchema. The response size is limited to 250KB.

Example
execute: async ({ client, inputData, context, validationErrors, req }) => {
if (validationErrors) {
throw new Error(JSON.stringify(validationErrors));
}
const { projectId, branchId, directoryId, filter, recursion } = inputData;
return await client.sourceFilesApi.withFetchAll().listProjectFiles(projectId, {
branchId,
directoryId,
filter,
recursion
});
}

Input and Output Schemas

Both schemas use JSONata format.

  • inputSchema - Defines the UI form that users will see when configuring the automation action. Specifies input fields, their types, and validation rules.

  • outputSchema - Describes the structure of data that the automation action will return. This helps users understand what they can expect from the automation step and how to use its results in subsequent automation steps.

Note: The response payload is limited to 250KB.