Slack Setup
MoonGuard uses laravel/slack-notification-channel as a dependency to build Slack notifications, in case you want to send MoonGuard notifications to Slack you need a Slack Weebhook URL.
To obtain the webhook, you can create a Slack App on the Slack API site. This is a simple process that involves creating an app for your workspace:
- Create an App from scratch. In the “Create New App” buttom press create app “From scratch”
- Activate an incoming Webhook.
- Add a new incoming Webhook.
- Decide which channel to post notifications.
Once you have obtained the webhook URL, you must update the .env file of your Laravel project with the SLACK_WEBHOOK_URL variable.
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/TTW2G=asdW3/B042W9dsd9L/D2D329QLMNsdi12
Finally activate the Slack channel in the MoonGuard config file.
<?php
[
//...
'notifications' => [
'channels' => ['mail', 'slack'], //<-- add 'slack'
'slack' => [
'webhook_url' => env('SLACK_WEBHOOK_URL'),
],
],
];
Note
If you're using a custom user model, it must implement the
routeNotificationForSlack():string
method.