Giter Club home page Giter Club logo

slack-bot's Introduction

cc-slack-bot

A bot for Coding Coach slack workspace

Getting Started

Setting up the Slack App

  1. Create a new Slack team
  2. Create a new Slack App
  3. Navigate to OAuth & Permissions on the left sidebar of your app page
  4. Scroll to the Scopes section. Add chat:write, chat:write.public, users:read, channels:history, and app_mentions:read OAuth scopes to the Bot token scopes and add admin to the User token scopes (You need a user token to invite users to the team)
  5. Scroll up to the top of the OAuth & Permissions page and click the Install App to Workspace button. You’ll be led through Slack’s OAuth UI, where you should allow your app to be installed to your workspace. Once this is done, you should be taken back to the OAuth & Permissions page and you should be able to find the user and bot OAuth access tokens. We will need these both in a while

Development

  1. Fork and clone the project
  2. Run yarn to install dependencies
  3. Run cp .env.example .env
  4. Populate SLACK_TEAM_URL in .env with the team URL (e.g. https://<TEAM_NAME>.slack.com)
  5. Go to your Slack app (from https://api.slack.com/apps/) and grab the Signing Secret from the Basic Information page. Populate SLACK_SIGNING_SECRET in .env with the copied signing secret
  6. Navigate to OAuth & Permissions on the left sidebar of your app page. Populate .env with the tokens
SLACK_USER_TOKEN=<OAuth Access Token>
SLACK_BOT_TOKEN=<Bot User OAuth Access Token>
  1. Install ngrok

  2. Run yarn start:dev

  3. Run ngrok http <PORT> in another tab

  4. Set up Event Subscriptions

    Follow https://slack.dev/bolt/tutorial/getting-started#setting-up-events until the URL verification step. Once the URL is verified, add the following bot events

    • app_mention
    • message.channels
    • team_join

    Save the changes.

  5. You're done 🎉 Start hacking 💻

Setting up auto-invites

To invite users via users.admin.invite method, you need a user token with the client scope. Without it, you will receive the following error response when trying to invite a user.

{"ok":false,"error":"missing_scope","needed":"client","provided":"admin,identify"}

Since the client scope is deprecated (legacy), visit https://slack.com/oauth/authorize?&client_id=CLIENT_ID&team=TEAM_ID&install_redirect=install-on-team&scope=admin+client in your browser and authorize your app.

  • TEAM_ID is the subdomain for your slack team, e.g. coding-coach.slack.com - your TEAM_ID is coding-coach
  • CLIENT_ID can be found in Basic Information section for your app

References

slack-bot's People

Contributors

moshfeu avatar arku avatar mnttnm avatar

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.