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
  • init
  • id
  • image
  • text
  • getMemento
  1. Reference
  2. BaseProvider
  3. SlackProvider
  4. SlackMessage

ContextBlock

PreviousActionsBlockNextDividerBlock

Last updated 1 year ago

init

Creates an ContextBlock instance.

Slack Docs:

Name
Type
Required
Default
Description

No arguments

Return: The ContextBlock instance.

id

Sets a custom identifier for the ContextBlock instance.

Name
Type
Required
Default
Description

id

string

true

The custom identifier for the ActionsBlock instance.

Return: The ContextBlock instance.

image

Adds an ImageElement to this ContextBlock instance.

Name
Type
Required
Default
Description

imageUrl

string

true

The url for the image.

altText

string

false

"" (empty string)

The alt text for the image.

Return: The new ImageElement instance.

Throws: Megaphone.Provider.SlackBlockException when more than 25 elements are added.

text

Adds a TextObject to this ContextBlock instance.

Name
Type
Required
Default
Description

text

string

true

The text for the TextObject.

Return: The new TextObject instance.

Throws: Megaphone.Provider.SlackBlockException when more than 25 elements are added.

getMemento

Converts the ContextBlock instance to a serializable format.

Name
Type
Required
Default
Description

No arguments

Return: (struct) A struct representing this ContextBlock instance.

Throws: Megaphone.Provider.SlackBlockException when either 0 or more than 25 elements are present.

{
    "type": "context"
    "elements": [ ... ],
    "block_id": "optional"
}
https://api.slack.com/reference/block-kit/blocks#context
ImageElement
TextObject