Skip to main content

Payloads And Views

This page documents the Ruby API for payloads and views. Values use keyword-only construction, validate before freezing, and serialize to Slack JSON.

Attachment​

A legacy message attachment containing blocks and an optional color bar.

See the Slack reference.

.new​

Construct an immutable, validated value with keyword arguments. Required keywords: blocks.

def self.new: (blocks: Array[Block], ?color: (String)?, ?fallback: (String)?, ?additional_fields: Hash[String | Symbol, untyped]?) -> Attachment
ParameterDescription
blocksAdds the attachment's blocks in display order.
colorSets the attachment's left border color: a six-digit hex color or good, warning, or danger.
fallbackSets plain-text summary shown in clients that cannot display attachments.
additional_fieldsJSON-compatible extension fields that do not replace modeled wire keys.

Returns: Attachment

ThrowsWhen
ValidationErrorA field or cross-field Slack rule fails.

Related types: Attachment, Block

.[]

Keyword-only alias for .new.

def self.[]: (blocks: Array[Block], ?color: (String)?, ?fallback: (String)?, ?additional_fields: Hash[String | Symbol, untyped]?) -> Attachment

Returns: Attachment

Related types: Attachment, Block

blocks​

Adds the attachment's blocks in display order. Wire key: blocks.

def blocks: () -> Array[Block]

Returns: Array[Block]

Related types: Block

color​

Sets the attachment's left border color: a six-digit hex color or good, warning, or danger. Wire key: color.

def color: () -> (String)?

Returns: (String)?

fallback​

Sets plain-text summary shown in clients that cannot display attachments. Wire key: fallback.

def fallback: () -> (String)?

Returns: (String)?

additional_fields​

Return frozen extension fields with normalized string keys.

def additional_fields: () -> Hash[String, untyped]

with​

Return a newly validated value with changed keywords.

def with: (**untyped changes) -> Attachment

Returns: Attachment

Related types: Attachment

to_h​

Return structural Ruby members, including additional_fields. Nested members remain frozen.

def to_h: () -> Hash[Symbol, untyped]

as_json​

Return a fresh, detached Slack wire Hash.

def as_json: (?untyped options) -> Hash[String, untyped]

to_json​

Encode the Slack wire payload as JSON.

def to_json: (?untyped options) -> String

HomeTabView​

The payload for publishing an App Home tab with views.publish.

See the Slack reference.

.new​

Construct an immutable, validated value with keyword arguments. Required keywords: blocks.

def self.new: (blocks: Array[Block], ?private_metadata: (String)?, ?callback_id: (String)?, ?external_id: (String)?, ?additional_fields: Hash[String | Symbol, untyped]?) -> HomeTabView
ParameterDescription
blocksAdds the blocks shown on the App Home tab, in display order.
private_metadataSets application-defined data returned in view payloads.
callback_idSets an identifier returned in view payloads so your app can recognize the view.
external_idSets a workspace-unique identifier you can use to update the view later.
additional_fieldsJSON-compatible extension fields that do not replace modeled wire keys.

Returns: HomeTabView

ThrowsWhen
ValidationErrorA field or cross-field Slack rule fails.

Related types: Block, HomeTabView

.[]​

Keyword-only alias for .new.

def self.[]: (blocks: Array[Block], ?private_metadata: (String)?, ?callback_id: (String)?, ?external_id: (String)?, ?additional_fields: Hash[String | Symbol, untyped]?) -> HomeTabView

Returns: HomeTabView

Related types: Block, HomeTabView

blocks​

Adds the blocks shown on the App Home tab, in display order. Wire key: blocks.

def blocks: () -> Array[Block]

Returns: Array[Block]

Related types: Block

private_metadata​

Sets application-defined data returned in view payloads. Wire key: private_metadata.

def private_metadata: () -> (String)?

Returns: (String)?

callback_id​

Sets an identifier returned in view payloads so your app can recognize the view. Wire key: callback_id.

def callback_id: () -> (String)?

Returns: (String)?

external_id​

