Skip to main content

Build an Automation

TimeUnder 10 minutes
What you'll buildAn automation that prints Hello World to the terminal when it runs.

An automation runs your integration logic without an external request, on demand or on a schedule. Automations are ideal for data synchronization, report generation, and routine maintenance jobs. This quick start shows the full cycle: add an automation artifact, build the logic in the visual designer, run it, and review the scheduling options for production.

Prerequisites​

A working WSO2 Integrator environment.

Step 1: Create the integration​

  1. On the project home page, click Create on Cloud.

    WSO2 Cloud project home showing the Create on Cloud optionWSO2 Cloud project home showing the Create on Cloud option
  2. The WSO2 Integrator cloud editor opens in your browser.

    WSO2 Integrator cloud editor landing page showing an empty integration and the Deploy to WSO2 Cloud panelWSO2 Integrator cloud editor landing page showing an empty integration and the Deploy to WSO2 Cloud panel
Note

The cloud editor creates a default integration for you, so you don't need to name it now. You can change its name when you deploy it. For more information, see Save and deploy.

Step 2: Add an automation artifact​

  1. In the design view, click Add Artifact manually.

    Integration design view with the Add Artifact manually button highlightedIntegration design view with the Add Artifact manually button highlighted
  2. Select Automation under Automation.

    Artifacts page with Automation highlighted under AutomationArtifacts page with Automation highlighted under Automation
  3. Click Create.

    Create New Automation form with the Create buttonCreate New Automation form with the Create button

Step 3: Add logic​

  1. Click + below the Start node to open the node panel.

    Automation flow with the add node button highlighted below the Start nodeAutomation flow with the add node button highlighted below the Start node
  2. Select Call Function under Statement.

    Node panel with Call Function highlighted under StatementNode panel with Call Function highlighted under Statement
  3. Search for print in the functions panel.

  4. In the search results, go to the Standard Library section and select the print function under io.

    Functions panel search results with print highlighted under io in the Standard Library sectionFunctions panel search results with print highlighted under io in the Standard Library section
  5. Click Initialize Array for the Values parameter.

    io:print panel with the Initialize Array button highlighted under Valuesio:print panel with the Initialize Array button highlighted under Values
  6. Set Values to "Hello World" and click Save.

    io:print panel with Values set to Hello Worldio:print panel with Values set to Hello World

Step 4: Run and test​

  1. Click Run.

  2. Confirm the terminal output contains Hello World.

    Running the automation and seeing the Hello World output in the terminalRunning the automation and seeing the Hello World output in the terminal

Step 5: Deploy to WSO2 Cloud​

To deploy your integration to WSO2 Cloud from the cloud editor, see Save and deploy.

Skip ahead: deploy a ready-made sample

Rather not build it yourself? One-click deploy the HelloWorldAutomation sample straight to WSO2 Cloud.

Deploy to WSO2 Cloud

Source code​

View the generated Ballerina code

The steps above generate the following complete, runnable Ballerina program:

import ballerina/io;
import ballerina/log;

public function main() returns error? {
do {
io:print("Hello World");
} on fail error e {
log:printError("Error occurred", 'error = e);
return e;
}
}

Scheduling automations​

Periodic invocation is configured in an external system once the automation is deployed. Available options include:

  • Cron job: schedule the automation from a cron entry on a Unix or Linux host.
  • Kubernetes: define a CronJob resource to run the automation on a recurring schedule.
  • VM: use a host scheduler such as Windows Task Scheduler or systemd timers.
  • WSO2 Integration Platform: configure the schedule in the WSO2 Integration Platform when the integration is pushed to the cloud.