Skip to content

Instantly share code, notes, and snippets.

@chrisbay
Created June 21, 2017 13:11
Show Gist options
  • Select an option

  • Save chrisbay/bcf30bd08dd9cdda1720305b5ca92099 to your computer and use it in GitHub Desktop.

Select an option

Save chrisbay/bcf30bd08dd9cdda1720305b5ca92099 to your computer and use it in GitHub Desktop.
Find a Slackbot's ID after connecting with its token
import os
from slackclient import SlackClient
BOT_NAME = 'bot_name_without_at_sign'
slack_client = SlackClient('BOT_TOKEN_GOES_HERE')
if __name__ == "__main__":
api_call = slack_client.api_call("users.list")
if api_call.get('ok'):
# retrieve all users so we can find our bot
users = api_call.get('members')
for user in users:
if 'name' in user and user.get('name') == BOT_NAME:
print("Bot ID for '" + user['name'] + "' is " + user.get('id'))
else:
print("could not find bot user with the name " + BOT_NAME)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment