Open MercatoDocsSearch docsAPI reference

User guide

Creating Workflows

Open the visual editor and sketch the business process one step at a time. Declare the inputs and check the transition paths before starting a test run.

The example builds an approval workflow in the Studio.

Getting Started

  1. Navigate to the Workflows section in the backend interface
  2. Click Create Workflow – the template gallery opens
  3. Pick a starting point:
    • A template: Ready-made flows (order approval, lead-to-install, task escalation, webhook integration) you can preview and then adapt
    • Blank canvas: the gallery's Blank card starts you on an empty canvas

Either way you land in the Studio. It is the only workflow editor – the old form editor has been retired (see The Studio is the only editor).

For this guide, we'll start from a blank canvas.

Workflow visual editor showing a sales order approval flow

Workflow visual editor with a seeded sales order approval definition loaded from the Open Mercato demo instance

Using the Visual Editor

1. Add a START Step

Every workflow begins with a START step:

  1. Click START in the step palette on the left
  2. A green node appears on the canvas
  3. This is your workflow's entry point – it automatically advances when the workflow starts

2. Add a USER_TASK Step

Next, add a step that requires human input:

  1. Click USER TASK in the step palette
  2. An amber node appears on the canvas
  3. Click the node to select it, then click Edit or double-click the node
  4. Configure the task:
    • Step Name: "Approve Purchase Request"
    • Description: "Review and approve or reject the purchase request"
    • Assigned to Role: "Approvers" (or choose a specific user)
    • Form Key: Optional identifier for a custom form
    • Allowed Actions: "complete" and "cancel"

πŸ’‘ Tip: When assigning to a role, any user with that role can claim and complete the task.

3. Connect the Steps

Create a transition from START to your user task:

  1. Hover over the START node – small handles appear on its edges
  2. Click and drag from the handle to the USER_TASK node
  3. Release to create a connection (transition)
  4. The workflow will automatically move from START to the user task

4. Add Decision Paths

Let's add two END steps for "Approved" and "Rejected" outcomes:

  1. Click END in the step palette twice to add two END nodes
  2. Click the first END node and rename it to "Approved"
  3. Click the second END node and rename it to "Rejected"
  4. Connect the USER_TASK to both END nodes:
    • Drag from the user task to "Approved"
    • Drag from the user task to "Rejected"

5. Configure Transitions

Click each transition to configure when it should be taken:

Transition to "Approved":

  1. Click the edge connecting USER_TASK to "Approved"
  2. In the properties panel, set:
    • Transition Name: "Request Approved"
    • Trigger: "manual" (requires user action)
    • Pre-Conditions: Optional – add a rule like context.decision === 'approve'

Transition to "Rejected":

  1. Click the edge connecting USER_TASK to "Rejected"
  2. Set:
    • Transition Name: "Request Rejected"
    • Trigger: "manual"
    • Pre-Conditions: Optional – add a rule like context.decision === 'reject'

6. Add Activities

Let's send an email notification when the request is approved:

  1. Click the transition to "Approved"
  2. In the properties panel, find the Activities section
  3. Click Add Activity
  4. Configure the activity:
    • Activity Type: "SEND_EMAIL"
    • Activity Name: "Notify Requester"
    • Fill in the type-specific form fields:
      • To: {{context.requesterEmail}}
      • Subject: Your request has been approved
      • Body: Your purchase request for {{context.itemName}} has been approved.

Each activity type shows its own form fields. If you need to paste or fine-tune raw configuration, expand the Advanced (JSON) section on the activity.

πŸ’‘ Tip: Use {{context.fieldName}} to insert workflow data into activity configurations. Invalid configuration is flagged as a non-blocking warning when you save.

Learn more about activities β†’

7. Save and Enable the Workflow

  1. Click Save in the top toolbar
  2. Enter a Workflow ID: "purchase-approval-v1" (lowercase, hyphens allowed)
  3. Enter a Workflow Name: "Purchase Approval"
  4. Optionally add a Description: "Routes purchase requests through approvers"
  5. Set Version: 1
  6. Toggle Is Active to enable the workflow
  7. Click Save Definition

Your workflow is now live and ready to accept new instances.

Draft Autosave

While you edit, the editor autosaves your work as a personal draft every few seconds. Drafts never change the published definition – only clicking Save does. If you leave and come back with unsaved changes, a banner offers to Restore draft or Discard it; if someone else saved the definition in the meantime, the banner says so before you restore. A successful save removes the draft.

Declaring Workflow Inputs (Context Panel)

The definition panel has a collapsible Context section where you declare the inputs your workflow expects – each with a name, a type (text, number, boolean, select, date), an optional label, a required flag, and options for selects.

Declared inputs power the rest of the editor: they appear in the variable picker at every step with their types, required inputs are shown as always available, and optional ones carry a maybe marker. Declaring inputs is optional, but workflows with a declared context are far easier to configure and test.

Starting a Workflow from an Event

