Display all online users in a Slack channel

essa picture essa · Aug 14, 2016 · Viewed 10.8k times · Source

New to slack at the moment - I've looked around to see if there's a Slack command to show all online users in a Slack channel but haven't found any.

Would a custom slack command calling a Slack API method eg. users.getPresence be the way to go or is there another way?

Answer

Taylor Singletary picture Taylor Singletary · Aug 15, 2016

Your best bet would be to first retrieve the list of members within the channel using the Web API method channels.info.

Each channel object will contain a members field containing a collection of user IDs -- those who have joined the channel.

You would then have two options depending on your preferences:

1) Use users.list to retrieve a list of all team members (including each user's presence) and narrow list of users down to those listed in the members field from above.

2) or, you could look up each user from that members field, one at a time using users.info.