# Lists (Arrays)

## How to create a list

Relay.app has various tools to perform operations on lists of data in your workflow. There are three common situations in which you might encounter lists.

1. [A step output **representing a list of app objects**](#id-1.-a-step-output-representing-a-list-of-app-objects)
2. [A step output **containing** a (nested) **field that's a list of items**](#id-2.-a-step-output-containing-a-nested-field-thats-a-list-of-items)
3. [A step output **containing** a (nested) **list of app objects**](#id-3.-a-step-output-containing-a-nested-list-of-app-objects)

### **1. A step output representing a list of app objects**

*Example:* A list of Jira tickets obtained by configuring a [Find step](https://docs.relay.app/data/find-steps) to return **All matching issues in a list**

The step output pill will contain a badge with three horizontal lines on top of the app icon to indicate it's a list of Issues, not just a single Issue<img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-9b075d8d9c4c9a6b5a5c433ae9f77bf87fa2da9e%2FCleanShot%202024-11-19%20at%2012.08.15.png?alt=media" alt="Step output pill showing list badge with three horizontal lines on Jira issue icon" data-size="line">

<figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-b9030dc1046b4c81997b86a33e49bee6d339ffd5%2FCleanShot%202024-11-19%20at%2012.05.51.png?alt=media" alt="Relay.app workflow step showing Jira Find Issues action configured to return all matching issues in a list format"><figcaption><p>Example of a Step Output representing a list of objects (Jira issues)</p></figcaption></figure>

### 2. A step output containing a (nested) field that's a list of items

*Example:* A step output representing an email object from Gmail contains a number of lists:

* Lists of recipients (for the To and CC lines)
* List of attachments
* List of labels

*Note:* While the structure of every email object contains these lists, this does not mean that they contain data for every email. For example, when an email doesn't have any attachments, the list of attachments is simply empty.

<figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-e14d8561c315e59742713566ae1805682b90037f%2FCleanShot%202024-11-19%20at%2012.11.35.png?alt=media" alt="Gmail email step output showing nested lists including attachments, recipients, and labels fields"><figcaption><p>Example of a step output containing lists of items (an email with lists of attachments, recipients, labels)</p></figcaption></figure>

### 3. A step output containing a (nested) list of app objects

*Example:* A deal object from HubSpot contains lists of associated companies, contacts, tasks, and many others.

<figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-9312dc1f64803be3cea1ef3be457485ffa6ef258%2FCleanShot%202024-11-19%20at%2012.18.17.png?alt=media" alt="HubSpot Deal step output displaying associated objects including lists of companies, contacts, and tasks"><figcaption><p>Example of a step output containing lists of other app objects items (a HubSpot deal with a list of associated companies)</p></figcaption></figure>

## How to work with a list

### Loops (Iterators): Perform actions for each item in a list

Once you have a list of items, the most common thing you'll want to do is to perform an action for each item in the list (e.g. upload each attachment to Google Drive). Iterators let you perform one or multiple actions for each item in a list. Read more about [iterators](https://docs.relay.app/flow-control/iterators "mention").

### Use your list as input for an AI step

Another common use case is to analyze or synthesize a list of data using AI. For example, to create a [digest of a list of newsletters](https://www.relay.app/templates/newsletter-summarizer) or get [combined insights from customer calls](https://www.relay.app/templates/customer-call-insight-generator). In this case, you'll create a "prompt any model" AI step and use the list as input in data for previous steps.

This technique is demonstrated at 1:35 of this video:

{% embed url="<https://youtu.be/GFCKSkrHiZ4?si=0a0eJzs3s-YeeCPm>" %}
An example workflow that uses an AI analysis of a list
{% endembed %}

### Filtering, combining, and manipulating lists

You can use a [transform-data](https://docs.relay.app/built-in-actions/transform-data "mention") step to perform a variety of actions on your list, including:

* Filtering based on some criteria
* Combining it with another list
* Removing duplicates
* Appending values

<figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-aa669279c6bc75170c2c33de9aea0ec3ab12b85b%2FScreenshot%202025-11-17%20at%202.02.39%E2%80%AFPM.png?alt=media" alt=""><figcaption><p>The transform data menu for working with lists</p></figcaption></figure>

### Format a list in text with unrolling

If you want to create a text representation of a list (e.g. a bulleted list in an email body), you could use an AI step to do the formatting for you. But if you want more control and consistency over list formatting, you can **use&#x20;*****unrolling*****&#x20;to render your list in a bulleted or numbered list format**.

Inside a multi-line or rich text box, like an email or Slack message body, insert an unroll block for a selected list. Inside the unroll block, insert fields from the object to create the template for how each list item should be displayed in the list.

<figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-3f7ee3f6e70bc74554242d5352956839490a667f%2FCleanShot%202024-11-19%20at%2012.44.50.png?alt=media" alt="Multi-line text input showing unroll data option with template structure for formatting list items"><figcaption><p>Multi-line text inputs let you "unroll" list data using custom template structures</p></figcaption></figure>

<figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fi4U6HOe55ny0ZV2ZVp6C%2Fimage.png?alt=media&#x26;token=aa3e1170-84a5-4a4c-a7db-76f01f69b2ec" alt="" width="563"><figcaption><p>Example of an unroll block to format a list of events with subbullets</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-20a7f3fce6a50a48cea2cab94e5525fefcce0f70%2FCleanShot%202024-11-19%20at%2013.04.57.png?alt=media" alt="List unroll template showing bullet point structure with Jira issue key, summary, and assignee for each item in the list"><figcaption><p>Example of an unrolled list to create bullet points with key details for open Jira issues</p></figcaption></figure>

For a detailed demonstration on how to unroll a list, you can check out this video:

{% embed url="<https://youtu.be/VqayM6sg8Bc?si=IP2GtXza7fv_8xeM>" %}
Detailed demo of unrolling a list
{% endembed %}

#### Unrolling nested list data

Sometimes lists have nested items. For example, you may have a list of jobs, and each job contains a name, start date, and end date.

To unroll nested lists, you'll need to use a *Create constant* step. Create a multi-line text variable and unroll elements of the list there.

<figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-2f563ff0ad78fd61964e23bdaf3c65e6c9218202%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Combine list data into a comma-separated list

The 'Combine' feature is similar to the 'Unroll' feature, except for that it's hard-coded to concatenate all values in the list separated by commas. You can use this in single-line text inputs.

<figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-2456c48dbaf072ccc896ce3cb9274363baf13798%2FCleanShot%202024-11-19%20at%2012.24.51.png?alt=media" alt="Single-line text input showing combine data option to merge list items into comma-separated format"><figcaption><p>Single-line text inputs let you combine list data into a comma-separated string</p></figcaption></figure>

<div><figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-e8133869d04002bc94b3178a904e1447beb5f105%2FCleanShot%202024-11-19%20at%2013.11.56.png?alt=media" alt="Text input field showing combine data option to create comma-separated list from multiple values"><figcaption></figcaption></figure> <figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-8c2f6daeda23fe2c953f504b02d5b241ffd224de%2FCleanShot%202024-11-19%20at%2013.12.44.png?alt=media" alt="Preview showing the result of combining list data into a comma-separated string format"><figcaption></figcaption></figure></div>

### Using the size of a list

All lists have a **size** property. You may use this in a workflow to determine the number of items in the List, and define behavior accordingly. For example, by creating [paths](https://docs.relay.app/flow-control/paths) for cases where the list contains 0, 1, or multiple items.

<figure><img src="https://647519108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkKoEy3xMIYaIwd4mRAB%2Fuploads%2Fgit-blob-a52fab48a2ae29eb0c1755ccbff39847f90888c5%2FCleanShot%202024-11-19%20at%2012.51.17.png?alt=media" alt="Step output data picker showing Size property of a list that indicates the number of items in the list"><figcaption><p>The 'Size' property of a list may be used to determine how many items are in a list during a run</p></figcaption></figure>

### Explicitly selecting the first item from a list

While in the majority of cases you'll want to wrap an [loop (iterator)](#iterators) around a list, there may be cases when you want to explicitly pick the first item from a list to perform an action on. For example, your CRM might let you add multiple 'Associated Companies' to a deal, even though you're only ever adding one at most. In that case, you can probably just use the 'first result'.

This is why step outputs for lists will still show up in data pickers that only accept a single item. You'll see a 'First result' entry that lets you pick the very first result.

<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-c598581d2672fc1d9e304d1cd1e5552b1a76ebf0%2FCleanShot%202024-11-19%20at%2012.22.04.png?alt=media" alt="Dropbox upload step configuration showing first result option to select the first attachment from an email list"><figcaption><p>Uploading the first attachment in an email to Dropbox</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-1ccfb77a8026411577e3d734962a6d6f83b207e9%2FCleanShot%202024-11-19%20at%2012.29.57.png?alt=media" alt="Jira add comment step showing first result option to select the first issue from a list of issues"><figcaption><p>Adding a comment to the first Jira Issue from a list of issues</p></figcaption></figure></div>


---

# 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://docs.relay.app/data/lists-arrays.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.
