Skip to content

BranniganLab/slackbots

Repository files navigation

SlackBots already installed in the Brannigan Lab slack site:


delay-estimator

Estimate contextual delays (the ones you can't control) for research tasks using multiple parameters.

To see usage from within slack, enter

/delay-estimator

from within the slack site where it is installed, or see below:

/delay-estimator best_case_weeks=2 fraction_RD=0.8 hpc_factor=1 num_coauthors=1 stress_level=1

Parameters:

- best_case_weeks: Minimum possible time required, in weeks (e.g. 2)
- fraction_RD: Fraction of task that is R&D (0 to 1)
- hpc_factor: 0 = no HPC, 1 = average reliability, >1 = worse than average
- num_coauthors: Number of coauthors who must weigh in (excluding PI)
- stress_level: 0.5 = rested, 1 = typical, >1 = depleted

Typical output:

image

How to Build your own Slackbot with Python + Flask

(General guide generated by ChatGPT)

This guide will help you build and deploy a Slackbot using Python, Flask, and either your local machine (with ngrok) or PythonAnywhere. It assumes basic comfort with Python but no prior experience with Slack app development.


1. Create a Slack App

  1. Go to https://api.slack.com/apps
  2. Click Create New App > From scratch
  3. Give your app a name (e.g. MyBot) and select your Slack workspace

2. Add a Slash Command

  1. In the left menu, click Slash Commands
  2. Click Create New Command
    • Command: /mybot
    • Request URL: (you'll set this after deployment)
    • Short Description: A test bot
    • Usage Hint: name=value name2=value2
  3. Save the command

3. Enable Interactivity (Optional for buttons or modals)

  1. In the left menu, click Interactivity & Shortcuts
  2. Turn it ON
  3. Set the Request URL to the same endpoint as your slash command

4. Install the App to Your Workspace

  1. In the left menu, go to OAuth & Permissions
  2. Click Install App to Workspace
  3. Authorize access

5. Write Your Flask App

Here is a minimal example (app.py):

from flask import Flask, request, jsonify
app = Flask(__name__)

@app.route("/slack/command", methods=["POST"])
def respond():
    user_input = request.form.get("text", "")
    return jsonify({
        "response_type": "in_channel",
        "text": f"You said: {user_input}"
    })

if __name__ == "__main__":
    app.run()

6A. Deploy Locally with ngrok (for testing)

  1. Install ngrok

  2. In terminal:

    ngrok http 5000
  3. Copy the URL (e.g. https://abcd1234.ngrok.io) into Slack as the Request URL

  4. Run your app locally with:

    python app.py

6B. Deploy with PythonAnywhere (for persistent hosting)

  1. Login into https://www.pythonanywhere.com/ (if this is a lab slackbot, you can run it on the lab pythonanywhere account)

  2. Go to the Files tab and upload your app.py

  3. Go to the Web tab and create a new web app (Manual configuration, Python 3.x)

  4. Edit your WSGI configuration file and replace its contents with:

    import sys
    path = "/home/yourusername"
    if path not in sys.path:
        sys.path.append(path)
    from app import app as application

    Replace "yourusername" with your PythonAnywhere username, and "app" with the name of your Python file (without .py).

  5. Reload your app using the Web tab.

  6. Use this URL as your Slack slash command Request URL:

    https://yourusername.pythonanywhere.com/slack/command
    

7. Test It

In Slack, type:

/mybot Hello world

You should see the bot respond:

You said: Hello world

Optional: Add Help, Buttons, Modals, or Validation

You can expand your bot to support features like:

  • A /mybot help message
  • Rich responses using Slack Block Kit (e.g. buttons, menus, layouts)
  • Interactivity support (e.g. handling button clicks or modal inputs)
  • Custom validation and argument parsing

About

Various bots intended to be integrated with slack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages