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. Defining Channels

Configuration

Like cbmailservices and cbfs, Megaphone creates channels to send Notification instances on. Channels are created by defining provider and any necessary properties.

// config/modules/megaphone.cfc
component {

    function configure() {
        return {
            "channels": {
                // this is the unique name for the channel
                "database": {
		    "provider": "DatabaseProvider@megaphone",
		    "properties": {
                        // this is the default table name
                        "tableName": "megaphone_notifications",
                        "datasource": "megaphone"
                    }
                },
                "db2": {
                    // providers can be used multiple times with different properties
		    "provider": "DatabaseProvider@megaphone",
		    "properties": {
                        "datasource": "db2"
                    }
                },
                "email": {
                    "provider": "EmailProvider@megaphone",
                    "properties": {
                        "mailer": "default",
                        "onSuccess": () => {},
                        "onError": () => {}
                     }
                },
                "slack": {
                    "provider": "SlackProvider@megaphone",
                    "properties": {
                        "token": getSystemSetting( "SLACK_BOT_TOKEN" ),
                        "defaultChannel": "##general"
                     }
                }
            }
        };
    }

}

Each Provider defines the required and optional properties it accepts. Refer to the individual Provider documentation for more information.

PreviousInstallationNextRetrieving Channels

Last updated 1 year ago