SlackMessage

to

Sets the channel, private group, or IM channel to send the message to.

NameTypeRequiredDefaultDescription

channel

string

true

The channel, private group, or IM channel to send the message to.

Return: The SlackMessage instance.

text

Sets the text of the message.

NameTypeRequiredDefaultDescription

text

string

true

The text of the message.

Return: The SlackMessage instance.

actionsBlock

Creates and adds an Actions Block to the message's blocks. After creating the block, it will call the provided callback function to configure the Actions Block.

NameTypeRequiredDefaultDescription

callback

function

true

The callback function to configure the created Actions Block.

Return: The SlackMessage instance.

ActionsBlock

contextBlock

Creates and adds a Context Block to the message's blocks. After creating the block, it will call the provided callback function to configure the Context Block.

NameTypeRequiredDefaultDescription

callback

function

true

The callback function to configure the created Context Block.

Return: The SlackMessage instance.

ContextBlock

dividerBlock

Creates and adds a Divider Block to the message's blocks.

NameTypeRequiredDefaultDescription

No arguments

Return: The SlackMessage instance.

DividerBlock

headerBlock

Creates and adds a Header Block to the message's blocks with the passed-in text. If a callback function is provided, it is called to configure the Header Block.

NameTypeRequiredDefaultDescription

text

string

true

The text for the header.

callback

function

false

null

The callback function to configure the created Header Block.

Return: The SlackMessage instance.

HeaderBlock

imageBlock

Creates and adds an Image Block to the message's blocks with the passed-in imageUrl.

If altText is not provided when constructing the Image Block, it must be provided in the callback.

If a callback function is provided, it is called to configure the Image Block.

NameTypeRequiredDefaultDescription

imageUrl

string

true

The url for the image of the block.

altText

string

false

"" (empty string)

The alt text for the image. If no alt text is provided, it must be configured in the callback.

callback

function

false

null

The callback function to configure the created Image Block.

Return: The SlackMessage instance.

ImageBlock

sectionBlock

Creates and adds a Section Block to the message's blocks.

The provided callback function is called to configure the Section Block.

NameTypeRequiredDefaultDescription

callback

function

true

The callback function to configure the created Section Block.

Return: The SlackMessage instance.

SectionBlock

emoji

Sets the icon of the Slack Message to be the provided emoji.

NameTypeRequiredDefaultDescription

icon

string

true

The emoji code to set as the icon, e.g. :chart_with_upwards_trend:

Return: The SlackMessage instance.

image

Sets the icon of the Slack Message to be the provided image URL.

NameTypeRequiredDefaultDescription

image

string

true

The image URL to set as the icon.

Return: The SlackMessage instance.

metadata

Add metadata for the given event type.

NameTypeRequiredDefaultDescription

eventType

string

true

The event type to track metadata for.

payload

struct

false

{}

The metadata to track.

Return: The SlackMessage instance.

EventMetadata

disableMarkdownParsing

Disables markdown parsing of the Slack Message text.

NameTypeRequiredDefaultDescription

No arguments

Return: The SlackMessage instance.

Pass true to enable unfurling of primarily text-based content.

NameTypeRequiredDefaultDescription

unfurlLinks

boolean

false

true

Boolean flag to unfurl links or not.

Return: The SlackMessage instance.

unfurlMedia

Pass true to enable unfurling of media content.

NameTypeRequiredDefaultDescription

unfurlMedia

boolean

false

true

Boolean flag to unfurl media or not.

Return: The SlackMessage instance.

username

Sets the username for the Slack Bot.

NameTypeRequiredDefaultDescription

username

string

true

The username to use for the Slack Bot.

Return: The SlackMessage instance.

getMemento

Returns a serializable representation of this Slack Message.

NameTypeRequiredDefaultDescription

No arguments

Return: (struct) The serializable Slack Message

Throws: Megaphone.Provider.SlackBlockException

dump

Sends either the memento or a link to the Slack's BlockKit Builder to writeDump.

NameTypeRequiredDefaultDescription

raw

boolean

false

false

If true, outputs the memento of the message. Otherwise, outputs a URL to Slack's BlockKit Builder.

This method also accepts all the same arguments as writeDump.

Return: (void)

when

Control-flow helper to have if / else statements with method chaining.

NameTypeRequiredDefaultDescription

target

boolean

true

The boolean evaluator.

success

function

true

The callback to execute if the boolean value is true.

failure

function

false

null

The optional callback to execute if the boolean value is false.

Return: The SlackMessage instance.

Last updated