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 incredential
When to use
Section titled “When to use”- Deploy notices, failure alerts and daily summaries in a channel.
- Anywhere Slack’s own formatting is enough:
texttakes 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.
Connection (with)
Section titled “Connection (with)”| Field | Required | Description |
|---|---|---|
channel |
yes | Channel id or name the bot token can post to. For example: #general or C0123ABCD. |
Input (input)
Section titled “Input (input)”| Field | Type | Required | Description |
|---|---|---|---|
text |
string | yes | Message text. Slack mrkdwn works: bold, italic, code. |
Settings
Section titled “Settings”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]). |
Output
Section titled “Output”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. |
How it runs
Section titled “How it runs”- On an agent with the
connectorcapability. The managed environments have one, so this needs no agent of your own. - One
POSTrequest toslack.com. - Any 4xx or 5xx fails the step, unless
fail_on_error_statusisfalse.retry:asks again after a 5xx, a 401, 408, 409, 423, 425 or 429, or a 4xx withRetry-After, and not after any other 4xx, which would get the same answer. - While
fail_on_error_statusis on, a 2xx reply fails the step too whenbody.okis nottrue, with the reason frombody.error.
Example
Section titled “Example”version: hyperspool-graph/v1nodes: - 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.