Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TrentDPT's avatar

Slack UserID vs Display Name

Hey Everyone,

I recently linked up Laravel (current build I have is 5.5.*) to Laravel-slack. It works great with channels, but I noticed the at the only way I can post a message in slack for Direct Messages is if I use the UserID of the individual, not their display name.

Is this a new situation that Slack has changed their process? Is there a work around? Is there a way to have the Slack workgroup shoot over all the userids or even emails over to Laravel?

How have people solved this issue?

Thanks

0 likes
6 replies
bobbybouwmann's avatar

The API of Slack mostly stayed the same in all these years. I don't think there is a work-around. Slack does that name as you and I where we link posts or addresses to a user_id instead of the username in the database.

You can create a loop to send multiple messages. As far as I know Slack doesn't support this as a feature.

I'm also not 100% clear what exactly your question is.

TrentDPT's avatar

Apologies if this was unclear, @bobbybouwmann

I was trying to go off of this, which demonstrated you could use @username. Though in the Laravel Docs it just states

to->('#other')

https://github.com/gpressutto5/laravel-slack https://laravel.com/docs/7.x/notifications#slack-notifications

However, you are correct that what seems to be the current situation is that you need to know the user's ID in order to put

to->(@userID)

My question is how do people currently utilize this? Do they just go through individually and note all the user's IDs and log them locally into their own database? Do they somehow pull all those IDs in some sort of call to Slack?

What I would like to do is the following. I have worked through some of the Laracast notification systems, and I would like to have it so that if someone is "subscribed" to a case, that if that case gets a new reply they receive a direct message on the Slack system. I know that its possible if I have their UserID, but what if I have an open website, and an open slack team where I may have people joining at a large scale and so how do I gather all of those userIds from slack and match them up to user's on the website

Does that shine more light on the situation?

bobbybouwmann's avatar
Level 88

You probably need to store the user_id from Slack in your users table. That way you can always notify them. There is probably an API call to do this. One downside to this is that each user needs to give you permission to do this (at least that's how I know it). Normally you would post to the slackbot instead so you have all those notifications in one place for the specific user.

TrentDPT's avatar

@bobbybouwmann Any chance you can point me in the right direction or possibly the right search language to find that?

TrentDPT's avatar

I was asking if you knew any resources that could help walk me through that answer you gave, since utilization of slackbot and how to do an api call to slack are beyond me currently

Please or to participate in this conversation.