Skip to content

How to set Slack channel

Kyle T edited this page Oct 8, 2020 · 1 revision

How to set the channel for the Slack orb.

When utilizing the Slack orb for CircleCI, you will need to have a channel name or channel ID prepared for your messages to send to. You can reference a channel by its direct name in most cases, such as engineering or support (without any #), but names with certain characters are not supported and so it is recommended to instead use the channel ID.

To obtain a Slack channel's ID:

  1. Right click the channel name within your desktop client
  2. From the drop-down context menu, select Copy link.
  3. Extract the ID from the URL copied to your clipboard.

Example:

https://<org>.slack.com/archives/<channel id>

Default Channel

The Slack orb expects a default channel to be selected. In the event no channel parameter is provided to the orb, it will fall back on the channel id value stored in the $SLACK_DEFAULT_CHANNEL environment variable.

This value can be included in the same restricted context holding our OAuth token, which would apply to any project within the org (which uses this context).

Alternatively, the context could not contain the default channel value, and it could instead be set individually on each project: CircleCI environment variables

Custom Channel Parameter (and multiple channels)

To change the channel your message will be sent to, or to send to multiple channels at the same time, utilize the channel parameter of the notify command. The channel parameter can accept one or more channels separated by a comma.