Slack API: Retrieve all member emails from a slack channel

user5844628 picture user5844628 · Jan 10, 2017 · Viewed 14.5k times · Source

Given the name of a slack channel, is there a way to retrieve a list of emails of all the members in that channel? I tried looking in the slack api docs but couldn't find the method I need to make this happen (https://api.slack.com/methods).

Answer

Erik Kalkoken picture Erik Kalkoken · Jan 10, 2017

Provided you have the necessary scopes you can retrieved the emails of all members of a channel starting with the channel name as follows:

  1. Call channels.list to get the list of all channels and to convert the channel name to its ID
  2. Call channels.info of the desired channel with channel ID to get the list of its members.
  3. Call users.list to retrieve the list of all Slack users including their profile information and email
  4. Match the channel member list with the user list by user ID to get the correct users and emails

Note that this also works for private channels using groups.list and groups.info, but only if the user or bot related to the access token is a member of that private channel.

Update 2019

Would strongly recommend to rather use the newer conversations.* methods, instead of channels.* and groups.*, because they are more flexible and they are some cases where the older methods will not work (e.g. converted channels).