Skip to main content

Payloads

Fluent builders for complete messages, interaction responses, webhooks, secondary attachments, modals, and App Home tabs. Their built objects can be passed directly to the corresponding Slack SDK or HTTP API method.

Attachment()

function Attachment(): FluentBuilder<{
blocks: JsonObject[];
color?: string;
fallback?: string;
}, JsonObject>;

Creates lower-priority supporting content using Slack's legacy secondary attachment format. Attachments add context beneath a message, while fallback() supplies text for notifications and clients that cannot display Block Kit.

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

Chainable setters

Call these setters in any order before .build(). Repeating a singular setter replaces its previous value. Collection setters accept individual values, nested builders, or arrays and append each call.

SetterValue typeRequiredDescription
.blocks(...values)
JsonObject[]
YesBlocks displayed inside the attachment.
.color(value)stringNoOptional side-border color: a Color value or a six-digit hex code.
.fallback(value)stringNoPlain-text fallback for notifications and clients without Block Kit support.

Validation and errors

.build() materializes nested builders and validates the finished Slack object. It throws a typed slackblocks validation error when a required value is missing, a value has the wrong type or range, mutually exclusive setters are combined, or Slack rejects the resulting shape. Pass { validate: false } to .build() only when intentionally creating an intermediate partial object.

Returns

FluentBuilder<{ blocks: JsonObject[]; color?: string; fallback?: string; }, JsonObject>


HomeTab()

function HomeTab(): FluentBuilder<{
blocks: JsonObject[];
callbackId?: string;
externalId?: string;
privateMetadata?: string;
}, SlackObject<"home">>;

Creates an App Home tab view for Slack's views.publish method. Add up to 100 compatible blocks and optional identifiers or private metadata for the application.

See: https://docs.slack.dev/surfaces/app-home.

Chainable setters

Call these setters in any order before .build(). Repeating a singular setter replaces its previous value. Collection setters accept individual values, nested builders, or arrays and append each call.

SetterValue typeRequiredDescription
.blocks(...values)
JsonObject[]
YesBetween one and 100 App Home-compatible blocks.
.privateMetadata(value)stringNoOpaque application metadata returned with view interactions.
.callbackId(value)stringNoApplication-defined callback identifier.
.externalId(value)stringNoApplication-defined external identifier.

Validation and errors

.build() materializes nested builders and validates the finished Slack object. It throws a typed slackblocks validation error when a required value is missing, a value has the wrong type or range, mutually exclusive setters are combined, or Slack rejects the resulting shape. Pass { validate: false } to .build() only when intentionally creating an intermediate partial object.

Returns

FluentBuilder<{ blocks: JsonObject[]; callbackId?: string; externalId?: string; privateMetadata?: string; }, SlackObject<"home">>


Message()

function Message(): FluentBuilder<MessageInput, JsonObject>;

Creates a message payload for Slack Web API methods such as chat.postMessage. Set the destination channel and add Block Kit blocks, secondary attachments, fallback text, metadata, or unfurl behavior as needed.

See: https://docs.slack.dev/reference/methods/chat.postMessage.

Chainable setters

Call these setters in any order before .build(). Repeating a singular setter replaces its previous value. Collection setters accept individual values, nested builders, or arrays and append each call.

SetterValue typeRequiredDescription
.channel(value)stringYesChannel, group, or direct-message conversation identifier.
.blocks(...values)
JsonObject[]
NoBlock Kit blocks displayed in the message.
.attachments(...values)
JsonObject[]
NoOptional secondary attachments.
.text(value)stringNoNotification and accessibility fallback text.
.mrkdwn(value)booleanNoWhether Slack parses text as mrkdwn. Defaults to true.
.unfurlLinks(value)booleanNoWhether Slack unfurls links.
.unfurlMedia(value)booleanNoWhether Slack unfurls media.
.metadata(value)
JsonObject
NoOptional message metadata.

Validation and errors

.build() materializes nested builders and validates the finished Slack object. It throws a typed slackblocks validation error when a required value is missing, a value has the wrong type or range, mutually exclusive setters are combined, or Slack rejects the resulting shape. Pass { validate: false } to .build() only when intentionally creating an intermediate partial object.

Returns

FluentBuilder<MessageInput, JsonObject>


MessageInput

Destination, Block Kit content, fallback text, attachments, metadata, and unfurl behavior for a Slack Web API message payload.

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()

function MessageResponse(): FluentBuilder<{
attachments?: JsonObject[];
blocks?: JsonObject[];
mrkdwn?: boolean;
replaceOriginal?: boolean;
responseType?: "ephemeral" | "in_channel";
text?: string;
}, JsonObject>;

Creates the immediate response payload returned for a slash command or interactive request. Configure its blocks, fallback text, visibility, and whether it replaces the original interaction message.

See: https://docs.slack.dev/interactivity/implementing-slash-commands#responding_to_commands.

Chainable setters

Call these setters in any order before .build(). Repeating a singular setter replaces its previous value. Collection setters accept individual values, nested builders, or arrays and append each call.

