Skip to main content

Slack bot setup

Use a bot to send reports to multiple channels or put failure, global error, and flaky details in a thread. Complete the installation prerequisites first.

Create and authorize the Slack appโ€‹

You need permission to create and install an app in your workspace; your administrator may need to approve it. The screenshots illustrate the setup flow; Slack may change the appearance of these screens.

  1. Navigate to https://api.slack.com/apps
  2. Click the Create New App button and select "From scratch"

Navigate to https://api.slack.com/apps

  1. Input a name for your app and select the target workspace, then click on the Create App button

Input a name for your app and select the target workspace

  1. Under the Features menu, select OAuth & Permissions and scroll down to Scopes section

Under the Features menu select

  1. Click the Add an OAuth Scope button and select the following scopes:

Click the Add an OAuth Scope

  • chat:write
  • chat:write.public
  • chat:write.customize
  1. Scroll up to the OAuth Tokens for Your Workspace and click the Install to Workspace button

Install

You will be prompted with the message below, click the Allow button

click the Allow button

The final step will be to copy the generated Bot User OAuth Token aka SLACK_BOT_USER_OAUTH_TOKEN.

Treat this token as a secret.

Final

Configure the reporter and run testsโ€‹

Configure the reporter with one or more channel names:

import { defineConfig } from '@playwright/test';

export default defineConfig({
reporter: [
['dot'],
[
'./node_modules/playwright-slack-report/dist/src/SlackReporter.js',
{
channels: ['pw-tests', 'ci'],
sendResults: 'always',
showInThread: true,
},
],
],
});

Run your tests by providing your SLACK_BOT_USER_OAUTH_TOKEN as an environment variable or specifying slackOAuthToken option in the config:

Bash / zsh

export SLACK_BOT_USER_OAUTH_TOKEN='xoxb-your-bot-token'
npx playwright test

PowerShell

$env:SLACK_BOT_USER_OAUTH_TOKEN = 'xoxb-your-bot-token'
npx playwright test

Public channel names work with the scopes above. For private channels, invite the bot to the channel and configure its channel ID. Slack requires membership for private-channel delivery; see Slack channel permissions.

The reporter posts a summary to each configured channel when the run completes. With showInThread: true, details appear beneath the parent summary. Do not also configure slackWebHookUrl.

Next stepsโ€‹

See Configuration to route successful and unsuccessful runs separately, control notification rules, and add metadata. For existing JSON results, use CLI bot delivery.