Flow: processes and approvals

SENSEVER

The official Sensever channel: guides and API documentation for Chat, Requests, Flow, Studio, bots and messaging channels.

7 min de lectura

Flow: processes and approvals

A process is a multi-step scenario that Flow runs on its own and that can last for days: get a contract approved by a lawyer and a finance manager, wait for payment from an external system, remind a manager after three days. This article explains what processes can do, how to create and start them, and how to decide on approvals.

A process isn't the same as an object's statuses. Statuses and transitions describe what state an object is in and where it can be moved (Flow: statuses and the process editor). A process is a sequence of actions around an object: it can move the object itself, wait for people and events, and branch.

What a process can do

A process consists of steps. Each step has a key and a type:

Step

What it does

"Action"

An action on the object, as in automations: change a field, run a transition, send a notification or an email, call a webhook. You can specify an "On error" step

"Wait"

Wait for a set time: P3D — three days, PT15M — 15 minutes

"Wait until date"

Wait until a date from an expression, such as the task deadline. If the date has passed, continue immediately

"Wait for external event"

Wait for an event from another system with a given type and correlation key; you can set a timeout

"Approval"

Ask people to approve; then different steps follow for "Approved", "Rejected" and "On timeout"

"Branch"

Take the first branch whose condition is true, otherwise "Default"

"Parallel"

Start 2–20 branches at the same time

"Join"

Continue when all branches or a quorum have arrived; the other branches are cancelled

"Escalation"

Send a notification and move on

"Finish"

The process completed successfully

"Finish with error"

The process ended with an error code, for example REJECTED

A process can have up to 100 steps. A process that loops endlessly without waits stops with an error.

Type processes and processes without an object

When creating a process, you choose the "Object type". A type process runs on a single object: its steps see the object's fields and change it. "No object" is a process that only has input data; its steps can only use a webhook, a notification and an email.

Whom it runs as

Steps run on behalf of a service executor — the "Run as" field. Its permissions apply to all steps: if the executor has no permission to change a field, the step is refused. In the object's history, such changes are labeled "process on behalf of …".

How to create a process

Settings → the "Processes" tab → "New process":

  1. "Name" — what the process is called in lists.

  2. "Key" — Latin letters; object actions, automations and the API use it to start the process. It can't be changed after creation.

  3. "Object type" or "No object".

  4. "Run as" — the service executor.

The process page opens. On the left are the "Steps" list and the "First step", and on the right is the form of the selected step. You add a new step with the "New step…" list, a key and the "+ Add" button. Step parameters described with expressions or lists (branch conditions, approval assignees, the action) are entered as JSON; the whole process document is visible and editable in the "JSON document" block. The expression language is described in Flow API: automations, reminders and expressions.

"Save draft" saves your changes, and "Publish" checks the whole process and makes the draft the current version. Publishing errors are all shown at once next to their steps and parameters; warnings (for example, an unreachable step) don't prevent publishing — "Published with warnings".

Versions

A published version doesn't change. To change a process, click "Edit (new draft)". Once a new version is published, new runs use it, while processes already running finish on their own version. The "Versions" block shows version numbers and statuses, and "Recent runs" shows the last ten instances with links to the objects.

How to start a process

Method

How to set it up

A button in the object card

Type settings → "Actions" → a new action of the start_process kind (there is a "Template: start process" button and a "Process" selector). The button appears in the card in the "Change status · Actions" row

Automation

The "Start process" action in the type's automation. Repeating the same rule run doesn't create a second instance

API

POST /v1/processes/{key}/start — see Flow API: processes, approvals and external events

You can only start a published process that is visible to whoever starts it. Otherwise the button in the card is unavailable, with an explanation.

The process in the object card

The card's right column has a "Processes" block listing all runs on this object:

  • the process key and version, and the status: "running", "completed", "error", "cancelled";

  • start and end times;

  • "Now:" — the current steps ("running", "waiting");

  • expected external events and their state: "waiting", "received", "timed out";

  • approvals: who is assigned, who approved or rejected and with what comment;

  • the error text if the process failed;

  • "Cancel" on a running process.

Cancelling removes the process's steps, waits and approvals. Actions already performed aren't rolled back.

If the object is archived, its running processes are cancelled (the card shows "Cancelled: the object was archived."). After the object is restored, cancelled processes don't resume.

Approvals

The "Approval" step asks one or more people to make a decision. You specify whom to ask as a list: specific members, a workspace role, people from an object field (for example, "Watchers"), the object's assignee or author, or an expression. No more than 50 assignees.

"Decision rule":

Mode

When it's approved

any — "any one is enough"

At least one person approved

all — "all required"

All assignees approved

quorum — "quorum"

As many people approved as specified

You can set a "Timeout", for example P3D, and an "On timeout" step — for example, an escalation to a manager.

How to decide on an approval

Each assignee gets a direct message "Your approval is needed" with a link to the object in Sensever chat — in the "Sensever Flow" conversation (the "Approvals and processes" category in personal notification settings).

All of a workspace's approvals are collected under "Approvals" in the left column; the counter next to it shows how many are waiting for your decision. Approvals from all your workspaces at once are in "All workspaces" mode, under its "Approvals" item: there each approval shows its workspace, and the counter sums up all workspaces. You can decide from either list in the same way.

  1. Open "Approvals". The "Awaiting decision" tab shows your open approvals, and "All" includes those already decided.

  2. The approval card shows the process, the step, the decision rule and other participants' decisions. "Open object" takes you to the card.

  3. Click "Approve" or "Reject" and, if you like, add a comment (up to 1000 bytes) — process participants will see it.

You can only decide on your own approval, and only once. An approval that has already been decided, cancelled or has timed out can't be decided.

External events

The "Wait for external event" step waits for a message from another system: for example, an ERP reports that an order has been paid (erp.order_paid), with the object number in the correlation key. The event is sent to Flow with a POST /v1/events request; a repeat of the same event doesn't advance the process a second time. How to send events is described in Flow API: processes, approvals and external events.

Reliability

The process state is stored in the Flow database, not in server memory: restarting servers doesn't lose or repeat steps, and waits and pauses continue from where they were. Webhooks, notifications and emails in steps are retried if the recipient fails.

What's next

Comentarios

Autores