Skip to content

A simple Slack slash command for solving math problems

License

Notifications You must be signed in to change notification settings

ntdkhiem/Math-Genie

Repository files navigation

Math Genie :octocat:

Simple slack slash command for solving math problems

Features 🔥

  • Based on Wolfram|Alpha APIs
  • Simple to use
  • Python3 support
  • Can reply to any math problems

Requirements ⚒️

Installation 🔧

git clone https://github.com/TopKeingt/Math-Genie

or click here to download respository's zip file.

python -m pip install -r requirements.txt

Prerequisite 🔨

Generate The Wolfram App Id

You need to create a wolfram app id (the core of the program to work)

  1. Create a wolfram alpha account or sign in here
  2. Create an App Id here (only when you signed in)
    1. Click Get an AppID and enter your Application Name and Description screenshot-1
    2. Copy the APPID and paste to WOLFRAM_APP_ID in config.ini screenshot-3

Generate The Slack Api Token

Because the program will run on Slack so you need to get slack api token to able to communicate.

What is Slack ? 📝

Slack is a collaboration hub for work, no matter what work you do. It’s a place where conversations happen, decisions are made, and information is always at your fingertips. With Slack, your team is better connected.

  1. Go to api.slack.com

  2. Create a new Slack Applications or use your old Slack App (this project only add one slash command to your bot).

  3. Copy Vertification Token and paste to SLACK_VERTIFICATION_TOKEN in config.ini screenshot-4

  4. Go to Slash Commands

    1. Click Create New Command and fill out the form then save. screenshot-7
  5. Go to OAuth & Permissions

    1. Select Send messages as [app's name] under Scopes and click Save Changes

    screenshot-5

    1. Click Install App to Workspace on the very top of the page and authorize your app to communicate with your slack's workspace.
    2. When successfully authorized, it will redirected back to your app page. Copy OAuth Access Token and paste to SLACK_BOT_TOKEN in config.ini.

    screenshot-6

Usage 🍽️

Now you will able to run the program with python

❗ Any missing value in config.ini will break the program. Please follow the instruction above to fill out the configuration.

The example of what config.ini should look like: code How to run ?

$ python main.py --help
usage: main.py [-h] [-p] [-d]

Run the program in [mode]

optional arguments:
  -h, --help         show this help message and exit
  -p, --production   Run the program in production mode
  -d, --development  Run the program in development mode

example:

$ python main.py --development
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 232-100-363
 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)

Notice ❗

since slack's app doesn't allow slash commands to use local url like http://127.0.0.1:3000 as Request Url please use ngrok to generate public url.

Example Usage

$ ngrok http 5000
ngrok by @inconshreveable                                                                               (Ctrl+C to quit)

Session Status                online
Account                       TopKeingt (Plan: Free)
Version                       2.2.8
Region                        United States (us)
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://30081a1a.ngrok.io -> localhost:3000
Forwarding                    https://30081a1a.ngrok.io -> localhost:3000

Connections                   ttl     opn     rt1     rt5     p50     p90
                              0       0       0.00    0.00    0.00    0.00

and use http://[ngrok's id].ngrok.io as Request Url

Pull requests are welcome 🔎

Video demonstration coming soon

Releases

No releases published

Packages

No packages published

Languages