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
  1. Providers
  2. SlackProvider

Slack BlockKit

PreviousSlackProviderNextCreating Custom Providers

Last updated 1 year ago

Megaphone provides a fluent BlockKit API to build a SlackMessage. It starts by calling the newSlackMessage provided to the toSlack method on the Notification.

function toSlack( notifiable, newSlackMessage ) {
    return newSlackMessage();
}

For the individual methods and building blocks, please see the reference documentation.

An important callout is the dump method. This method can writeDump a memento of the SlackMessage instance when passing the raw parameter as true. The default, however, is to writeDump a URL that takes you to Slack's to visually see your message.

public void function dump(
    boolean raw = false,
    string output = "browser",
    string format = "html",
    boolean abort = false,
    string label = "",
    boolean metainfo = false,
    numeric top = 9999,
    string show = "",
    string hide = "",
    numeric keys = 9999,
    boolean expand = true,
    boolean showUDFs = true
);

Example URL:

SlackMessage
BlockKit Builder
https://app.slack.com/block-kit-builder/TBHQJRCEN#%7B%22blocks%22:%5B%7B%22text%22:%7B%22text%22:%22Invoice%20Paid%22,%22type%22:%22plain_text%22%7D,%22type%22:%22header%22%7D,%7B%22elements%22:%5B%7B%22text%22:%22Customer%20%231234%22,%22type%22:%22plain_text%22%7D%5D,%22type%22:%22context%22%7D,%7B%22fields%22:%5B%7B%22text%22:%22*Invoice%20No:*%5Cn1000%22,%22type%22:%22mrkdwn%22%7D,%7B%22text%22:%22*Invoice%20Recipient:*%5Cneric@ortussolutions.com%22,%22type%22:%22mrkdwn%22%7D%5D,%22text%22:%7B%22text%22:%22An%20invoice%20has%20been%20paid.%22,%22type%22:%22plain_text%22%7D,%22type%22:%22section%22%7D,%7B%22type%22:%22divider%22%7D,%7B%22text%22:%7B%22text%22:%22Congratulations!%22,%22type%22:%22plain_text%22%7D,%22type%22:%22section%22%7D%5D%7D