Introduction and quick start
What is Synchra24 automation, how to create the first script and safely perform a test run.
Machine translation
Synchra24 automations help to exchange data between systems and respond to operational events without a separate integration server. A script can receive data from HTTP sources or an internal event, convert it to JavaScript, and send the result to one or more external systems.
For example, automation can be done once a day.:
- get the list of employees in XML from 1C;
- bring the fields to a structure that another system accepts;
- send the result in JSON;
- save the startup status and diagnostic data.
What will be required
For work, you need:
- license API integration;
- the role's right to edit company integrations;
- source and destination addresses available via HTTPS or HTTP;
- tokens of external systems, if their API requires authorization.
The AI assistant in the handler editor additionally requires a license. AI agent.
Where are the automations located
Open a company and go to:
- Administrator;
- Automation;
- To create.
The main screen displays the created automations, their status, the next launch and the execution history. The switch allows you to quickly stop automation without deleting its configuration.
The admin panel section, open automation, and its editor tab are saved in the page address. After a reboot, the saved automation is restored on the same tab; the browser's "Back" and "Forward" buttons work. The link does not transfer access rights and does not contain handler code, secrets, or unsaved changes. To save the changes before restarting, use Check and save.
What does automation consist of?
There are two main tabs in the editor.
Configuration
Describes the order of execution:
- when to start automation;
- where to get the data from;
- what format should I use to read the response?;
- where to send the result;
- how many times to repeat the sending in case of an error.
The configuration can be written in YAML or JSON. The documentation examples use YAML because it is usually shorter and easier to read.
The handler
Contains a JavaScript function transform(input, context). It receives the source data and returns the result for the destination.
If the conversion is not required, the handler can be omitted from the configuration. The received data will be sent unchanged.
The first automation
The following is a minimal example: get JSON, leave the necessary fields and transfer the result to another service.
1. Fill in the basic information
Specify a clear name, for example Ежедневная выгрузка заказов, and briefly describe the purpose of automation.
2. Add the configuration
version: 1
trigger:
type: manual
source:
type: http
method: GET
url: https://api.example.com/orders
headers:
Authorization: "Bearer ${secrets.SOURCE_TOKEN}"
response:
format: json
encoding: utf-8
transform:
type: javascript
timeout_seconds: 2
destination:
type: http
method: POST
url: https://receiver.example.com/import/orders
headers:
Authorization: "Bearer ${secrets.DESTINATION_TOKEN}"
request:
format: json
encoding: utf-8
retry:
attempts: 3
delay_seconds: 5
trigger.type: manual This means that automation is only started manually. This is a convenient mode for first acquaintance and debugging.
3. Add a handler
function transform(input, context) {
const orders = Array.isArray(input.orders) ? input.orders : [];
return orders.map((order) => ({
number: String(order.id),
amount: Number(order.total || 0),
createdAt: order.created_at || null,
}));
}
The function must be called transform and return a JSON-compatible value: object, array, string, number, boolean value, or null.
4. Create secrets
Open Variables in the automation list, add:
SOURCE_TOKEN;DESTINATION_TOKEN.
The secret values are stored separately from the configuration and are not shown after saving.
5. Check the configuration
Click Check the configuration. The system will check:
- the YAML or JSON structure;
- required fields;
- cron format, if a schedule is specified;
- source and destination addresses;
- JavaScript syntax.
During this check, no external requests are executed.
6. Perform a test run
Click Test launch. The system will access the source and execute the handler, but will not send the data to the destination.
The result modal displays:
- data received from the source;
- data after the handler;
- messages
console.log,console.info,console.warnandconsole.error; - JavaScript error, if any.
7. Save and enable
After checking, click Check and save. For automatic execution, turn on the automation switch and replace the manual trigger with a schedule.
There is a standard switch in the automation list. Enabled / Turned off allows you to quickly change the availability of the script without opening the editor. It is temporarily unavailable during saving.
trigger:
type: schedule
cron: "0 0 * * *"
timezone: Europe/Moscow
This example runs every day at 00:00 Moscow time.
Launching from your own service
For example, an employee prepares a report in your service, clicks "Send", and automation saves the result to an artifact or transmits it to an external system.
- In the administrator, save the service and create it in the tab Events
enabled event with a local name
report_ready. - In automation, select this service event. Use
version: 2,trigger.type: eventand the full code, for examplecustom.service_42.report_ready. - Set up the handler and destination. Field
sourceno need: the input is the event envelope, the service data is located ininput.payload. - Save and enable automation.
- Add a call to the service
synchra.emitEventwith a stable operation key, publish the service and check the working shipment and automation history.
A license is additionally required for this scenario. Applications and the right to edit the services. The AI assistant editor can add a call to an already registered event; it does not register events from the code. The preview of the service simulates sending and does not start automation processes. The call is currently supported only by the web engine.
Code examples and limits: Services and Event automation.
The order of execution
When running, Synchra24 executes the steps sequentially:
- downloads and decrypts the company's secret variables;
- retrieves data from a source or sources;
- decodes the response according to the format;
- causes
transform(input, context)if the handler is enabled; - encodes the result into the destination format;
- sends data;
- records the status, time, and safe preview of the result in the history.
If any mandatory stage fails, the launch status is assigned Mistake.
Which mode to choose
Use the usual ones source and destination when data goes from one system to another.
Use steps When needed:
- collect data from multiple sources;
- send the result to multiple appointments;
- give each assignment its own part of the result.
Details: Automation configuration and Multiple sources and destinations.
The next step
It is recommended to read the documents before the operational launch:
- Automation artifacts;
- JavaScript handler;
- Synchra24 Event Launch;
- Secret variables and security;
- Checking and finding errors.
Data being modified from the service
Create a JSON artifact in Automation management. In the service, replace the value with await synchra.setArtifact(name, value). In YAML, connect it as artifacts: {settings: service.settings}: then it is available to sources, conditions, handler (context.artifacts.settings) and appointments. Creating a name remains a separate administrative action. The full scenario.
Creating from a ZIP template
In the section Automation click From the ZIP template, select the archive from automation.json, configuration and handler, check the dependencies and create a record. It will be turned off and will not fulfill the requests when downloading. Configure the secret variables and resources of this company, check the code, and then enable them separately. The download button in the editor header creates a reverse ZIP package. Format, example, and limitations.
Automation Store and Publication
Click Shop go to the automation section to find a ready-made script. After installation, automation will be turned off: configure connections and secret variables, check the operation and then turn it on.
To offer your own automation to other companies, save it and click publish in the editor. You can publish a separate automation or a package along with the service. The secret values of your company are not passed on to customers.
How to install the product, fill out the seller's card, send the publication for verification and give the key to the buyer is described in the article "Extension Store".