Slack notifications not working, unable to create legacy incoming webhook
nathan-io opened this issue · 2 comments
- Slack Notification Channel Version: 2.4.0
- Laravel Version: 9.5.1
- PHP Version: 8.1
- Database Driver & Version:
Description:
I see that to()
is not currently supported as noted in #54 .
We're not using to()
, as the channel is configured within the Slack App settings. In a greenfield project, we're still unable to send Slack notifications.
There doesn't appear to be a way to even create the legacy Incoming Webhooks anymore, and Slack's current webhook docs list creating a Slack App as the first step.
On the "Custom Integrations" area of the workspace admin dashboard, there's a warning:
We recommend replacing your custom integrations with Slack apps, which have more features and use the latest APIs.
In the Slack workspaces I have admin permissions on, there's no option to even create a custom integration. You must create a Slack App.
Steps To Reproduce:
Create a Slack App and an incoming webhook on that app. Add the webhook URI in .env
and attempt to send a notification to Slack.
Our current implementation within a Notification class looks like:
// ...
public function via($notifiable)
{
return ['slack'];
}
public function routeNotificationForSlack($notification)
{
return config('app.slack_webhook_url');
}
public function toSlack($notifiable)
{
$tags = json_encode($this->tags);
$callLink = url('/nova/resources/calls/' . $this->callId);
return (new SlackMessage)
->success()
->content('Applied Tags to Call')
->attachment(function ($attachment) use ($tags, $callLink) {
$attachment->title('Call Id ' . $this->callId, $callLink)
->fields([
'Caller Name' => $this->callerName,
'Caller Phone Number' => $this->callerPhoneNumber,
'Applied Tags' => $tags,
'Call Details Page' => $callLink,
]);
});
}
@nathan-io you defined the routeNotificationForSlack
on your notification class instead of the user model. If you move it there, the notification will be sent. See the docs here: https://laravel.com/docs/9.x/notifications#routing-slack-notifications
🤦♂️ Thank you, that indeed resolved it.