---
title: Passing data between steps
source: https://docs.newrelic.com/docs/workflow-automation/workflow-examples/basic-patterns/data-passing
---

Reference outputs from previous steps using template syntax to chain actions and build complex automation.

**Requirements:**

-   New Relic account with appropriate permissions
-   Slack workspace with appropriate permissions
-   Slack bot token configured as a secret in workflow automation
-   Access to Slack channels where messages will be sent

## Basic data passing

Query alert issues from New Relic and send notifications to Slack for each active issue.

**What this workflow does:**

-   Execute NerdGraph query to retrieve active alert issues
-   Loop through each alert issue
-   Send Slack notification for each issue with issue details

    ```yaml
      name: alertSlack
      description: "query Alert Issues and send notifications to Slack"

      workflowInputs:
        accountId:
          type: Int

      steps:
        - name: getAlert
          type: action
          action: newrelic.nerdgraph.execute
          version: 1
          inputs:
            graphql: |
              query GetAlertIssues($accountId: Int!) {
                actor {
                  account(id: $accountId) {
                    aiIssues {
                      issues(filter: {states: ACTIVATED}) {
                        issues {
                          issueId
                          priority
                          state
                          title
                        }
                      }
                    }
                  }
                }
              }
            variables:
              accountId: ${{ .workflowInputs.accountId }}

        - name: loopStep
          type: loop
          for:
            in: ${{ .steps.getAlert.outputs.data.actor.account.aiIssues.issues.issues }}
            steps:
              - name: sendToSlack
                type: action
                action: slack.chat.postMessage
                version: 1
                inputs:
                  token: ${{ :secrets:your_slack_token }}
                  channel: incident-channel
                  text: >
                    issueId: ${{ .steps.loopStep.loop.element.issueId }}
                    priority: ${{ .steps.loopStep.loop.element.priority }}
                    state: ${{ .steps.loopStep.loop.element.state }}
                    title: ${{ .steps.loopStep.loop.element.title | tostring }}
    ```

**Key actions**: `newrelic.nerdgraph.execute`, `slack.chat.postMessage`

## Related topics [#related-topics]

[Loops](https://docs.newrelic.com/docs/workflow-automation/workflow-examples/basic-patterns/loops)

Pass data through loop iterations

[Conditional logic](https://docs.newrelic.com/docs/workflow-automation/workflow-examples/basic-patterns/conditional-logic)

Use data in switch conditions

[JSON parsing](https://docs.newrelic.com/docs/workflow-automation/workflow-examples/basic-patterns/json-parsing)

Extract and pass JSON data
