GithubHelp home page GithubHelp logo

jonathanchan / slack-autoarchive Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grailbio-external/slack-autoarchive

4.0 0.0 4.0 91 KB

If there has been no activity in a channel for awhile, you can automatically archive it using a cronjob.

License: Apache License 2.0

Python 98.97% Dockerfile 1.03%

slack-autoarchive's Introduction

Autoarchive Unused Slack Channels


  • python3
  • Install requirements.txt ( pip install -r requirements.txt )
  • An OAuth token from a Slack app on your workspace that has the following permission scopes:

Bot Token Scopes

  • channels:read
  • channels:manage
  • channels:history
  • channels:join
  • chat:write
  • groups:read

User Token Scopes

  • channels:history

Example Usages

BOT_SLACK_TOKEN must be exposed as environment variables before running your script. By default, the script will do a DRY_RUN. To perform a non-dry run, specify DRY_RUN=false as an environment variable as well. See sample usages below.

# Run the script in dry run archive mode...This will output a list of channels that will be archived.

# Run the script in active archive mode...THIS WILL ARCHIVE CHANNELS!

As an alternative to passing in environment variables through the command line, add a .env file to your project root:


However, it may be best to always pass the DRY_RUN variable through the command line to avoid accidental archives.

NOTE: On the first run with DRY_RUN=false it will only add the bot to every channel - only on a subsequent run will channels be archived.

How can I exempt my channel from being archived?

You can add the string 'noarchive' to your channel purpose or topic. (There is also a whitelist file or env variable if you prefer.)

What Channels Will Be Archived

A channel will be archived by this script is it doesn't meet any of the following criteria:

  • Has non-bot messages in the past 60 days.
  • Is whitelisted. A channel is considered to be whitelisted if the channel name contains keywords in the WHITELIST_KEYWORDS environment variable. Multiple keywords can be provided, separated by comma.

What Happens When A Channel Is Archived By This Script

  • *Don't panic! It can be unarchived by following these instructions However all previous members would be kicked out of the channel and not be automatically invited back.
  • You can always whitelist a channel if it indeed needs to be kept despite meeting the auto-archive criteria.

I don't trust the DRY_RUN option to not mess up my Slack org or cause confusion amongst my users.

Create a new Slack org to test this script against. Use the script to quickly create channels in your new Slack org. Edit to change the number of channels to create.

Known Issues

  • Since slack doesn't have a batch API, we have to hit the api a couple times for each channel. This makes the performance of this script slow. If you have thousands of channels (which some people do), get some coffee and be patient.

  • Channels that aren't archivable, such as #general, are reported as being archived. This can be ignored.


  • First build the docker image (in the root of the project)

docker build --tag autoarchive .

  • run the container (dryrun is set to true by default)

docker run autoarchive

  • if your ready to archive run

docker run -e DRY_RUN=false autoarchive

slack-autoarchive's People


adamjdeacon avatar adamkaplan avatar alberto-sierra avatar alexeiser avatar broom9 avatar bytesandwich avatar gareth-sharpe avatar girasquid avatar helgi avatar johntheodore avatar jonathanchan avatar lozette avatar rainya avatar sethgoldin avatar tehshrike avatar


 avatar  avatar  avatar  avatar

slack-autoarchive's Issues

Channels are not being archived

Hitting a rate limiter when joining channels.

From one test, the limit of joining channels is 18 before the rate limiter causes problems.

The bot is too chatty

Would rather have the bot not post any messages to public channels.

Users could be outraged for one reason or another.

Allow the person running this program to send out proper notifications to users.

bot persistence

why does the bot need to stay in all public channels?
it would be better for the bot to come and go when needed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.