---
title: Send a report to Slack
source: https://docs.newrelic.com/docs/workflow-automation/workflow-examples/integrations/slack
---

Execute NRQL query, convert results to CSV, and post to Slack.

**Requirements:**

-   NRQL query
-   Slack token in secrets.

**What this workflow does:**

-   Execute NRQL query against New Relic account
-   Generate CSV from query results
-   Post CSV to Slack channel with message

**Key actions**: `newrelic.nrdb.query`, `utils.transform.toCSV`, `slack.chat.postMessage`

```yaml
  name: nrqlToSlackReport

  workflowInputs:
    accountId:
      type: Int
    nrqlQuery:
      type: String
      defaultValue: 'FROM Transaction SELECT count(*) FACET appName SINCE 1 hour ago'
    slackChannel:
      type: String

  steps:
    - name: queryData
      type: action
      action: newrelic.nrdb.query
      version: 1
      inputs:
        accountIds:
          - ${{ .workflowInputs.accountId }}
        query: ${{ .workflowInputs.nrqlQuery }}

    - name: convertToCSV
      type: action
      action: utils.transform.toCSV
      version: 1
      inputs:
        data: ${{ .steps.queryData.outputs.results | tostring }}

    - name: postToSlack
      type: action
      action: slack.chat.postMessage
      version: 1
      inputs:
        token: ${{ :secrets:slack_token }}
        channel: ${{ .workflowInputs.slackChannel }}
        text: 'NRQL Query Report'
        attachment:
          filename: 'query-results.csv'
          content: ${{ .steps.convertToCSV.outputs.csv }}
```

## Related topics [#related-topics]

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

Build approval workflows with switch statements

[Create destinations](https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/create-destinations)

Configure Slack bot and channels

[Slack actions](https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/actions-catalog/slack/slack-chat)

Complete Slack action reference
