LogoLogo
  • Introduction
  • What's New?
  • Upgrade Guide
  • Getting Started
    • Requirements
    • Installation
  • Defining Channels
    • Configuration
    • Retrieving Channels
  • Creating and Sending Notifications
    • Defining Notifications
    • Notifiables
    • Sending Notifications
  • Providers
    • DatabaseProvider
    • EmailProvider
    • SlackProvider
      • Slack BlockKit
    • Creating Custom Providers
  • Testing
    • Coming Soon
  • Reference
    • NotificationService
    • BaseNotification
    • SendsNotifications
    • INotifiable
    • BaseProvider
      • DatabaseProvider
        • DatabaseNotificationService
        • HasDatabaseNotifications
        • DatabaseNotificationCursor
        • DatabaseNotification
      • EmailProvider
      • SlackProvider
        • SlackMessage
          • EventMetadata
          • ActionsBlock
          • ContextBlock
          • DividerBlock
          • HeaderBlock
          • ImageBlock
          • SectionBlock
          • ButtonElement
          • ConfirmObject
          • ImageElement
          • TextObject
          • PlainTextOnlyTextObject
  • ForgeBox
  • GitHub
Powered by GitBook
On this page
  • to
  • text
  • actionsBlock
  • contextBlock
  • dividerBlock
  • headerBlock
  • imageBlock
  • sectionBlock
  • emoji
  • image
  • metadata
  • disableMarkdownParsing
  • unfurlLinks
  • unfurlMedia
  • username
  • getMemento
  • dump
  • when
  1. Reference
  2. BaseProvider
  3. SlackProvider

SlackMessage

PreviousSlackProviderNextEventMetadata

Last updated 1 year ago

to

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

Slack Docs:

Name
Type
Required
Default
Description

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.

Slack Docs:

Name
Type
Required
Default
Description

text

string

true

The text of the message.

Return: The SlackMessage instance.

actionsBlock

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

Name
Type
Required
Default
Description

callback

function

true

The callback function to configure the created Actions Block.

Return: The SlackMessage instance.

contextBlock

Name
Type
Required
Default
Description

callback

function

true

The callback function to configure the created Context Block.

Return: The SlackMessage instance.

dividerBlock

Name
Type
Required
Default
Description

No arguments

Return: The SlackMessage instance.

headerBlock

Name
Type
Required
Default
Description

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.

imageBlock

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.

Name
Type
Required
Default
Description

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.

sectionBlock

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

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

Name
Type
Required
Default
Description

callback

function

true

The callback function to configure the created Section Block.

Return: The SlackMessage instance.

emoji

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

Name
Type
Required
Default
Description

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.

Name
Type
Required
Default
Description

image

string

true

The image URL to set as the icon.

Return: The SlackMessage instance.

metadata

Add metadata for the given event type.

Name
Type
Required
Default
Description

eventType

string

true

The event type to track metadata for.

payload

struct

false

{}

The metadata to track.

Return: The SlackMessage instance.

disableMarkdownParsing

Disables markdown parsing of the Slack Message text.

Name
Type
Required
Default
Description

No arguments

Return: The SlackMessage instance.

unfurlLinks

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

Name
Type
Required
Default
Description

unfurlLinks

boolean

false

true

Boolean flag to unfurl links or not.

Return: The SlackMessage instance.

unfurlMedia

Pass true to enable unfurling of media content.

Name
Type
Required
Default
Description

unfurlMedia

boolean

false

true

Boolean flag to unfurl media or not.

Return: The SlackMessage instance.

username

Sets the username for the Slack Bot.

Name
Type
Required
Default
Description

username

string

true

The username to use for the Slack Bot.

Return: The SlackMessage instance.

getMemento

Returns a serializable representation of this Slack Message.

Name
Type
Required
Default
Description

No arguments

Return: (struct) The serializable Slack Message

Throws: Megaphone.Provider.SlackBlockException

dump

Name
Type
Required
Default
Description

raw

boolean

false

false

Return: (void)

when

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

Name
Type
Required
Default
Description

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.

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

Creates and adds a to the message's blocks.

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

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

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

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

This method also accepts all the same arguments as .

https://api.slack.com/methods/chat.postMessage#arg_channel
https://api.slack.com/methods/chat.postMessage#arg_text
Actions Block
ActionsBlock
Context Block
ContextBlock
Divider Block
DividerBlock
Header Block
HeaderBlock
Image Block
ImageBlock
SectionBlock
EventMetadata
BlockKit Builder
writeDump
BlockKit Builder