SetterValue typeRequiredDescription
.blocks(...values)
JsonObject[]
NoBlock Kit blocks displayed in the response.
.attachments(...values)
JsonObject[]
NoOptional secondary attachments.
.text(value)stringNoNotification and accessibility fallback text.
.mrkdwn(value)booleanNoWhether Slack parses text as mrkdwn. Defaults to true.
.replaceOriginal(value)booleanNoReplace the original interaction message. Defaults to false.
.responseType(value)"ephemeral" | "in_channel"NoResponse visibility. Defaults to in_channel.

Validation and errors

.build() materializes nested builders and validates the finished Slack object. It throws a typed slackblocks validation error when a required value is missing, a value has the wrong type or range, mutually exclusive setters are combined, or Slack rejects the resulting shape. Pass { validate: false } to .build() only when intentionally creating an intermediate partial object.

Returns

FluentBuilder<{ attachments?: JsonObject[]; blocks?: JsonObject[]; mrkdwn?: boolean; replaceOriginal?: boolean; responseType?: "ephemeral" | "in_channel"; text?: string; }, JsonObject>


function Modal(): FluentBuilder<{
blocks: JsonObject[];
callbackId?: string;
clearOnClose?: boolean;
close?: TextLike;
externalId?: string;
notifyOnClose?: boolean;
privateMetadata?: string;
submit?: TextLike;
submitDisabled?: boolean;
title: TextLike;
}, SlackObject<"modal">>;

Creates a modal view for Slack's views.open, views.update, and views.push methods. Configure the title, compatible blocks, controls, metadata, and close behavior before building the payload.

See: https://docs.slack.dev/surfaces/modals.

Chainable setters

Call these setters in any order before .build(). Repeating a singular setter replaces its previous value. Collection setters accept individual values, nested builders, or arrays and append each call.

SetterValue typeRequiredDescription
.title(value)
TextLike
YesPlain-text modal title, up to 24 characters.
.blocks(...values)
JsonObject[]
YesBetween one and 100 modal-compatible blocks.
.close(value)
TextLike
NoOptional plain-text close-button label.
.submit(value)
TextLike
NoOptional plain-text submit-button label.
.privateMetadata(value)stringNoOpaque application metadata returned with view interactions.
.callbackId(value)stringNoApplication-defined callback identifier.
.clearOnClose(value)booleanNoClose every view above this modal when it closes.
.notifyOnClose(value)booleanNoSend a view_closed event when the modal closes.
.externalId(value)stringNoApplication-defined external identifier.
.submitDisabled(value)booleanNoKeep the submit button disabled until an input changes.

Validation and errors

.build() materializes nested builders and validates the finished Slack object. It throws a typed slackblocks validation error when a required value is missing, a value has the wrong type or range, mutually exclusive setters are combined, or Slack rejects the resulting shape. Pass { validate: false } to .build() only when intentionally creating an intermediate partial object.

Returns

FluentBuilder<{ blocks: JsonObject[]; callbackId?: string; clearOnClose?: boolean; close?: TextLike; externalId?: string; notifyOnClose?: boolean; privateMetadata?: string; submit?: TextLike; submitDisabled?: boolean; title: TextLike; }, SlackObject<"modal">>


WebhookMessage()

function WebhookMessage(): FluentBuilder<{
attachments?: JsonObject[];
blocks?: JsonObject[];
deleteOriginal?: boolean;
metadata?: JsonObject;
replaceOriginal?: boolean;
responseType?: "ephemeral" | "in_channel";
text?: string;
unfurlLinks?: boolean;
unfurlMedia?: boolean;
}, JsonObject>;

Creates a payload for an incoming webhook or an interaction response URL. Unlike a Web API message, this form can replace or delete the original message and does not require a destination channel field.

See: https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks.

Chainable setters

Call these setters in any order before .build(). Repeating a singular setter replaces its previous value. Collection setters accept individual values, nested builders, or arrays and append each call.

SetterValue typeRequiredDescription
.blocks(...values)
JsonObject[]
NoBlock Kit blocks displayed in the message.
.attachments(...values)
JsonObject[]
NoOptional secondary attachments.
.text(value)stringNoNotification and accessibility fallback text.
.responseType(value)"ephemeral" | "in_channel"NoResponse visibility for response URLs.
.replaceOriginal(value)booleanNoReplace the original interaction message.
.deleteOriginal(value)booleanNoDelete the original interaction message.
.unfurlLinks(value)booleanNoWhether Slack unfurls links.
.unfurlMedia(value)booleanNoWhether Slack unfurls media.
.metadata(value)
JsonObject
NoOptional message metadata.

Validation and errors

.build() materializes nested builders and validates the finished Slack object. It throws a typed slackblocks validation error when a required value is missing, a value has the wrong type or range, mutually exclusive setters are combined, or Slack rejects the resulting shape. Pass { validate: false } to .build() only when intentionally creating an intermediate partial object.

Returns

FluentBuilder<{ attachments?: JsonObject[]; blocks?: JsonObject[]; deleteOriginal?: boolean; metadata?: JsonObject; replaceOriginal?: boolean; responseType?: "ephemeral" | "in_channel"; text?: string; unfurlLinks?: boolean; unfurlMedia?: boolean; }, JsonObject>