Skip to content

Slack: Post message

Posts a message to a Slack channel, as the bot whose token the credential holds.

  • Kind: slack.post_message
  • Palette: Integrations, under Slack
  • Credential: a credential of kind bearer, named in credential
  • Deploy notices, failure alerts and daily summaries in a channel.
  • Anywhere Slack’s own formatting is enough: text takes mrkdwn (*bold*, _italic_, `code`).

Slack answers some failures, such as a channel the bot isn’t in, with a 200 and ok: false. The action reads that flag, so those fail the step with Slack’s reason instead of passing silently.

Field Required Description
channel yes Channel id or name the bot token can post to. For example: #general or C0123ABCD.
Field Type Required Description
text string yes Message text. Slack mrkdwn works: bold, italic, code.

Beside with and input in the node’s config.

Field Type Required Description
credential string yes Name of the project credential the action authenticates with.
fail_on_error_status boolean no Treat any 4xx/5xx as a failure. On by default: an action either did its job or did not. Default true.
optional_when_untrusted boolean no Run without the credential when the run is untrusted (a fork pull request), instead of failing. The credential is still withheld.
retry_on array no Status codes that fail the node instead of returning, so its retry: policy applies (e.g. [429, 503]).

The HTTP response. The reply is under body: nodes.<id>.output.body.<field>.

Field Type Description
status integer The HTTP status code.
headers object The response headers.
body object The response body, parsed as JSON when it is JSON.
body.channel string The channel id posted to.
body.ok boolean
body.ts string The message timestamp, which is its id for replies and edits.
  • On an agent with the connector capability. The managed environments have one, so this needs no agent of your own.
  • One POST request to slack.com.
  • Any 4xx or 5xx fails the step, unless fail_on_error_status is false. retry: asks again after a 5xx, a 401, 408, 409, 423, 425 or 429, or a 4xx with Retry-After, and not after any other 4xx, which would get the same answer.
  • While fail_on_error_status is on, a 2xx reply fails the step too when body.ok is not true, with the reason from body.error.
version: hyperspool-graph/v1
nodes:
- id: deploy
type: shell
config: { run: spool output set version=2.8.1 }
- id: announce
type: slack.post_message
config:
credential: slack
with: { channel: "#deploys" }
input:
text: { $template: "*checkout* {{ nodes.deploy.output.version }} is live" }
edges:
- { from: deploy, to: announce }

The credential is a bot token (xoxb-…): spool credential set slack --kind bearer. The posted message’s id is nodes.announce.output.body.ts, for threading a reply under it.

See Connectors for credentials and versions, and the node reference for every other node.