Skip to content

chariotsolutions/slack-exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slack Channel Exporter

Export a single Slack private channel to JSON or text format, with support for date range filtering and thread preservation.

Setup

  1. Install dependencies:
pip install -r requirements.txt
  1. Create a Slack App and get an OAuth token:

    • Go to https://api.slack.com/apps
    • Create a new app or select existing app
    • Add OAuth scopes: groups:history and groups:read (for private channels)
    • Install app to your workspace
    • Copy the "Bot User OAuth Token" (starts with xoxb-)
  2. Configure your environment:

# Copy the example file
cp .env.example .env

# Edit .env and add your token
# SLACK_BOT_TOKEN=xoxb-your-actual-token
# SLACK_CHANNEL_ID=C1234567890  # Optional: set a default channel
  1. Add the bot to the private channel you want to export:
    • In Slack, go to the channel
    • Type /invite @YourBotName

Usage

Using environment variables (recommended):

After setting up your .env file:

# Export entire channel history as JSON
python export_channel.py C1234567890 --output export.json

# Or use the default channel from .env
python export_channel.py --output export.json

# Export as text file
python export_channel.py C1234567890 --output export.txt --format text

# Export with date range
python export_channel.py C1234567890 --output export.json \
  --start-date 2024-01-01 --end-date 2024-12-31

Interactive token prompt:

If SLACK_BOT_TOKEN is not set in your .env file, you'll be prompted securely:

python export_channel.py C1234567890 --output export.json
Enter Slack Bot Token: [input hidden]

Note: The token is never passed as a command-line argument to prevent it from being stored in shell history or visible in process listings.

Finding Your Channel ID

In Slack:

  1. Right-click on the channel name
  2. Select "View channel details"
  3. Scroll to bottom - the Channel ID is shown there

Or use the channel name to find it via API.

Output Formats

JSON

Contains full message objects with metadata, including nested thread replies under thread_replies key.

Text

Human-readable format with timestamps, usernames, and indented thread replies:

[2024-01-15 10:30:45] U123456
Hello, this is a message

    ↳ [2024-01-15 10:31:20] U789012
    This is a reply in the thread

================================================================================

Notes

  • The bot must be a member of the private channel to access it
  • Rate limits apply (typically 50+ requests per minute)
  • Large channels may take several minutes to export
  • Reactions, emojis metadata, and attachments are not exported

About

Export Slack private channels to JSON or text format with thread preservation and date range filtering

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages