I’ve got a functioning notification system that can post to Channel in our companies Slack. However, everything that comes across is just text. The linkNames is suppose to find/link user names in your content. I see that it gets set to “1” but has no affect when it shows up in the channel.
namespace AppNotifications; use IlluminateBusQueueable; use IlluminateContractsQueueShouldQueue; use IlluminateNotificationsNotification; use IlluminateNotificationsMessagesSlackMessage; class Dd extends Notification { use Queueable; /** * Create a new notification instance. * * @return void */ public function __construct() { // } /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return ['slack']; } /** * Get the array representation of the notification. * * @param mixed $notifiable * @return array */ public function toArray($notifiable) { return [ // ]; } /** * Get the Slack representation of the notification. * * @param mixed $notifiable * @return SlackMessage */ public function toSlack($slackComment) { $slackMessage = new SlackMessage(); $slackMessage->linkNames(); $slackMessage->from('Christopher'); $slackMessage->to($slackComment->channel); $slackMessage->content("Harded coded for example @christopher <- this doesn't get linked to the user in slack but should"); $slackMessage->info(); //dd($slackMessage); // this shows that the linkedNames attribute has been set to "1" return $slackMessage; }
}
Is this a known issues, a version mismatch, or am I missing something?
Advertisement
Answer
https://api.slack.com/reference/surfaces/formatting#mentioning-users
To mention a user in app-published text, you need to provide their user ID in the following syntax:
Hey <@U024BE7LH>, thanks for submitting your report.