Skip to content

Slack chatbot to automate on-demand diagnostics collection for NYC Mesh equipment

License

Notifications You must be signed in to change notification settings

nycmeshnet/nycmesh-support-bot

Repository files navigation

NYC Mesh Support Bot

Contributors Forks Stargazers Issues MIT License

Slack chatbot to help with NYC Mesh support requests

GIF showing usage of supportbot in NYC Mesh Slack

Usage

Use the included CLI to run the server like so:

supportbot-server

The server connects to the Slack API via websockets, bypassing the need for a public IP / port.

Getting Started

Installation

To install the supportbot-server command, do the following:

git clone https://github.com/andybaumgar/nycmesh-support-bot.git
cd nycmesh-support-bot/

A virtual environment is optional but recommended:

python3 -m venv venv
source venv/bin/activate

Finally, install this package with

pip install -e .

Prerequisites

You'll need python and pip to install this client. Confirm these are available with:

python3 --version
python3 -m pip --version

If not, install them using the appropriate instructions for your OS here

Credentials

The bot needs Slack API credentials to operate. They are supplied in the .env file.

You can obtain credentials for a Slack workspace by creating a socket-mode app following these instructions.

Usage

> supportbot-server
Starting bolt app...
Bolt app is running!
  • find . -name \*.py -print | entr -r supportbot-server

CLI Arguments

The supportbot-server command is configurable via a few CLI arguments. Use supportbot-server --help to learn more about the available options.

Autoreload (Linux and Mac)

Deploy Process

The supportbot uses GitHub Actions Docker and DockerHub for CI/CD. The GitHub Actions workflow file describes the process.

Running with Docker

  • install Docker Desktop
  • start Docker Desktop
  • clone the repo and open a shell in the root folder
  • ensure you have a .env file with all required credentials
  • if you are running on Windows change the bin/nn_stats.sh carriage return back to LF (cloning on Windows will set it to CRLF, but this will not work in the Linux container)
  • run the following commands:
docker build . -t supportbot
docker run --name nycmesh-support-bot --rm -v "$PWD/.env:/app/.env" supportbot

Testing with Docker

  • follow the directions above for running
  • run the following commands:
docker build . -t supportbot
docker run -v "$PWD/.env:/app/.env" --rm nycmesh-support-bot-test pytest

Dockerhub

Dockerhub is used as an image registry to store our built code before deployment.

Secrets

Secrets are stored in GitHub Secrets, and locally in a .env file. In production a script is used to convert the GitHub Secrets to .env.

GitHub Actions/Runner setup

Github Actions Self Hosted Runner setup description

Starting and Stopping the Runner

An extra command is used to setup the runner as a service:

cd /home/supportbot/actions-runner
sudo ./svc.sh start

Built With

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See the LICENSE file for more information.

Contact

Project Link: https://github.com/nycmeshnet/nycmesh-support-bot

Acknowledgments

About

Slack chatbot to automate on-demand diagnostics collection for NYC Mesh equipment

Resources

License

Stars

Watchers

Forks

Packages

No packages published