Skip to content

Commit

Permalink
Merge pull request #30 from docmarionum1/conversations-api
Browse files Browse the repository at this point in the history
Major Revision to Port to Conversations API
  • Loading branch information
docmarionum1 authored Feb 7, 2021
2 parents f04a6bb + aa66265 commit f699565
Show file tree
Hide file tree
Showing 7 changed files with 477 additions and 247 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export
**.sqlite
**.pyc
55 changes: 48 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,60 @@
A bot that can search your slack message history. Makes it possible to search
further back than 10,000 messages.

## Requirements

1. Permission to install new apps to your Slack workspace.
2. python3
3. A publicly accessible URL to serve the bot from. (Slack recommends using [ngrok](https://ngrok.com/) to get around this.)

## Installation

1. Clone this repo.
1. Install the requirements:
2. Install the requirements:

pip install -r requirements.txt

1. [Export your team's slack history.](https://get.slack.help/hc/en-us/articles/201658943-Export-your-team-s-Slack-history)
Download the archive and export it to a directory. Then run `import_archive.py`
3. If you want to include your existing slack messages, [export your team's slack history.](https://get.slack.help/hc/en-us/articles/201658943-Export-your-team-s-Slack-history)
Download the archive and export it to a directory. Then run `import.py`
on the directory. For example:

python import.py export

This will create a file `slack.sqlite`.
1. Create a new [bot user](https://api.slack.com/bot-users) on your slack
channel and get the API key. Start the bot with:

4. Create a new [Slack app](https://api.slack.com/start/overview).

- Add the following bot token oauth scopes and install it to your workspace:

- `channels:history`
- `channels:read`
- `chat:write`
- `groups:history` (if you want to archive/search private channels)
- `groups:read` (if you want to archive/search private channels)
- `im:history`
- `users:read`

5. Start archive bot with:

SLACK_BOT_TOKEN=<BOT_TOKEN> SLACK_SIGNING_SECRET=<SIGNING_SECRET> python archivebot.py

export SLACK_API_TOKEN=<API_TOKEN> && python archivebot.py
Where `SIGNING_SECRET` is the "Signing Secret" from your app's "Basic Information" page and `BOT_TOKEN` is the
"Bot User OAuth Access Token" from the app's "OAuth & Permissions" page.

Where API_TOKEN is the token you got when creating the bot user.
Use `python archivebot.py -h` for a list of all command line options.

6. Go to the app's "Event Subscriptions" page and add the url to where archive bot is being served. The default port is `3333`.

- Then add the following bot events:

- `channel_rename`
- `group_rename` (if you want to archive/search private channels)
- `member_joined_channel`
- `member_left_channel`
- `message.channels`
- `message.groups` (if you want to archive/search private channels)
- `message.im`
- `user_change`

## Archiving New Messages

Expand Down Expand Up @@ -50,6 +84,13 @@ to the query. The full usage is:
limit: The number of responses to return. Default 10.


## Migrating from slack-archive-bot v0.1

`slack-archive-bot` v0.1 used the legacy Slack API which Slack [ended support for in February 2021](https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api). To migrate to the new version:

- Follow the installation steps above to create a new slack app with all of the required permissions and event subscriptions.
- The biggest change in requirements with the new version is the move from the [Real Time Messaging API](https://api.slack.com/rtm) to the [Events API](https://api.slack.com/apis/connections/events-api) which necessitates having a publicly-accessible url that Slack can send events to. If you are unable to serve a public endpoint, you can use [ngrok](https://ngrok.com/).

## Contributing

Contributions are more than welcome. From bugs to new features. I threw this
Expand Down
Loading

0 comments on commit f699565

Please sign in to comment.