# Paths

Paths let you create sequences of conditional steps inside a workflow.

You might think of a Paths as "***If** X is true, **then** do A, B & C. **Else**, do D and E.*"

Here's a quick video tutorial:

{% embed url="<https://youtu.be/inz715XVLWc?si=7cjmojIFoATIjLGm>" %}

## The Basics

### Creating a Path group

To create a Path group, navigate to Paths in the Flow Control menu. Next, specify the rules for which Path A should be activated. By default, Path B is set to be activated for cases where no other Path is matching.

<div align="left"><figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-6a5ae4094d81022ed00ba8fb764e0d81ef8ed3ab%2FCleanShot%202024-11-19%20at%2013.54.23.gif?alt=media" alt="Animated demonstration of creating a path group by navigating to Paths in Flow Control menu and configuring conditional rules" width="563"><figcaption></figcaption></figure></div>

### Adding Paths to an existing group

To add one or more Paths to a group, click \[+].

<div align="left"><figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-08e13c379bfa971623f472c6c9a8d68be9d69836%2FCleanShot%202024-11-19%20at%2014.00.00.gif?alt=media" alt="Animated demonstration of adding additional paths to an existing path group by clicking the plus button" width="563"><figcaption></figcaption></figure></div>

### Nesting Paths

It's possible to nest Path groups inside each other, simply by creating a new Path group inside another.

<div align="left"><figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-b1756a56e5b2cc74dd14f7b2ca6d63e2cf42ed0b%2FCleanShot%202024-11-19%20at%2015.04.06.png?alt=media" alt="Workflow showing nested path groups with one path group containing another path group inside it" width="375"><figcaption></figcaption></figure></div>

### Reordering Paths

Reorder Paths by right-clicking on its header to change the order of evaluation.

<div align="left"><figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-2ac9be413b02d65542fa31ae942c981d2cd48cd7%2FCleanShot%202024-11-19%20at%2013.44.59.gif?alt=media" alt="Animated demonstration of reordering paths by right-clicking on the path header to access reordering options" width="375"><figcaption></figcaption></figure></div>

## Merging paths

In Relay.app, it's possible to continue running steps in a workflow after a path group, essentially joining or merging the paths back to one flow. This is useful if you want to use paths to conditionally execute just certain steps.

After the path, you can use data objects created, updated, or fetched within the path when:

* The objects being created, updated, or fetched are of the **same type**
* The object is being created, updated, or fetched in **every path**
* If the object is a result of an AI step, all the AI outputs are **named the same**

For example, if you are creating a Google Contacts contact in one path and are updating a Google Contacts contact in another path, you can reference the created/updated contact in steps after the path ends.

The [step output](https://docs.relay.app/data/step-outputs) of the merged output is indicated with a path icon instead of a step number, like this:<img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-08ed140bd01e9821de8d48a5d9e37b6928fce535%2FCleanShot%202024-11-19%20at%2015.00.57.png?alt=media" alt="Step output pill showing path icon instead of step number to indicate merged output from path group" data-size="line">.

<div><figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-6f24012b22e8435587c3ef248e3e38163c13d81c%2FCleanShot%202024-11-19%20at%2014.56.37.png?alt=media" alt="Workflow showing path group merging where Step 5 uses a Contact output that comes from either Step 3 or 4 depending on path taken"><figcaption><p>The contact referenced in step 5 comes out of the path group above. The contact must be either the output of step 3 or step 4, depending on which path was taken in a run.</p></figcaption></figure> <figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-9d19cb43189c94c885a4d1c5efc26e28519995db%2FCleanShot%202024-11-19%20at%2014.52.15.gif?alt=media" alt="Animated demonstration showing that merged data objects are only available when every path in a group has compatible step outputs"><figcaption><p>Merged data objects are only available when *every* path in a group has a step that creates, updates, or fetches an object of the same type.</p></figcaption></figure></div>

## Good to know

* **Paths are evaluated from left-to-right**, and only one Path within a group will be taken. This means that if the rules of the first Path evaluate to 'true', that Path is taken. Regardless of whether rules of other Paths in the same group match as well\
  ![](https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-ef58eec24cd7674e9ffca67aa6169b8f184f5bdd%2FCleanShot%202024-11-19%20at%2013.41.48.png?alt=media)
