Shared workflows
Build steps once as an automation, then run them from your USSD, chatbot and automation projects and use the answer.
A shared workflow is an automation that other projects in your organisation run directly and get an answer from. Build a client lookup, an access-token fetch or a payment check once, and every USSD menu, chatbot and automation that needs it runs the same steps.
It has three parts:
| Part | Where | What it does |
|---|---|---|
| Called by another flow Trigger | The shared workflow | Makes the automation shareable, and declares the inputs it takes. |
| Return | The shared workflow | Ends it with the outputs the caller gets back. |
| Run workflow | Each project that uses it | Passes the inputs, waits for the answer, and continues on Success or Failure. |
The project that runs it waits for the answer in the same request, so the caller on a USSD menu or in a chat sees the result on the next screen.
Shared workflow or subworkflow?
A shared workflow runs on its own and always answers with its current live version, so publishing it updates every project that runs it. A subworkflow is copied into each project that uses it, pinned to a version, and changes only when that project is updated.
Make a shared workflow
Add the trigger
In an automation project, drag Called by another flow Trigger from the Triggers group. Fill in What it does, and add the Inputs callers pass, for example a required Text input accountNumber.
Build the steps
Read the inputs as {{state.inputs.accountNumber}}. Use the steps you would in any automation, apart from those that wait: Wait, Approval, Collect Payment and Respond Webhook can't be in a shared workflow, because its caller needs the answer now.
Return the answer
End each path with a Return step, and add the Outputs the caller should get, such as clientId set to ${state.client.id}.
Save and publish
Once you save, the workflow appears in the Workflow picker of every Run workflow step in your organisation. Publish it so published projects can run it: until then it's listed as (not live yet).
Run it from a project
- In a USSD, chatbot or automation project, drag Run workflow from the Logic group.
- Choose the Workflow, and fill in its Inputs, for example
accountNumberset to{{state.accountNumber}}. - Read the answer after the step as
{{state.workflowResult.output.clientId}}, using the name in Save the answer as. - Connect Success and Failure.
See Run workflow for the answer's shape, how long each project type waits, and the error codes.
Drafts, versions and publishing
- A draft runs the draft. When you test a project in its simulator, its Run workflow step runs the shared workflow's saved draft.
- A published project runs the live version. Publishing a new version of the shared workflow changes what every published project runs, without republishing them. Check the trigger's Used by list before you add a required input or remove an output.
- Publishing checks every step. A project can't be published while one of its steps runs a shared workflow with no live version, or leaves out an input the live version requires.
- Version history: a project version that runs shared workflows is published from the canvas, not promoted from Version history, so it's rebuilt with their live versions.
Reuse an answer
On the trigger, Reuse the result for up to 60 minutes answers a call with the same inputs from a saved result instead of running the workflow again. Use it for an answer that stays valid for a while, such as an access token that lasts five minutes: reuse it for four. A caller can still choose Always run it on its own step.
Billing
Each call that runs the shared workflow counts as one automation run, on the shared workflow's project, as well as whatever the calling project uses. In the billing report these runs appear under the Workflow call channel.
A call answered from a saved result, or refused before it runs (for example for missing inputs), is not billed.
Limits
- Shared workflows can run each other at most 3 deep, and a workflow can't run one that's already running further up the chain.
- A call waits at most 4.5 seconds from USSD, 20 seconds from a chatbot and 120 seconds from an automation. See How long it waits.
- Only projects in your organisation can run a shared workflow.
- Voice projects can't run shared workflows yet.
Build with Buni
When your organisation has shared workflows, Buni, the AI assistant, knows what each one takes and answers. Ask it to "look up the client with the Find client workflow" and it adds a Run workflow step with the inputs and both paths. In an automation, it can also make a shared workflow for you, with its trigger, inputs and Return steps.