The definition panel's Triggers section starts a workflow automatically when something happens elsewhere in the system.

When a workflow has several versions, its event triggers fire only from the newest enabled, published version – the same version a start without a pinned version runs. Older versions stay available to the instances and sub-workflow callers already pinned to them, but their triggers no longer start anything, so change triggers on the newest version. Disabling or deleting the newest version hands the triggers back to the next enabled, published one.

The Variable Picker

Every configuration field that accepts {{ }} templates – activity config inputs, mapping value cells, and trigger expressions – has a variable picker button. It opens a popover listing exactly what is available in context at that point in the workflow:

Clicking an entry inserts {{path}} at the cursor.

Unresolved Reference Warnings

The Problems panel warns when an expression references context that nothing in the workflow produces – a typo in a path, or a reference to an output of a step that never runs before this one. These are warnings, never blockers: the definition still saves, because the editor cannot always prove a value will be absent at runtime.

Testing a Step

You can dry-run a single activity without executing the workflow. Open an activity's configuration and use the Test step panel:

  1. The editor builds a sample context for the step – from your pinned sample if you have one, otherwise from the last test output, otherwise from typed placeholders
  2. Running the test interpolates the config against that context and shows the resolved values plus the activity's output preview
  3. Side-effecting activities never actually execute – they return a simulated "would do" result (for example, wouldSendTo for an email) or a structured refusal when the activity cannot be safely simulated
  4. Pin as sample stores the test output as the step's sample so the picker and future tests reuse it

Testing steps requires the Test workflow definition steps permission.

Warning Β· Samples are stored as-is

Pinned samples are saved inside the workflow definition without redaction or encryption and are visible to anyone who can view the definition. Do not pin real customer data or secrets – use representative fake values instead.

The Input Data Panel

Alongside every step and route inspector sits an Input data panel: the same grouped listing the variable picker shows, docked next to the fields you are filling in. It lists what is in context at that point, with type badges, maybe markers, and sample values where one is available.

Every row is draggable and clickable:

Editing on the Canvas

The Studio is a real editor, not a read-only diagram:

Manual Layout Wins

New steps are laid out automatically, but once you move a card, that position is yours: it is saved with the definition and survives reloads, drafts and saves. The Auto-arrange button is the one action that re-lays the whole canvas. A drag is saved once, when you drop it – not on every frame.

Keyboard and the Command Palette

Every canvas operation is reachable without a mouse.

Steps announce themselves as type, name and status, and status is never signalled by colour alone: every state pairs its colour with its own icon and a text label.

The Code View

The Code button opens the definition JSON alongside the canvas.

The Code view is read-only in this release: you cannot type into it, and the canvas remains the source of truth. Two-way editing with live error highlighting is planned for a later phase.

Validation and Saving

Validation runs as you edit, and every issue appears in two places: as a badge on the step or route it belongs to, and as a row in the Problems panel that you can click to jump straight to it. Errors block a save; warnings never do.

If a save cannot go through, it says so:

Editing a Workflow That Is Running

Instances keep executing the exact definition version they started on, and the engine re-reads that record as they advance. So if you change the structure of a definition – add or remove steps, change a step's type, re-wire or re-target routes, change fork/join wiring – while instances are still running, the save is refused with a banner explaining how many instances are affected.

The banner's Create version button mints the next version and applies your edit there, so running instances finish on the old version and new runs start on the new one. Labels, positions, activity configuration, conditions, priorities, triggers and metadata are not structural and always save in place. Draft autosave is never blocked – work in progress is always saveable.

The Studio Is the Only Editor

The old form editor has been retired. Everything it did now lives in two places:

Existing links keep working: /backend/definitions/create and /backend/definitions/<id> now forward to the Studio with the same permissions as before. They will be kept for at least one minor release, so bookmarks and any deep links you have saved do not break.

Best Practices

Naming Conventions

Organizing Steps

Error Handling

Learn more about compensation β†’

Testing Workflows

Before going live:

  1. Dry-run individual activities with the Test step panel
  2. Create a test instance with sample data
  3. Complete each step manually to verify behavior
  4. Check the execution timeline for errors
  5. Review email notifications and API calls in the monitoring view

Learn more about monitoring β†’

Example: Simple Approval Workflow

Here's the complete workflow we just built:

Steps:

  1. START β†’ Auto-advance to next step
  2. Approve Purchase Request (USER_TASK) β†’ Wait for approver decision
  3. Approved (END) β†’ Workflow complete, request approved
  4. Rejected (END) β†’ Workflow complete, request rejected

Transitions:

Context Data:

{
  "itemName": "Laptop",
  "amount": 1500,
  "requesterEmail": "[email protected]",
  "decision": "approve"
}

When started, this workflow:

  1. Creates a task for any user with the "Approvers" role
  2. Waits for the approver to complete the task
  3. Sends an email if approved
  4. Ends the workflow

Next Steps

Now that you've created your first workflow:

See Also:

Previous: Workflow Activities Β· Next: Workflows Overview