How to Post a Slack Notification from CircleCI
CircleCI sends Slack messages with the official circleci/slack orb, gated on job status.
Import the circleci/slack orb, set a Slack OAuth token in a context, then add slack/notify steps with an event: filter (fail, pass, always).
Notify Slack on failure
The orb posts to Slack only when the job fails, using the token from the attached context.
.circleci/config.yml
orbs:
slack: circleci/slack@4
jobs:
test:
docker:
- image: cimg/node:20.11
steps:
- checkout
- run: npm ci && npm test
- slack/notify:
event: fail
channel: builds
template: basic_fail_1Gotchas
- The orb needs
SLACK_ACCESS_TOKEN(a Slack app OAuth token) set in a context attached to the job. - Put
slack/notifywithevent: failafter the steps you want to monitor so it captures their result. - Use
event: pass/alwaysfor success or unconditional pings;basic_fail_1is a built-in failure template.
Related guides
How to Post a Slack Notification from GitHub ActionsPost a Slack notification from GitHub Actions with the official slackapi action or an incoming webhook, inclu…
How to Require Manual Approval Before Deploy in CircleCIRequire manual approval before a CircleCI deploy with an approval job type in the workflow, pausing the pipel…