Sets a workspace-unique identifier you can use to update the view later. Wire key: external_id.

def external_id: () -> (String)?

Returns: (String)?

additional_fields​

Return frozen extension fields with normalized string keys.

def additional_fields: () -> Hash[String, untyped]

with​

Return a newly validated value with changed keywords.

def with: (**untyped changes) -> HomeTabView

Returns: HomeTabView

Related types: HomeTabView

to_h​

Return structural Ruby members, including additional_fields. Nested members remain frozen.

def to_h: () -> Hash[Symbol, untyped]

as_json​

Return a fresh, detached Slack wire Hash.

def as_json: (?untyped options) -> Hash[String, untyped]

to_json​

Encode the Slack wire payload as JSON.

def to_json: (?untyped options) -> String

MessagePayload​

A complete payload for chat.postMessage and related Web API methods.

See the Slack reference.

.new​

Construct an immutable, validated value with keyword arguments. Required keywords: channel.

def self.new: (channel: String, ?blocks: (Array[Block])?, ?attachments: (Array[Attachment])?, ?text: (String)?, ?mrkdwn: (bool)?, ?unfurl_links: (bool)?, ?unfurl_media: (bool)?, ?metadata: (Hash[String | Symbol, untyped])?, ?additional_fields: Hash[String | Symbol, untyped]?) -> MessagePayload
ParameterDescription
channelSets the ID of the channel, private group, or conversation that receives the message.
blocksAdds the message blocks in display order.
attachmentsAdds legacy attachments in display order.
textSets the fallback text used in notifications and by clients that cannot display blocks.
mrkdwnSets whether Slack formats the top-level text as mrkdwn.
unfurl_linksSets whether Slack unfurls text-based links.
unfurl_mediaSets whether Slack unfurls media links.
metadataSets message metadata as a JSON-compatible map, such as event_type and event_payload.
additional_fieldsJSON-compatible extension fields that do not replace modeled wire keys.

Returns: MessagePayload

ThrowsWhen
ValidationErrorA field or cross-field Slack rule fails.

Related types: Attachment, Block, MessagePayload

.[]​

Keyword-only alias for .new.

def self.[]: (channel: String, ?blocks: (Array[Block])?, ?attachments: (Array[Attachment])?, ?text: (String)?, ?mrkdwn: (bool)?, ?unfurl_links: (bool)?, ?unfurl_media: (bool)?, ?metadata: (Hash[String | Symbol, untyped])?, ?additional_fields: Hash[String | Symbol, untyped]?) -> MessagePayload

Returns: MessagePayload

Related types: Attachment, Block, MessagePayload

channel​

Sets the ID of the channel, private group, or conversation that receives the message. Wire key: channel.

def channel: () -> String

Returns: String

blocks​

Adds the message blocks in display order. Wire key: blocks.

def blocks: () -> (Array[Block])?

Returns: (Array[Block])?

Related types: Block

attachments​

Adds legacy attachments in display order. Wire key: attachments.

def attachments: () -> (Array[Attachment])?

Returns: (Array[Attachment])?

Related types: Attachment

text​

Sets the fallback text used in notifications and by clients that cannot display blocks. Wire key: text.

def text: () -> (String)?

Returns: (String)?

mrkdwn​

Sets whether Slack formats the top-level text as mrkdwn. Wire key: mrkdwn.

def mrkdwn: () -> (bool)?

Returns: (bool)?

Sets whether Slack unfurls text-based links. Wire key: unfurl_links.

def unfurl_links: () -> (bool)?

Returns: (bool)?

unfurl_media​

Sets whether Slack unfurls media links. Wire key: unfurl_media.

def unfurl_media: () -> (bool)?

Returns: (bool)?

metadata​

Sets message metadata as a JSON-compatible map, such as event_type and event_payload. Wire key: metadata.

def metadata: () -> (Hash[String, untyped])?

Returns: (Hash[String, untyped])?

additional_fields​

Return frozen extension fields with normalized string keys.

def additional_fields: () -> Hash[String, untyped]

with​

Return a newly validated value with changed keywords.

