Module for sending messages to Slack
New in version 2015.5.0.
This module can be used by either passing an api key and version directly or by specifying both in a configuration profile in the salt master/minion config.
For example:
slack:
api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15
Send message to Slack incoming webhook.
message -- The topic of message.
attachment -- The message to send to the Slack WebHook.
color -- The color of border of left side
short -- An optional flag indicating whether the value is short enough to be displayed side-by-side with other values.
identifier -- The identifier of the WebHook (the part of the URL
after https://hooks.slack.com/services/). When not
passed on the command line the value is read from the
slack.hook minion configuration option (or the
nested slack: hook: form). The configuration key
is hook, not identifier.
channel -- The channel to use instead of the WebHook default.
username -- Username to use instead of WebHook default.
icon_emoji -- Icon to use instead of WebHook default.
Boolean if message was sent successfully.
CLI Example:
salt '*' slack.call_hook message='Hello, from SaltStack' \
identifier='T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'
Minion configuration example:
slack:
hook: T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Find a room by name and return it.
name -- The room name.
api_key -- The Slack admin api key.
The room object.
CLI Example:
salt '*' slack.find_room name="random"
salt '*' slack.find_room name="random" api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15
Find a user by name and return it.
name -- The user name.
api_key -- The Slack admin api key.
The user object.
CLI Example:
salt '*' slack.find_user name="ThomasHatch"
salt '*' slack.find_user name="ThomasHatch" api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15
List all Slack rooms.
api_key -- The Slack admin api key.
The room list.
CLI Example:
salt '*' slack.list_rooms
salt '*' slack.list_rooms api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15
List all Slack users.
api_key -- The Slack admin api key.
The user list.
CLI Example:
salt '*' slack.list_users
salt '*' slack.list_users api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15
Send a message to a Slack channel.
Changed in version 3003: Added attachments and blocks kwargs
Changed in version 3006.28: from_name is now optional. Slack deprecated the ability for
classic/custom-bot apps to override the bot's display name and icon
via the chat.postMessage API on March 31, 2025 (see
https://api.slack.com/changelog/2024-09-legacy-custom-bots-classic-apps-deprecation).
When from_name or icon is provided, Slack now rejects the
request with legacy_custom_bots_deprecated. Omit both to send
with the bot's configured Slack app identity.
channel -- The channel name, either will work.
message -- The message to send to the Slack channel.
from_name -- Deprecated. Formerly the username override for
the sent message. Slack rejects this for modern
apps; configure the display name in the Slack app
settings instead. Passing this value now logs a
warning and is only forwarded to Slack for
backward compatibility.
api_key -- The Slack api key, if not specified in the configuration.
icon -- Deprecated. Formerly the icon_url override for
the sent message. Slack rejects this for modern
apps; configure the icon in the Slack app settings
instead. Passing this value now logs a warning and
is only forwarded to Slack for backward
compatibility.
attachments -- Any attachments to be sent with the message.
blocks -- Any blocks to be sent with the message.
Boolean if message was sent successfully.
CLI Example:
salt '*' slack.post_message channel="Development Room" message="Build is done"
Docs for previous releases are available on readthedocs.org.
Latest Salt release: 3007.15