Sign inSign up

henry2423/tabot

By henry2423

•Updated almost 7 years ago

A SlackBot which collects team message and analyze team contribution.

Image
0

489

henry2423/tabot repository overview

⁠TeamAssistantBot

A SlackBot which collects team message and analyze team contribution.

Build Status

⁠Current Image Build:

  • henry2423/tabot:latest : Ubuntu 16.04 with Swift 4.2.2

⁠System Requirement:

  • Public IP(for SlackAPI communication). Alternatively you can use Ngrok⁠ to get a public URLs for testing in your own machine.(see Detail session below)
  • Docker⁠ - The whole project is based on Docker Container
  • Docker Compose⁠ - A Docker Container Management Tools to manage MonogoDB and SlackBot Services

⁠Setup Requirement:

  • OAuth Access Token & Bot User OAuth Access Token :

    1. Get the Token from https://api.slack.com/apps⁠ by creating a new app
    2. Once you create an app, go to Bot User tab, create a Bot User.
    3. Go to OAuth & Permissions tab, Install the App into your workspace. You will get a OAuth Access Token and Bot User OAuth Access Token
    4. Don't forget to set the Scopes below the OAuth Tokens & Redirect URLs section. Open All channels:, chat:, groups: and im: permission in order to collect and send message from bot.
    5. Your OAuth Access Token will look like xoxp-xxxxxx....
    6. Your Bot User OAuth Access Token will look like xoxb-xxxxxx....
  • App Verification Token

    1. In Basic Information tab, you will see the Verification Token in App Credentials section.
    2. Your App Verification Token will look like xxxxxxxxxx...
  • Slash Commands API Setup:

    1. Create New Command /setteam, Request URL http://[Your Domain name or IP]:8080/setTeam, and proper short description (e.g. "Assign you in this channel as team").
    2. Create New Command /setdeadline, Request URL http://[Your Domain name or IP]:8080/setDeadline, with proper short description (e.g. "Set Project Deadline (Admin Only)") and Usage Hint "[1] [2019/4/1]".
    3. Create New Command /teamstatistic, Request URL http://[Your Domain name or IP]:8080/getTeamStatisticData, and proper short description (e.g. "See how's your team doing this time").
    4. Create New Command /mystatistic, Request URL http://[Your Domain name or IP]:8080/getMyStatisticData, and proper short description (e.g. "See how's you doing this time").
    5. Create New Command /teamstatisticdetail, Request URL http://[Your Domain name or IP]:8080/getTeamStatisticDataDetail, and proper short description (e.g. "See your team statistic data in detail").
    6. Create New Command /mystatisticdetail, Request URL http://[Your Domain name or IP]:8080/getMyStatisticDataDetail, and proper short description (e.g. "See my statistic data in detail").

⁠Usage:

  • Start The services (MongoDB and SlackBot)

    1. (First Time) Clone the project. Add your credential in .env file. Decide your own DBAdminUsername and DBAdminPassword, the MongoDB service will create the account for you.
    DBAdminUsername=[Your MongoDB Username]
    DBAdminPassword=[Your MongoDB Password]
    OauthToken=[OAuth Access Token]
    OauthBotToken=[Bot User OAuth Access Token]
    VerficationToken=[App Verification Token]
    mongoDBURL=mongodb://[Your MongoDB Username]:[Your MongoDB Password]@mongo:27017/admin
    
    1. Update TimeZone in your Server, and save it into /etc/localtime. You can use data -R to check if timezone is correct right now
    $ tzselect
    $ cp /usr/share/zoneinfo/America/Chicago  /etc/localtime
    $ date -R
    
    1. In the project folder, start all the services with docker-compose
    $ docker-compose up -d
    
    1. NOTE: The MonogoDB database will save in /data in your host machine. You can clean the database by remove /data folder and restart the services.

    2. NOTE: Slack bot serves on port 8080 by default

  • Close the services (MongoDB and SlackBot)

    1. In the project folder, shutdown all the services with docker-compose
    $ docker-compose down
    
    1. NOTE: docker-compose will maintain MonogoDB and SlackBot service if crash, and all the data in MongoDB will remain when services restart.
  • Update the services

    1. In the project folder, shutdown all the services with docker-compose
    $ docker-compose down
    
    1. Update the Slackbot image with docker
    $ docker pull henry2423/tabot
    
    1. In the project folder, restart the services with docker-compose
    $ docker-compose up -d
    

⁠System Overview

  • Crawl All Channels Message in Workspace: The bot will crawl all your Public Channels and Private Channel (if you invited the bot in) and its messages to MongoDB in the first time. And the crawl action will do every 5 minutes.

  • Crawl User Lists in Workspace: The bot will crawl the information of all user in the worksapce in the first time. And update user info every 5 minutes.

  • Crawl Channel Lists in Workspace: The bot will crawl the information of all channels (private and public) in the worksapce in the first time. And update every 5 minutes.

  • Slash Command:

    1. /setteam: This command is for student to assign themself into their private group channel, which is essential for bot to know which team they belongs to. NOTE: Don't forget to add the bot into students' private group channel
    2. /setdeadline [projectIndex] [Date]: This command is used to setup deadline for every projects, it is only available for Administrator in worksapce. Please follow the specific format to setup the deadline (e.g. /setdeadline 1 2019/4/1).
    3. /teamstatistic: View student's team statistic matrix this project compare to previous
    4. /teamstatisticdetail: View student's team statistic matrix across projects
    5. /mystatistic: View student's statistic matrix within their team this project compare to previous
    6. /mystatisticdetail: View student's statistic within their team matrix across projects
  • Interactive Component:

    1. Smart Reminder: When Slack User A in chnnel ask some question and tag User B to answer it. But User B didn't reply to that message in channel after 3 days. Bot will send a notification message to User B Direct Channel to reply message.

⁠Detail

  • Ngrok Setup:

    1. Go to Ngrok⁠ sign up new account, and download ngrok app.
    2. Follow the Setup & Installation steps in ngrok page
    3. Run up ngrok with
    $ ./ngrok http 8080
    
    1. If success, you will see the output below, and the https://bxxxxx.ngrok.io can be used for Slack APP now. Ngrok
    2. NOTE: If you're using Ngrok to setup, Remind the Slash Commands API Setup and Interactive Component Setup in Setup Requirement session, your URL will be https://bxxxxx.ngrok.io/getStatistic and https://bxxxxx.ngrok.io/action with port specified.
  • Build the image from scratch:

    1. Replace the tabot service section in docker-compose.yaml
    tabot:
        build:
          context: .
          dockerfile: Dockerfile
        depends_on:
        - mongo
        links:
        - mongo
        image: henry2423/tabot
        restart: always
        ports:
        - 8080:8080
        environment:
        OauthToken: ${OauthToken}
        OauthBotToken: ${OauthBotToken}
        VerficationToken: ${VerficationToken}
        mongoDBURL: ${mongoDBURL}
    
    1. Start all the services with docker-compose (see Usage session)

⁠Contributors

Tag summary

Content type

Image

Digest

Size

617.5 MB

Last updated

almost 7 years ago

docker pull henry2423/tabot