# Run process flow shape

## Introduction

The **run process flow** shape is used to call one process flow from another, so you can run process flows in a chain. For example, you might have a process flow that receives data from a webhook, applies filters and then hits a **run process flow** shape to call another flow with that data.  &#x20;

The default behaviour is for the payload from the end of the *calling* process flow to be sent into the *called* process flow for onward processing. However, when configuring a **run process flow** shape you can add a manual payload - in this case, your manual payload will be sent into the *called* process flow.

The **run process flow** shape also allows you to choose whether any variables associated with the *called* process flow should be applied. &#x20;

{% hint style="info" %}
A single incoming payload for [any process flow shape](https://open.gitbook.com/~site/site_dIV1g/~/revisions/9dTvdvRJIRVZQXuBMMnJ/process-flows/building-process-flows/process-flow-shapes) should not exceed 500MB.

We recommend processing multiple, smaller payloads rather than one single payload (1000 x 0.5MB payloads are more efficient than 1 x 500MB payload!).

For payloads up to 500MB, consider adding a[ flow control shape](https://open.gitbook.com/~site/site_dIV1g/~/revisions/9dTvdvRJIRVZQXuBMMnJ/process-flows/building-process-flows/process-flow-shapes/standard-shapes/flow-control-shape) to batch data into multiple, smaller payloads. Payloads exceeding 500MB should be batched at source.
{% endhint %}

## Need to know

* A *called* process flow will only run if it is [enabled](https://doc.wearepatchworks.com/product-documentation/process-flows/managing-process-flows/enabling-and-disabling-a-process-flow/enabling-and-disabling-a-process-flow-without-virtual-enviroments).
* A *called* process flow is always added to your [run queue](https://doc.wearepatchworks.com/product-documentation/process-flows/error-reporting-and-exception-handling/run-logs-and-queue/working-with-your-run-queue) for processing - even if the parent flow is triggered manually.
* A *called* process flow does NOT inherit the [queue priority](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-settings) of its parent - you should set the priority of these process flows individually.
* If you don't configure a manual payload in the **run process flow** shape, the final payload from the *calling* process flow is always sent into the *called* process flow.&#x20;
* If multiple payloads are passed into the **run process flow** shape, the *called* process flow will run once for each payload - these runs take place in parallel.
* When a payload is passed to a 'child' process flow, meta variables are included.&#x20;
* You cannot create a recursive process flow loop - for example, if *Process Flow A* calls *Process Flow B*, you cannot then call *Process Flow A* from *Process Flow B*.
* If the process flow is running in a [virtual environment](https://doc.wearepatchworks.com/product-documentation/virtual-environments/about-virtual-environments), it looks for a version of the *called* flow deployed in the same environment. If there is no version of the *called* process flow in that environment, an error is given.

## Adding & configuring a run flow shape

**Step 1**\
In your process flow, add the **run process flow** shape in the usual way:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FJyR8yvq8kM5ufs5wn63U%2Frun%20process%20flow%201.png?alt=media&#x26;token=49f853c4-5be2-4cd0-9005-0b3bbf9d9d24" alt="" width="375"><figcaption></figcaption></figure></div>

**Step 2**\
Click in the **flow** field and select the process flow that you want to run:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2Fe4DsTd0MbLN6Lt5KNfi2%2Frun%20process%20flow%20config%202.png?alt=media&#x26;token=d152750e-523c-4f4f-8de1-f1e107933ead" alt="" width="350"><figcaption></figcaption></figure></div>

{% hint style="info" %}
If you have a lot of process flows, you can search for the one you want to use here.&#x20;
{% endhint %}

{% hint style="info" %}
If you select a process flow that is not enabled, an error will be displayed when you attempt to save these settings. In this case, you should access the process flow you want to call and [enable](https://doc.wearepatchworks.com/product-documentation/process-flows/managing-process-flows/enabling-and-disabling-a-process-flow/enabling-and-disabling-a-process-flow-without-virtual-enviroments) it, then come back to save this shape.
{% endhint %}

**Step 3**\
Move down to the **settings** section and choose which version of the selected process flow to call:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FwK0OO1U3pfnRWWUwuuiZ%2Frun%20process%20flow%20options%201.png?alt=media&#x26;token=b28247d7-4ae3-4c1f-b6db-655d47418dc9" alt="" width="331"><figcaption></figcaption></figure></div>

Available options are summarised below:

| Option                  | Summary                                                                                                                                                                                                                                                                                          |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Latest deployed version | Always run the latest [deployed version](https://doc.wearepatchworks.com/product-documentation/process-flows/process-flow-versioning#deployed) of this process flow. So, if the called process flow is edited and re-deployed at any point, the latest `deployed` version will always be called. |
| Latest draft version    | Always run the latest [draft version](https://doc.wearepatchworks.com/product-documentation/process-flows/process-flow-versioning#draft) of this process flow. So, if the called process flow is edited at any point, the latest edited (`draft`) version will always be called.                 |
| Specific version        | Select a version from the dropdown list. With this approach, keep in mind that this version is always called - do if you update this process flow subsequently, you will NOT be running the latest `draft` or `deployed` version.                                                                |

**Step 4**\
If your selected process flow is associated with any process variables, these are shown - you can choose to enable or disable these:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F3hErHRWEOaUs3dvIEt3k%2Frun%20process%20flow%20options%202.png?alt=media&#x26;token=6f134215-aac2-44d5-963c-66b032b90708" alt="" width="330"><figcaption></figcaption></figure></div>

**Step 5**\
If you want to pass a manual payload into this process flow, toggle the **specify payload manually** option ON and paste the required payload into the **supplied payload** field:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FXjDg80VzJucYYKcOqUlN%2Frun%20process%20flow%20options%203.png?alt=media&#x26;token=58aacf1e-a3e8-4306-b94b-41c799f5d1ba" alt="" width="327"><figcaption></figcaption></figure></div>

{% hint style="info" %}
The manual payload can be any format - JSON, XML, plain text, etc.&#x20;
{% endhint %}

**Step 6**\
Save the shape. The configured shape is added to the canvas with the sub-flow available as a link - for example:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FpTColqKauDknrDECyQmq%2Frun%20process%20flow%202a.png?alt=media&#x26;token=da265c0c-baff-43f2-8286-89a02c69ebd2" alt="" width="293"><figcaption></figcaption></figure></div>

Click this link to open the sub-flow in a new browser tab.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/run-process-flow-shape.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
