Integrations
Slack
APIs
Send Message

Send a message

Send a message to a channel, user, or group.

Required scopes:

  • chat:write

For more information on the API for sending a message, see chat.postMessage (opens in a new tab).

SDK Import:

from admyral.actions import send_slack_message

Arguments:

Argument NameDescriptionRequired
Channel ID channel_idChannel, private group, or user to send a message to. For channels, you can use the name (e.g. #my-channel) or the ID. For private channels and groups, use the ID. For DMs to users, use the user ID.Yes
Text textThe purpose of this field changes depends on whether the blocks field is used. If blocks is used, this is used as a fallback string to display in notifications. If blocks is not used, this is the main body text of the message. It can be formatted as plain text, or with mrkdwn.-
Blocks blocksA JSON-based array of structured blocks (Example: [{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]). See here (opens in a new tab) for more information about blocks.-

Tip: Slack offers an online Block Kit Builder (opens in a new tab) to help you create blocks for your messages more easily.

Returns

A JSON object.

Required Secrets

Secret PlaceholderDescription
SLACK_SECRETSlack secret. See Slack setup

SDK Example

cases = send_slack_message(
	channel_id="A43SP3KV1L2",
	text="Example slack message",
	secrets={
		"SLACK_SECRET": "my_stored_slack_secret"
	}
)

Example Output:

{
	"ok": true,
	"ts": "1716658341.471459",
	"channel": "C06QP0KV1L2",
	"message": {
		"ts": "1716658341.471459",
		"team": "T06DB7NEYJG",
		"text": "test reply",
		"type": "message",
		"user": "U074PMEF89M",
		"app_id": "A0751AEHE13",
		"blocks": [
			{
				"text": {
					"text": "New Paid Time Off request from <example.com|Fred Enriquez>\n\n<https://example.com|View request>",
					"type": "mrkdwn",
					"verbatim": false
				},
				"type": "section",
				"block_id": "BHeQA"
			}
		],
		"bot_id": "B075T2B0BUY",
		"bot_profile": {
			"id": "B075T2B0BUY",
			"name": "Admyral",
			"icons": {
				"image_36": "https://a.slack-edge.com/80588/img/plugins/app/bot_36.png",
				"image_48": "https://a.slack-edge.com/80588/img/plugins/app/bot_48.png",
				"image_72": "https://a.slack-edge.com/80588/img/plugins/app/service_72.png"
			},
			"app_id": "A0751AEHE13",
			"deleted": false,
			"team_id": "T06DB7NEYJG",
			"updated": 1716648265
		}
	},
	"warning": "missing_charset",
	"response_metadata": {
		"warnings": ["missing_charset"]
	}
}