def with: (**untyped changes) -> MessagePayload

Returns: MessagePayload

Related types: MessagePayload

to_h​

Return structural Ruby members, including additional_fields. Nested members remain frozen.

def to_h: () -> Hash[Symbol, untyped]

as_json​

Return a fresh, detached Slack wire Hash.

def as_json: (?untyped options) -> Hash[String, untyped]

to_json​

Encode the Slack wire payload as JSON.

def to_json: (?untyped options) -> String

MessageResponse​

A response body for slash commands and interaction response URLs.

See the Slack reference.

.new​

Construct an immutable, validated value with keyword arguments.

def self.new: (?blocks: (Array[Block])?, ?attachments: (Array[Attachment])?, ?text: (String)?, ?mrkdwn: (bool)?, ?replace_original: (bool)?, ?response_type: (:in_channel | :ephemeral)?, ?additional_fields: Hash[String | Symbol, untyped]?) -> MessageResponse
ParameterDescription
blocksAdds the response blocks in display order.
attachmentsAdds legacy attachments in display order.
textSets the fallback text used in notifications and by clients that cannot display blocks.
mrkdwnSets whether Slack formats the top-level text as mrkdwn.
replace_originalSets whether the response replaces the message that triggered it.
response_typeSets who can see the response.
additional_fieldsJSON-compatible extension fields that do not replace modeled wire keys.

Returns: MessageResponse

ThrowsWhen
ValidationErrorA field or cross-field Slack rule fails.

Related types: Attachment, Block, MessageResponse

.[]​

Keyword-only alias for .new.

def self.[]: (?blocks: (Array[Block])?, ?attachments: (Array[Attachment])?, ?text: (String)?, ?mrkdwn: (bool)?, ?replace_original: (bool)?, ?response_type: (:in_channel | :ephemeral)?, ?additional_fields: Hash[String | Symbol, untyped]?) -> MessageResponse

Returns: MessageResponse

Related types: Attachment, Block, MessageResponse

blocks​

Adds the response blocks in display order. Wire key: blocks.

def blocks: () -> (Array[Block])?

Returns: (Array[Block])?

Related types: Block

attachments​

Adds legacy attachments in display order. Wire key: attachments.

def attachments: () -> (Array[Attachment])?

Returns: (Array[Attachment])?

Related types: Attachment

text​

Sets the fallback text used in notifications and by clients that cannot display blocks. Wire key: text.

def text: () -> (String)?

Returns: (String)?

mrkdwn​

Sets whether Slack formats the top-level text as mrkdwn. Wire key: mrkdwn.

def mrkdwn: () -> (bool)?

Returns: (bool)?

replace_original​

Sets whether the response replaces the message that triggered it. Wire key: replace_original.

def replace_original: () -> (bool)?

Returns: (bool)?

response_type​

Sets who can see the response. Wire key: response_type.

def response_type: () -> (:in_channel | :ephemeral)?

Returns: (:in_channel | :ephemeral)?

additional_fields​

Return frozen extension fields with normalized string keys.

def additional_fields: () -> Hash[String, untyped]

with​

Return a newly validated value with changed keywords.

def with: (**untyped changes) -> MessageResponse

Returns: MessageResponse

Related types: MessageResponse

to_h​

Return structural Ruby members, including additional_fields. Nested members remain frozen.

def to_h: () -> Hash[Symbol, untyped]

as_json​

Return a fresh, detached Slack wire Hash.

def as_json: (?untyped options) -> Hash[String, untyped]

to_json​

Encode the Slack wire payload as JSON.

def to_json: (?untyped options) -> String

ModalView​

The view payload for views.open, views.push, and views.update.

See the Slack reference.

.new​

Construct an immutable, validated value with keyword arguments. Required keywords: title, blocks.

