Scrapes 3 months of message history from Slack channels that start with external- or end with -internal. Outputs JSON.
python slack_scraper.py- Create or select a Slack app with a bot token.
- Ensure the bot has these scopes:
channels:history,channels:read,users:read. - Install the app to the workspace and invite the bot to the target channels.
- Create a
.envfile and set:SLACK_BOT_TOKEN=xoxb-... - Install dependencies:
pip install -r requirements.txt
- If you get
not_in_channel, invite the bot to the channel. - If you get
missing_scope, update scopes in the Slack app and reinstall it.
The script lives in ~/Projects/slack_scraper_my_week.py. For a 1-week export of all channels you're in (to search what you did well / what didn’t go well):
cd ~/Projects
python slack_scraper_my_week.py- Use a user token so the script sees "channels I'm in":
- Slack API Apps → your app → OAuth & Permissions
- Under User Token Scopes add:
channels:history,channels:read,users:read,groups:read(for private channels) - Reinstall the app to the workspace, then copy the OAuth Access Token (starts with
xoxp-)
- In
.envadd:(You can keepSLACK_USER_TOKEN=xoxp-...SLACK_BOT_TOKENfor the original scraper; this script usesSLACK_USER_TOKENfirst.) Put a.envin~/Projectswith the token, or the script will load from~/slack_scraper/.envif you run from there. Install deps:pip install slack-sdk python-dotenv
slack_my_week_YYYYMMDD.json– all messages from your channels; each message has"is_me": true/falseslack_my_week_my_messages_only_YYYYMMDD.json– only messages you sent (easy to search)
Search in an editor or with grep, e.g. grep -i "did well\|went well" slack_my_week_my_messages_only_*.json