Laravel notification add mention of user in group channel
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm trying to send a notification with a mention of a user in a general channel. This is what I have:
<?php
namespace AppNotifications;
use IlluminateBusQueueable;
use IlluminateNotificationsMessagesSlackMessage;
use IlluminateNotificationsNotification;
use IlluminateContractsQueueShouldQueue;
use IlluminateNotificationsMessagesMailMessage;
class WeeklyTasksResponsible extends Notification
{
use Queueable;
protected $employee;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(AppEmployee $employee)
{
$this->employee = $employee;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['slack'];
}
/**
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
* @return SlackMessage
*/
public function toSlack($notifiable)
{
return (new SlackMessage)
->content('Reponsible for this week is: ' . $this->employee->slack_name);
}
}
This will sent a weekly notification in the general slack channel of our company. The message is "Responsible for this week is: nameofuser". The problem is the user doesn't see a notification of this.
I've also tried do this:
public function toSlack($notifiable)
{
return (new SlackMessage)
->content('Reponsible for this week is: @' . $this->employee->slack_name);
}
But it isn't the same as mentioning someone myself in the channel.
How can I do this?
php laravel notifications laravel-5.3 slack
add a comment |
I'm trying to send a notification with a mention of a user in a general channel. This is what I have:
<?php
namespace AppNotifications;
use IlluminateBusQueueable;
use IlluminateNotificationsMessagesSlackMessage;
use IlluminateNotificationsNotification;
use IlluminateContractsQueueShouldQueue;
use IlluminateNotificationsMessagesMailMessage;
class WeeklyTasksResponsible extends Notification
{
use Queueable;
protected $employee;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(AppEmployee $employee)
{
$this->employee = $employee;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['slack'];
}
/**
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
* @return SlackMessage
*/
public function toSlack($notifiable)
{
return (new SlackMessage)
->content('Reponsible for this week is: ' . $this->employee->slack_name);
}
}
This will sent a weekly notification in the general slack channel of our company. The message is "Responsible for this week is: nameofuser". The problem is the user doesn't see a notification of this.
I've also tried do this:
public function toSlack($notifiable)
{
return (new SlackMessage)
->content('Reponsible for this week is: @' . $this->employee->slack_name);
}
But it isn't the same as mentioning someone myself in the channel.
How can I do this?
php laravel notifications laravel-5.3 slack
1
According to their documentation, you have to set thelink_names
parameter totrue
/1
. I don't have enough time to give you the solution myself, hope someone can help you. You can see an explanation in this answer.
– HCK
Nov 24 '18 at 15:45
Or just use the user ID instead of the user name and it should work. e.g.<@U12345678>
– Erik Kalkoken
Nov 24 '18 at 17:56
add a comment |
I'm trying to send a notification with a mention of a user in a general channel. This is what I have:
<?php
namespace AppNotifications;
use IlluminateBusQueueable;
use IlluminateNotificationsMessagesSlackMessage;
use IlluminateNotificationsNotification;
use IlluminateContractsQueueShouldQueue;
use IlluminateNotificationsMessagesMailMessage;
class WeeklyTasksResponsible extends Notification
{
use Queueable;
protected $employee;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(AppEmployee $employee)
{
$this->employee = $employee;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['slack'];
}
/**
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
* @return SlackMessage
*/
public function toSlack($notifiable)
{
return (new SlackMessage)
->content('Reponsible for this week is: ' . $this->employee->slack_name);
}
}
This will sent a weekly notification in the general slack channel of our company. The message is "Responsible for this week is: nameofuser". The problem is the user doesn't see a notification of this.
I've also tried do this:
public function toSlack($notifiable)
{
return (new SlackMessage)
->content('Reponsible for this week is: @' . $this->employee->slack_name);
}
But it isn't the same as mentioning someone myself in the channel.
How can I do this?
php laravel notifications laravel-5.3 slack
I'm trying to send a notification with a mention of a user in a general channel. This is what I have:
<?php
namespace AppNotifications;
use IlluminateBusQueueable;
use IlluminateNotificationsMessagesSlackMessage;
use IlluminateNotificationsNotification;
use IlluminateContractsQueueShouldQueue;
use IlluminateNotificationsMessagesMailMessage;
class WeeklyTasksResponsible extends Notification
{
use Queueable;
protected $employee;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(AppEmployee $employee)
{
$this->employee = $employee;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['slack'];
}
/**
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
* @return SlackMessage
*/
public function toSlack($notifiable)
{
return (new SlackMessage)
->content('Reponsible for this week is: ' . $this->employee->slack_name);
}
}
This will sent a weekly notification in the general slack channel of our company. The message is "Responsible for this week is: nameofuser". The problem is the user doesn't see a notification of this.
I've also tried do this:
public function toSlack($notifiable)
{
return (new SlackMessage)
->content('Reponsible for this week is: @' . $this->employee->slack_name);
}
But it isn't the same as mentioning someone myself in the channel.
How can I do this?
php laravel notifications laravel-5.3 slack
php laravel notifications laravel-5.3 slack
asked Nov 24 '18 at 14:52
nielsvnielsv
6812275160
6812275160
1
According to their documentation, you have to set thelink_names
parameter totrue
/1
. I don't have enough time to give you the solution myself, hope someone can help you. You can see an explanation in this answer.
– HCK
Nov 24 '18 at 15:45
Or just use the user ID instead of the user name and it should work. e.g.<@U12345678>
– Erik Kalkoken
Nov 24 '18 at 17:56
add a comment |
1
According to their documentation, you have to set thelink_names
parameter totrue
/1
. I don't have enough time to give you the solution myself, hope someone can help you. You can see an explanation in this answer.
– HCK
Nov 24 '18 at 15:45
Or just use the user ID instead of the user name and it should work. e.g.<@U12345678>
– Erik Kalkoken
Nov 24 '18 at 17:56
1
1
According to their documentation, you have to set the
link_names
parameter to true
/1
. I don't have enough time to give you the solution myself, hope someone can help you. You can see an explanation in this answer.– HCK
Nov 24 '18 at 15:45
According to their documentation, you have to set the
link_names
parameter to true
/1
. I don't have enough time to give you the solution myself, hope someone can help you. You can see an explanation in this answer.– HCK
Nov 24 '18 at 15:45
Or just use the user ID instead of the user name and it should work. e.g.
<@U12345678>
– Erik Kalkoken
Nov 24 '18 at 17:56
Or just use the user ID instead of the user name and it should work. e.g.
<@U12345678>
– Erik Kalkoken
Nov 24 '18 at 17:56
add a comment |
1 Answer
1
active
oldest
votes
As mentioned by @HCK you can enable matching of usernames for @username
mentions in chat.postMessages
by setting the optional parameter link_names
to true
.
However, creating mentions with usernames is deprecated and should no longer be used.
The recommended approach is to create mentions with the user ID, which will work by default.
Example:
<@U12345678>
See the post A lingering farewell to the username from Slack for details about username deprecation.
I tried this and it worked. Thank you.
– Aftab Naveed
Feb 20 at 5:54
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53459368%2flaravel-notification-add-mention-of-user-in-group-channel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As mentioned by @HCK you can enable matching of usernames for @username
mentions in chat.postMessages
by setting the optional parameter link_names
to true
.
However, creating mentions with usernames is deprecated and should no longer be used.
The recommended approach is to create mentions with the user ID, which will work by default.
Example:
<@U12345678>
See the post A lingering farewell to the username from Slack for details about username deprecation.
I tried this and it worked. Thank you.
– Aftab Naveed
Feb 20 at 5:54
add a comment |
As mentioned by @HCK you can enable matching of usernames for @username
mentions in chat.postMessages
by setting the optional parameter link_names
to true
.
However, creating mentions with usernames is deprecated and should no longer be used.
The recommended approach is to create mentions with the user ID, which will work by default.
Example:
<@U12345678>
See the post A lingering farewell to the username from Slack for details about username deprecation.
I tried this and it worked. Thank you.
– Aftab Naveed
Feb 20 at 5:54
add a comment |
As mentioned by @HCK you can enable matching of usernames for @username
mentions in chat.postMessages
by setting the optional parameter link_names
to true
.
However, creating mentions with usernames is deprecated and should no longer be used.
The recommended approach is to create mentions with the user ID, which will work by default.
Example:
<@U12345678>
See the post A lingering farewell to the username from Slack for details about username deprecation.
As mentioned by @HCK you can enable matching of usernames for @username
mentions in chat.postMessages
by setting the optional parameter link_names
to true
.
However, creating mentions with usernames is deprecated and should no longer be used.
The recommended approach is to create mentions with the user ID, which will work by default.
Example:
<@U12345678>
See the post A lingering farewell to the username from Slack for details about username deprecation.
answered Nov 24 '18 at 18:38
Erik KalkokenErik Kalkoken
14k32653
14k32653
I tried this and it worked. Thank you.
– Aftab Naveed
Feb 20 at 5:54
add a comment |
I tried this and it worked. Thank you.
– Aftab Naveed
Feb 20 at 5:54
I tried this and it worked. Thank you.
– Aftab Naveed
Feb 20 at 5:54
I tried this and it worked. Thank you.
– Aftab Naveed
Feb 20 at 5:54
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53459368%2flaravel-notification-add-mention-of-user-in-group-channel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
According to their documentation, you have to set the
link_names
parameter totrue
/1
. I don't have enough time to give you the solution myself, hope someone can help you. You can see an explanation in this answer.– HCK
Nov 24 '18 at 15:45
Or just use the user ID instead of the user name and it should work. e.g.
<@U12345678>
– Erik Kalkoken
Nov 24 '18 at 17:56