def self.new: (title: String | PlainText, blocks: Array[Block], ?close: (String | PlainText)?, ?submit: (String | PlainText)?, ?private_metadata: (String)?, ?callback_id: (String)?, ?clear_on_close: (bool)?, ?notify_on_close: (bool)?, ?external_id: (String)?, ?submit_disabled: (bool)?, ?additional_fields: Hash[String | Symbol, untyped]?) -> ModalView
ParameterDescription
titleSets the title in the modal's top bar.
blocksAdds the blocks shown in the modal, in display order.
closeSets the label of the button that closes the modal.
submitSets the label of the button that submits the modal.
private_metadataSets application-defined data returned in view payloads.
callback_idSets an identifier returned in view payloads so your app can recognize the view.
clear_on_closeSets whether closing this modal closes every view in its stack.
notify_on_closeSets whether Slack sends a view_closed event when the user closes the modal.
external_idSets a workspace-unique identifier you can use to update the view later.
submit_disabledSets whether the submit button starts disabled. Only valid in workflow configuration modals.
additional_fieldsJSON-compatible extension fields that do not replace modeled wire keys.

Returns: ModalView

ThrowsWhen
ValidationErrorA field or cross-field Slack rule fails.

Related types: Block, ModalView, PlainText

.[]​

Keyword-only alias for .new.

def self.[]: (title: String | PlainText, blocks: Array[Block], ?close: (String | PlainText)?, ?submit: (String | PlainText)?, ?private_metadata: (String)?, ?callback_id: (String)?, ?clear_on_close: (bool)?, ?notify_on_close: (bool)?, ?external_id: (String)?, ?submit_disabled: (bool)?, ?additional_fields: Hash[String | Symbol, untyped]?) -> ModalView

Returns: ModalView

Related types: Block, ModalView, PlainText

title​

Sets the title in the modal's top bar. Wire key: title.

def title: () -> PlainText

Returns: PlainText

Related types: PlainText

blocks​

Adds the blocks shown in the modal, in display order. Wire key: blocks.

def blocks: () -> Array[Block]

Returns: Array[Block]

Related types: Block

close​

Sets the label of the button that closes the modal. Wire key: close.

def close: () -> (PlainText)?

Returns: (PlainText)?

Related types: PlainText

submit​

Sets the label of the button that submits the modal. Wire key: submit.

def submit: () -> (PlainText)?

Returns: (PlainText)?

Related types: PlainText

private_metadata​

Sets application-defined data returned in view payloads. Wire key: private_metadata.

def private_metadata: () -> (String)?

Returns: (String)?

callback_id​

Sets an identifier returned in view payloads so your app can recognize the view. Wire key: callback_id.

def callback_id: () -> (String)?

Returns: (String)?

clear_on_close​

Sets whether closing this modal closes every view in its stack. Wire key: clear_on_close.

def clear_on_close: () -> (bool)?

Returns: (bool)?

notify_on_close​

Sets whether Slack sends a view_closed event when the user closes the modal. Wire key: notify_on_close.

def notify_on_close: () -> (bool)?

Returns: (bool)?

external_id​

Sets a workspace-unique identifier you can use to update the view later. Wire key: external_id.

def external_id: () -> (String)?

Returns: (String)?

submit_disabled​

Sets whether the submit button starts disabled. Only valid in workflow configuration modals. Wire key: submit_disabled.

def submit_disabled: () -> (bool)?

Returns: (bool)?

additional_fields​

Return frozen extension fields with normalized string keys.

def additional_fields: () -> Hash[String, untyped]

with​

Return a newly validated value with changed keywords.

def with: (**untyped changes) -> ModalView

Returns: ModalView

Related types: ModalView

to_h​

Return structural Ruby members, including additional_fields. Nested members remain frozen.

def to_h: () -> Hash[Symbol, untyped]

as_json​

Return a fresh, detached Slack wire Hash.

def as_json: (?untyped options) -> Hash[String, untyped]

to_json​

Encode the Slack wire payload as JSON.

def to_json: (?untyped options) -> String

ResponseType​

Visibility of a slash-command or interaction response. Pass the wire symbol to constructor keywords.

ConstantSlack valueMeaning
IN_CHANNEL:in_channelVisible to everyone in the channel.
EPHEMERAL:ephemeralVisible only to the user who triggered the response.

WebhookMessage​

