laravel / slack-notification-channel

Slack Notification Channel for laravel.

Home Page:https://laravel.com/docs/notifications#slack-notifications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"From" is not supported

chimit opened this issue · comments

  • Slack Notification Channel Version: 2.0.2
  • Laravel Version: 6.15.1
  • PHP Version: 7.4
  • Database Driver & Version:

Description:

The method from is not supported.

Steps To Reproduce:

return (new SlackMessage)
    ->from('MyBot', ':robot_face:')
    ->to('#general')
    ->content('Hi!');

It is? Please give some more info here. What exactly isn't working for you?

Apparently, it's a legacy protocol. A from method simply doesn't work. Slack always displays an app username and avatar.

You cannot override the default channel (chosen by the user who installed your app), username, or icon when you're using Incoming Webhooks to post messages. Instead, these values will always inherit from the associated Slack app configuration.
https://api.slack.com/messaging/webhooks

When did they drop support for this? Can you link to any changelogs, blog posts, etc?

Hm... I'm not familiar with the Slack API, but if I follow instructions from the Slack log channel documentation and use the link from that page it throws me to the "Incoming WebHooks" app page. If I create hooks there everything works perfectly.

But the link on the Slack Notifications page throws me to the absolutely another page that asks me to create a new app. It gives me a webhook URL as well, but if I use it the from() method is ignored by Slack.

So if you use the existing "Incoming WebHooks" app you can use custom icons and names, but if you create your own app with webhooks you can't customize icons and names. So the link on this page is misleading.

Please, correct me if I'm wrong.

I'm currently using an incoming webhook in an app with the from method configured so I think there might be something we're missing here. If you can ever pinpoint the problem feel free to report back and we'll re-open.

Hm... I'm not familiar with the Slack API, but if I follow instructions from the Slack log channel documentation and use the link from that page it throws me to the "Incoming WebHooks" app page. If I create hooks there everything works perfectly.

But the link on the Slack Notifications page throws me to the absolutely another page that asks me to create a new app. It gives me a webhook URL as well, but if I use it the from() method is ignored by Slack.

So if you use the existing "Incoming WebHooks" app you can use custom icons and names, but if you create your own app with webhooks you can't customize icons and names. So the link on this page is misleading.

Please, correct me if I'm wrong.

@chimit you are right. There are two different ways to integrate Slack to your project: creating an app and integrating the existing Incoming WebHooks app. If you create an app, you can't use the from, to and image methods, but you still can customize the from name and image here:

https://api.slack.com/apps

Select your app, scroll down to Display Information and there is it.

Using the existing Incoming WebHooks is not recomended, as it uses a legacy custom integration, as @chimit pointed.

Thanks for the clarification, @shino47!

It is worth mentioning that customizing name and image in your own app is not as flexible as in legacy Incoming WebHooks because you can't do it dynamically from your code.

@driesvints there is still an inconsistency on the Slack Notifications documentation page. It leads you to create a new Slack app (https://api.slack.com/incoming-webhooks) that doesn't support a from method described below. We should choose one approach:

  1. Recommend using a legacy Incoming WebHooks app that supports from. Then change the link on https://laravel.com/docs/7.x/notifications#slack-notifications;
  2. Recommend to create your own Slack app and remove everything about the from method from Slack Notifications documentation page and change the link on https://laravel.com/docs/7.x/logging#configuration.

@chimit done: laravel/docs#5964

Thanks for clarifying that.