# Subflows

Source: https://neondeerdata.com/docs/platform/automations/subflows/

Call a reusable Attio workflow for a record, pass it values, and choose whether the calling workflow waits for its answer.

## Before you start

Use the Advanced Workflow Automations app version that includes `Start a subflow`, `Call a subflow`, and `Return from a subflow`. Complete [Automations setup](https://neondeerdata.com/docs/platform/automations/#setup) and check that your Neon Deer plan includes scheduled workflow runs.

The app is available today through [All apps in Neon Deer](https://app.neondeerdata.com/apps/); it is not yet listed in Attio's marketplace.

A subflow starts when another workflow calls it. Use [scheduled workflows](https://neondeerdata.com/docs/platform/automations/attio-scheduled-workflows/) when you want a record to enter a workflow at a future date and time instead.

## Set up the called workflow

1. Start an Attio workflow with `Start a subflow`. Choose the `Object` whose records it accepts.
2. Add the steps you want to reuse. The trigger supplies the record, its `Subflow ID`, and the input values sent by the caller.
3. Add `Return from a subflow`. Map `Subflow ID` from the trigger, choose `Status`, and map the values to return.
4. Turn the workflow on. It can then be selected by a calling workflow for the same object.

The return step sends the result to the workflow that called this run. Use the Subflow ID from this run's trigger; do not hardcode an ID from an earlier run.

## Call it from another workflow

1. Add `Call a subflow` to the calling workflow. Choose `Object`, the matching `Subflow`, and the `Record` to send.
2. Map the values the called workflow needs into the input fields. Unused inputs arrive as empty text.
3. Leave `Don't wait for a result` clear to wait for a return. Later steps can use `Status` and the returned output values.
4. Select `Don't wait for a result` when the calling workflow should continue immediately. It receives no returned values in that mode.

## Example: reuse an account-routing check

Create a Companies subflow that reads the company's region and uses a [lookup table](https://neondeerdata.com/docs/platform/automations/lookup-tables/) to choose an owner. Return `Succeeded` and the owner's email in `Output 1` when a match is found, or `Failed` when it is not.

A demo-request workflow and a partner-referral workflow can both call it for their company record. Each waits for the result, checks Status, and uses Output 1 in its next step. Changing the routing workflow updates the shared process without copying its steps into both callers.

`Failed` is a returned status your calling workflow can branch on. It is different from a call that could not start or failed to receive a return.

## Review calls and resolve problems

In [Automations → Scheduled runs](https://app.neondeerdata.com/automations/?view=scheduled), choose `Type → Subflow runs`. Open a run to see which workflow called it and follow the link to the calling run in Attio.

If the subflow is missing from the picker, check that it is on, starts with Start a subflow, and uses the selected object. If a waiting call does not receive a result, check that the called workflow reaches Return from a subflow with the correct Subflow ID. Review both workflows in Attio before retrying work that may already have changed records.

The first return decides the result. Later returns do not replace it. Calls that cannot start or do not return in time fail the waiting step; check its error and the [Activity page](https://neondeerdata.com/docs/platform/automations/activity/) before trying again.
