---
title: Slack integration
description: Learn how to post a summary of each Allure Report 3 run to a Slack channel, using an incoming webhook or a bot token.
---

# Slack integration (Allure 3)

Allure Report 3 can post a summary of each run to a Slack channel. The `slack` plugin that does this is included in the `allure` package.

Images: /images/integrations/slack/message-light.png, /images/integrations/slack/message-dark.png

The message contains the number of tests with each status and the list of failed and broken tests, by their full names. Statuses without tests are not listed.

There are two ways to post the message:

- [with an incoming webhook](#post-with-an-incoming-webhook) - the simplest setup, the message always goes to the channel selected for the webhook;
- [with a bot token](#post-with-a-bot-token) - the message goes to the channel set in the Allure configuration, and the Slack app must be a member of the channel.

## Post with an incoming webhook

1. In [Slack API: Applications](https://api.slack.com/apps), create a new app for your workspace.

1. In the settings of the app, open **Incoming Webhooks**, turn on **Activate Incoming Webhooks**, and click **Add New Webhook**. Select the channel for the messages and copy the webhook URL.

1. Pass the URL to Allure in the `ALLURE_SLACK_WEBHOOK` environment variable, for example, as a secret of your CI pipeline.

   Anyone who knows the URL can post to the channel, so don't keep it in the configuration file or anywhere else under version control.

1. Add the `slack` plugin to the `plugins` section of the [configuration file](/docs/v3/configure/), next to the plugin of your report:

   **allurerc.mjs:**
   ```javascript
   import { defineConfig } from "allure";

   export default defineConfig({
     plugins: {
       awesome: {},
       slack: {},
     },
   });
   ```

   **allurerc.json:**
   ```json
   {
     "plugins": {
       "awesome": {},
       "slack": {}
     }
   }
   ```

   **allurerc.yaml:**
   ```yaml
   plugins:
     awesome: {}
     slack: {}
   ```

After generating the report, Allure posts the message to the channel.

## Post with a bot token

1. In [Slack API: Applications](https://api.slack.com/apps), create a new app for your workspace.

1. In the settings of the app, open **OAuth & Permissions** and add the `chat:write` scope to **Bot Token Scopes**. Then install the app to your workspace and copy the **Bot User OAuth Token**.

1. In Slack, add the app to the channel for the messages, for example, by typing `/invite @app-name` in the channel.

1. Pass the token and the channel to Allure in the `ALLURE_SLACK_TOKEN` and `ALLURE_SLACK_CHANNEL` environment variables. The channel can be set by its ID, such as `C0123456789`, or by its name, such as `test-results` or `#test-results`.

1. Add the `slack` plugin to the configuration file, the same way as for the [incoming webhook](#post-with-an-incoming-webhook).

If both a webhook URL and a token are provided, Allure uses the webhook.

## Options

All options can also be provided via environment variables. If an option is set in the configuration file, the environment variable is not used.

| Option    | Environment variable   | Description                                                       |
| --------- | ---------------------- | ----------------------------------------------------------------- |
| `webhook` | `ALLURE_SLACK_WEBHOOK` | Incoming webhook URL. If set, `token` and `channel` are not used. |
| `token`   | `ALLURE_SLACK_TOKEN`   | Bot token of the Slack app.                                       |
| `channel` | `ALLURE_SLACK_CHANNEL` | ID or name of the channel to post to with the bot token.          |

For example, to set the channel in the configuration file and keep only the token in the environment:

**allurerc.mjs:**
```javascript
import { defineConfig } from "allure";

export default defineConfig({
  plugins: {
    awesome: {},
    slack: {
      options: {
        channel: "test-results",
      },
    },
  },
});
```

**allurerc.json:**
```json
{
  "plugins": {
    "awesome": {},
    "slack": {
      "options": {
        "channel": "test-results"
      }
    }
  }
}
```

**allurerc.yaml:**
```yaml
plugins:
  awesome: {}
  slack:
    options:
      channel: test-results
```

## Troubleshooting

If Allure can't post the message, it prints the error to the console and generates the report anyway. The error contains the error code that Slack returned, for example:

```plain
plugin slack error Error: slack error: not_in_channel
```

- `not_in_channel` - the app is not a member of the channel. Add the app to the channel.
- `channel_not_found` - there is no channel with this ID or name, or the app can't see it.
- `invalid_auth` - the token is not valid.
- `invalid_arguments` - the channel is not set.
