Nest Bot is a Slack bot designed to simplify the Nest registration process for users. It allows users to register for Nest using their Slack username and public SSH key.
Follow these steps to deploy Nest Bot in your environment:
- Python 3.8+
- PostgreSQL Database
- Slack App and Bot Token
-
Create a PostgreSQL database and schema for Nest Bot:
CREATE SCHEMA nest_bot;
-
Create the
userstable to store user registration data:CREATE TABLE nest_bot.users ( id SERIAL PRIMARY KEY, slack_user_id VARCHAR(255) UNIQUE NOT NULL, tilde_username VARCHAR(255) UNIQUE NOT NULL, name VARCHAR(255), email VARCHAR(255), ssh_public_key TEXT NOT NULL, description TEXT NOT NULL, is_approved BOOLEAN DEFAULT FALSE, created_at TIMESTAMP WITH TIME ZONE DEFAULT '1970-01-01 00:00:00 UTC'; );
-
Grant usage on the
nest_botschema to your PostgreSQL user:GRANT USAGE ON SCHEMA nest_bot TO your_postgresql_user;
Create a .env file in your project's root directory and add the following environment variables:
SLACK_BOT_TOKEN=your_slack_bot_token
SQL_DATABASE="your_database_name"
SQL_HOST="your_database_host"
SQL_USER="your_database_user"
SQL_PASSWORD="your_database_password"
SQL_PORT="your_database_port"
SLACK_APP_TOKEN=your_slack_app_tokenReplace your_slack_bot_token, your_database_name, your_database_host, your_database_user, your_database_password, your_database_port, and your_slack_app_token with your specific values.
Note: Switch to psycopg2 NOT BINARY on production
Install the required Python dependencies using the requirements.txt file:
pip install -r requirements.txtStart Nest Bot using the following command:
python your_app_filename.pyReplace your_app_filename.py with the name of the Python script where your Nest Bot code is located.