A payload for incoming webhooks.

See the Slack reference.

.new​

Construct an immutable, validated value with keyword arguments.

def self.new: (?blocks: (Array[Block])?, ?attachments: (Array[Attachment])?, ?text: (String)?, ?response_type: (:in_channel | :ephemeral)?, ?replace_original: (bool)?, ?delete_original: (bool)?, ?unfurl_links: (bool)?, ?unfurl_media: (bool)?, ?metadata: (Hash[String | Symbol, untyped])?, ?additional_fields: Hash[String | Symbol, untyped]?) -> WebhookMessage
ParameterDescription
blocksAdds the message blocks in display order.
attachmentsAdds legacy attachments in display order.
textSets the fallback text used in notifications and by clients that cannot display blocks.
response_typeSets who can see the response.
replace_originalSets whether the response replaces the message that triggered it.
delete_originalSets whether the response deletes the message that triggered it.
unfurl_linksSets whether Slack unfurls text-based links.
unfurl_mediaSets whether Slack unfurls media links.
metadataSets message metadata as a JSON-compatible map, such as event_type and event_payload.
additional_fieldsJSON-compatible extension fields that do not replace modeled wire keys.

Returns: WebhookMessage

ThrowsWhen
ValidationErrorA field or cross-field Slack rule fails.

Related types: Attachment, Block, WebhookMessage

.[]​

Keyword-only alias for .new.

def self.[]: (?blocks: (Array[Block])?, ?attachments: (Array[Attachment])?, ?text: (String)?, ?response_type: (:in_channel | :ephemeral)?, ?replace_original: (bool)?, ?delete_original: (bool)?, ?unfurl_links: (bool)?, ?unfurl_media: (bool)?, ?metadata: (Hash[String | Symbol, untyped])?, ?additional_fields: Hash[String | Symbol, untyped]?) -> WebhookMessage

Returns: WebhookMessage

Related types: Attachment, Block, WebhookMessage

blocks​

Adds the message blocks in display order. Wire key: blocks.

def blocks: () -> (Array[Block])?

Returns: (Array[Block])?

Related types: Block

attachments​

Adds legacy attachments in display order. Wire key: attachments.

def attachments: () -> (Array[Attachment])?

Returns: (Array[Attachment])?

Related types: Attachment

text​

Sets the fallback text used in notifications and by clients that cannot display blocks. Wire key: text.

def text: () -> (String)?

Returns: (String)?

response_type​

Sets who can see the response. Wire key: response_type.

def response_type: () -> (:in_channel | :ephemeral)?

Returns: (:in_channel | :ephemeral)?

replace_original​

Sets whether the response replaces the message that triggered it. Wire key: replace_original.

def replace_original: () -> (bool)?

Returns: (bool)?

delete_original​

Sets whether the response deletes the message that triggered it. Wire key: delete_original.

def delete_original: () -> (bool)?

Returns: (bool)?

Sets whether Slack unfurls text-based links. Wire key: unfurl_links.

def unfurl_links: () -> (bool)?

Returns: (bool)?

unfurl_media​

Sets whether Slack unfurls media links. Wire key: unfurl_media.

def unfurl_media: () -> (bool)?

Returns: (bool)?

metadata​

Sets message metadata as a JSON-compatible map, such as event_type and event_payload. Wire key: metadata.

def metadata: () -> (Hash[String, untyped])?

Returns: (Hash[String, untyped])?

additional_fields​

Return frozen extension fields with normalized string keys.

def additional_fields: () -> Hash[String, untyped]

with​

Return a newly validated value with changed keywords.

def with: (**untyped changes) -> WebhookMessage

Returns: WebhookMessage

Related types: WebhookMessage

to_h​

Return structural Ruby members, including additional_fields. Nested members remain frozen.

def to_h: () -> Hash[Symbol, untyped]

as_json​

Return a fresh, detached Slack wire Hash.

def as_json: (?untyped options) -> Hash[String, untyped]

to_json​

Encode the Slack wire payload as JSON.

def to_json: (?untyped options) -> String