ℹ️ This plugin requires
v4.7.1
or newer of Nebula Logger's unlocked package
Adds a Slack integration for the unlocked package edition of Nebula Logger. Any logs with log entries that meet a certain (configurable) logging level will automatically be posted to your Slack channel via an asynchronous Queueable
job.
This plugin includes some add-on metadata for Nebula Logger to support the Slack integration
- Apex class
SlackLoggerPlugin
and corresponding tests inSlackLoggerPlugin_Tests
- Plugin configuration details stored in Logger's CMDT objects
LoggerPlugin__mdt
andLoggerParameter__mdt
- Custom fields
Log__c.SendSlackNotification__c
andLog__c.SlackNotificationDate__c
- Field-level security (FLS) via a new permission set
LoggerSlackPluginAdmin
to provide access to the custom Slack fields - Two custom list views for the
Log__c
object to see anyLog__c
records that have, or should be, sent to Slack - Remote site setting for Slack's API
In order to use the Slack plugin, there are some configuration changes needed in both Slack and Salesforce
Within Slack, you'll need to setup incoming webhooks to allow the Logger Slack plugin to create messages. The high-level steps are:
- Create a new app in your Slack workspace (or use an existing app, if you prefer)
- Create a new incoming webhook for your app, and copy the webhook URL. This will be used in Salesforce (see below steps)
Check out Slack's webhooks documentation for more details on how to setup incoming webhooks.
- Ensure that you have the unlocked package version of Nebula Logger installed in your org
- Install the unlocked package for the Slack plugin
- Go to Setup --> Custom Metadata Types --> Logger Parameters. There are 2 parameters to configure (shown in screenshot below)
- Parameter 'Slack Endpoint' - You can configure this webhook in 1 of 2 ways:
- Easier but less secure: Paste the Slack webhook URL into the
Value__c
field and save the Plugin Parameter record. - More secure: Create a new Named Credential (see section below for step-by-step instructions), using the webhook URL as the endpoint. Within the Parameter 'Slack Endpoint', enter
callout:<your named credential>
into theValue__c
field and save the Plugin Parameter record
- Easier but less secure: Paste the Slack webhook URL into the
- Parameter 'Slack Notification Logging Level' - Set the desired logging level value that should trigger a Slack notification to be sent the Logger Plugin Parameter 'Slack Notification Logging Level`. It controls which logging level (ERROR, WARN, INFO, DEBUG, FINE, FINER, or FINEST) will trigger the Slack notifications to be sent.
- Parameter 'Slack Endpoint' - You can configure this webhook in 1 of 2 ways:
The Slack integration should now be setup & working - any new logs that meet the specified notification logging level (step 6 above) will send a Slack notification.
Note: these instructions are for setting up the improved Named Credentials, as legacy credentials are deprecated as of Winter '23. For more info, see Salesforce's documentation.
-
Create a new External Credential. This will define how Salesforce should authenticate with the Slack webhook (which in this case is no authentication).
- Go to the Named Credentials page in setup, click
New
under the External Credentials tab. - Enter a name (for example,
Nebula Slack Webhook (No Auth)
) - Select
No Authentication
for the Authentication Protocol.
- Go to the Named Credentials page in setup, click
-
Create a Principle for the External Credential. This will define the credentials that should be used when calling out to the Slack webhook (again, in this case, no credentials are needed, but we will still need to grant access to the principal).
- In the Principals section of the External Credential you just created, click
New
. - Enter a parameter name (for example:
Default
orStandard
, as there will only ever be one principal for this credential).
- In the Principals section of the External Credential you just created, click
-
Create a new Named Credential. This is where the webhook URL will be stored.
- Go back to the main Named Credentials page and click
New
in the Named Credentials tab. - Enter a name for the Named Credential (for example:
Nebula Slack Webhook
). - Paste the Slack webhook URL into the URL field.
- In the External Credential dropdown, select the one you created in step 1.
- Go back to the main Named Credentials page and click
-
Grant the Platform Integration User access to the External Credential. This will allow the Platform Integration user (the running user listening for Log Platform Events) to make callouts to the Slack webhook.
- Create a new permission set or open an existing one
- Go to the External Credential Principal Access section of the permissions set and grant access to the External Credential you created in step 1.
- Assign the permission set to the Platform Integration User handles Log Platform events.