Skip to content
Latchkey

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_1

Gotchas

  • The orb needs SLACK_ACCESS_TOKEN (a Slack app OAuth token) set in a context attached to the job.
  • Put slack/notify with event: fail after the steps you want to monitor so it captures their result.
  • Use event: pass/always for success or unconditional pings; basic_fail_1 is a built-in failure template.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →