Skip to content

Chat

The module allows the creation of chat dialogs. The chat is displayed across the UI in a right panel, providing users with a persistent chat experience throughout the application.

index.js
const crowdinModule = require('@crowdin/app-project-module');
const app = crowdinModule.express();
const configuration = {
baseUrl: 'https://123.ngrok.io',
clientId: 'clientId',
clientSecret: 'clientSecret',
name: 'Sample App',
identifier: 'sample-app',
description: 'Sample App description',
dbFolder: __dirname,
imagePath: __dirname + '/' + 'logo.png',
chat: [{
key: 'sample-chat',
uiPath: __dirname + '/' + 'public',
name: 'Sample Chat'
}]
}
const crowdinApp = crowdinModule.addCrowdinEndpoints(app, configuration);
app.listen(3000, () => console.log('Crowdin app started'));

You can use the React JSON Schema forms to define the UI for your chat in a declarative way:

index.js
const configuration = {
baseUrl: 'https://123.ngrok.io',
clientId: 'clientId',
clientSecret: 'clientSecret',
name: 'Sample App',
identifier: 'sample-app',
description: 'Sample App description',
dbFolder: __dirname,
imagePath: __dirname + '/' + 'logo.png',
chat: [{
key: 'sample-chat',
formSchema: {
"title": "Chat settings",
"type": "object",
"properties": {
"welcomeMessage": {
"type": "string",
"title": "Welcome message",
"default": "Hello! How can I help you?"
}
}
},
formUiSchema: {
"ui:submitButtonOptions": {
"submitText": "Save"
}
}
}]
};

You can define chat dialogs:

index.js
const configuration = {
// ... other configuration
chat: [
{
key: 'first-chat',
uiPath: __dirname + '/' + 'public/chat1',
name: 'First Chat'
},
{
key: 'second-chat',
formSchema: {
// ... schema definition
},
name: 'Second Chat'
}
]
};
Parameter
Description
keyUnique identifier for the chat.
nameDisplay name for the chat (optional, defaults to app name).
urlThe relative URL to the content page of the module that will be integrated into the UI.
uiPathFolder where UI of the module is located (js, html, css files).
fileNamePage name (default index.html).
formSchemaJSON schema for the form that will be displayed in the chat.
formUiSchemaJSON schema for the UI of the form that will be displayed in the chat.
formPostDataUrlURL to custom endpoint to save form data (POST requests).
formGetDataUrlURL to custom endpoint to retrieve form data (GET requests).
formPatchDataUrlURL to custom endpoint for patching form data (PATCH requests).
environmentsEnvironments where the chat module is available (crowdin, crowdin-enterprise).