Sign inSign up

marshallasch/slack-name-bot

By marshallasch

•Updated over 6 years ago

This is a bot created for gryph.slack.com to keep track of identity changes

Image
0

441

marshallasch/slack-name-bot repository overview

⁠Tracking Slack Name and Email Changes

This Slack app is based off of the template-terms-of-service⁠ sample app.

This Slack app will receive an event every time a user signs up for the workspace or changes their details. Any workspace administrator is able to query the history using the slash command /whois [@user].

⁠Setup

⁠Create a Slack app
  1. Create an app⁠
  2. Go to Bot Users and click "Add a Bot User" to create a, app bot. Save the change.
  3. Enable Interactive components (See Enable Interactive Components below)
  4. Navigate to the OAuth & Permissions page and add the following scopes:
    • bot
    • chat:write:bot
    • commands
    • users:read
    • users:read:email
    • team:read
    • channels:read
  5. Click 'Save Changes' and install the app (You should get an OAuth access token after the installation)
  6. Enable the events (See Enable the Events API below. It doesn't let you the Request URL until you run the code!)
  7. In your Slack workspace, invite the bot to #general, where the new user will join.
⁠Run locally
  1. Get the code
    • Either clone this repo and run npm install
    • Or run it as a docker container docker pull marshallasch/slack-name-bot
  2. Set the following environment variables to config.ini (see config.ini.tmp):
    • Note this will be created by docker run marshallasch/slack-name-bot as long as the variables are set

    • SLACK_ACCESS_TOKEN: Your app's xoxb- token (available on the Install App page, after you install the app to a workspace once.)

    • SLACK_SIGNING_SECRET: Your app's Signing Secret (available on the Basic Information page)

    • SLACK_CLIENT_SECRET: Your app's Client Secret (available on the Basic Information page)

    • SLACK_CLIENT_ID: Your app's ID (available on the Basic Information page)

    • DATABASE the data base name to use

    • DB_PORT the mongo db port to connect to (default is 27017)

    • DB_HOST the host of the mongo db server

    • DB_USER the mongo db user name

    • DB_PASS the plain text mogodb password

  3. If you're running the app locally:
    • Start the app (npm start)
⁠Enable the Events API
  1. Go back to the app settings and click on Events Subscriptions
  2. Set the Request URL to your server (e.g. https://yourname.ngrok.com) + /events
  3. On the same page, subscribe to the team_join and user_change workspace events
⁠Enable the Slash Commands
  1. Go back to the app settings and click on Slash Commands
  2. Set the Request URL to your server (e.g. https://yourname.ngrok.com) + /command
  3. On the same page, set the command name to /whois and the description
  4. On the same page, check the Escape channels, users, and links sent to your app checkbox
⁠Requirements

This application requires a connection to mongodb

To create the mongodb database and user account run

use slack_users
db.createUser(
   {
     user: "slackBot",
     pwd: "slackpass",
     roles: [ "readWrite" ]
   }
)

From a mongo shell on the db server.

Tag summary

Content type

Image

Digest

Size

347 MB

Last updated

over 6 years ago

docker pull marshallasch/slack-name-bot