Skip to main content

Messages

Payload factories for Web API messages, webhooks, and interaction responses.

attachment()

attachment(input, settings?): JsonObject

Creates lower-priority supporting content using Slack's legacy secondary-attachment format.

Attachments can add context beneath a message, while fallback supplies a plain-text summary for notifications and clients that cannot display Block Kit.

Input fields

Attachment blocks plus optional color and fallback text.

Input fieldTypeDescription
blocksJsonObject[]Blocks displayed inside the attachment.
color?stringOptional side-border color: a Color value or a six-digit hex code.
fallback?stringPlain-text fallback for notifications and clients without Block Kit support.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

JsonObject

A Slack attachment object.

Throws

InvalidUsageError when the color is not a valid hex code or a nested block violates a supported Block Kit constraint.

See

https://docs.slack.dev/legacy/legacy-messaging/legacy-secondary-message-attachments


Color

const Color: object

Preset side-border colors for legacy attachments.

The values mirror the Python Color enum: three Slack-recognized aliases (good, warning, danger) plus common hex colors.

Type Declaration

NameTypeDefault value
BLACK"#000000""#000000"
BLUE"#0000ff""#0000ff"
DANGER"danger""danger"
GOOD"good""good"
GREEN"#00ff00""#00ff00"
ORANGE"#ff8800""#ff8800"
PURPLE"#8800ff""#8800ff"
RED"#ff0000""#ff0000"
WARNING"warning""warning"
YELLOW"#ffff00""#ffff00"

message()

message(input, settings?): JsonObject

Creates a payload for Slack Web API message methods such as chat.postMessage.

Input fields

Destination channel and message content.

Input fieldTypeDescription
attachments?JsonObject[]Optional secondary attachments.
blocks?JsonObject[]Block Kit blocks displayed in the message.
channelstringChannel, group, or direct-message conversation identifier.
metadata?JsonObjectOptional message metadata.
mrkdwn?booleanWhether Slack parses text as mrkdwn. Defaults to true.
text?stringNotification and accessibility fallback text.
unfurlLinks?booleanWhether Slack unfurls links.
unfurlMedia?booleanWhether Slack unfurls media.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

JsonObject

A Slack-shaped message payload ready to spread into an SDK call.

Throws

InvalidUsageError when nested Block Kit content is invalid.


MessageInput

Fields accepted by message.

Properties

PropertyTypeDescription
attachments?JsonObject[]Optional secondary attachments.
blocks?JsonObject[]Block Kit blocks displayed in the message.
channelstringChannel, group, or direct-message conversation identifier.
metadata?JsonObjectOptional message metadata.
mrkdwn?booleanWhether Slack parses text as mrkdwn. Defaults to true.
text?stringNotification and accessibility fallback text.
unfurlLinks?booleanWhether Slack unfurls links.
unfurlMedia?booleanWhether Slack unfurls media.

messageResponse()

messageResponse(input, settings?): JsonObject

Creates a response payload for slash commands and interactive requests.

Input fields

Response content, visibility, and replacement behavior.

Input fieldTypeDescription
attachments?JsonObject[]Optional secondary attachments.
blocks?JsonObject[]Block Kit blocks displayed in the response.
mrkdwn?booleanWhether Slack parses text as mrkdwn. Defaults to true.
replaceOriginal?booleanReplace the original interaction message. Defaults to false.
responseType?"ephemeral" | "in_channel"Response visibility. Defaults to in_channel.
text?stringNotification and accessibility fallback text.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

JsonObject

A Slack interaction-response payload.

Throws

InvalidUsageError when nested Block Kit content is invalid.


webhookMessage()

webhookMessage(input, settings?): JsonObject

Creates a payload for an incoming webhook or response URL.

Input fields

Message content, visibility, replacement behavior, and unfurl settings.

Input fieldTypeDescription
attachments?JsonObject[]Optional secondary attachments.
blocks?JsonObject[]Block Kit blocks displayed in the message.
deleteOriginal?booleanDelete the original interaction message.
metadata?JsonObjectOptional message metadata.
replaceOriginal?booleanReplace the original interaction message.
responseType?"ephemeral" | "in_channel"Response visibility for response URLs.
text?stringNotification and accessibility fallback text.
unfurlLinks?booleanWhether Slack unfurls links.
unfurlMedia?booleanWhether Slack unfurls media.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

JsonObject

A Slack webhook-message payload.

Throws

InvalidUsageError when nested Block Kit content is invalid.