Personable chatbot for Slack using the Slack Realtime Messaging API.
MIT License
Personable chatbot for Slack using the Slack Realtime Messaging API.
See the code reference for API documentation, project file layout, and more.
See the plugin writing guide for information about how to develop your own Botty plugins.
Various plugin setup procedures:
events
: run sudo src/plugins/events/generate_oauth_credentials.py
.haiku
: run sudo src/plugins/haiku/generate_haiku_lines.py
.generate_text
: run sudo src/plugins/generate_text/generate_chains_db.py
.spaaace
: add Imgur API credentials to src/plugins/spaaace/imgur_credentials.json
.snek
: add the emoji from src/plugins/snek/emoji/*.png
to Slack.To run in production mode, run python3 src/botty.py SLACK_API_TOKEN_GOES_HERE
, where SLACK_API_TOKEN_GOES_HERE
is the Slack API token (obtainable from the Slack API site). Alternatively, edit example-start-botty.sh
to replace SLACK_API_TOKEN_GOES_HERE
with the Slack API token, then run ./example-start-botty.sh
.
Currently, a Botty instance is deployed for nokappa.slack.com on EC2 inside a tmux session, to allow monitoring and management over SSH.
From a fresh new t2.micro instance on AWS EC2 with a new 16GB EBS volume:
ssh [email protected]
.sudo yum update
./etc/ssh/sshd_config
, change Port
to 48372
(doesn't increase security, but reduces login spam) and PasswordAuthentication
to no
and PermitRootLogin
to no
and AllowUsers
to ec2-user
. Restart sshd
using sudo service sshd restart
. Stop unnecessary services: sudo service sendmail stop
.sudo yum install git python35 python35-pip python35-devel nginx tmux htop curl libjpeg-devel freetype-devel
.sudo mkdir -p /var/www && cd /var/www && sudo git clone https://github.com/Uberi/botty-bot-bot-bot.git && cd botty-bot-bot-bot
@history
folder (create @history/
and @history/files/
if they don't exist, both with permissions 755).sudo crontab -e
that updates history and merges with RTM chat data using utils/download-history.py
, utils/merge-channel-logs.py
, and utils/export-history-to-db.py
.sudo cp serve-history/botty-upstart.conf /etc/init/botty.conf
.example-start-prod-serve-history.sh
(e.g., Slack OAuth client ID/secret, team ID, Flask sessions secret key).chmod a+w serve-history/log/*
(Gunicorn will be run as user nobody
, so any files it writes must be world-writeable).sudo cp serve-history/botty-nginx.conf /etc/nginx/conf.d/botty.conf; chkconfig nginx on
. Edit the directory path in /etc/nginx/conf.d/botty.conf
if your Botty project is not in /var/www/botty-bot-bot-bot
.sudo wget https://dl.eff.org/certbot-auto && sudo chmod a+x certbot-auto && sudo ./certbot-auto --nginx --debug
, follow the prompts.55 0,12 * * * PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin /var/www/botty-bot-bot-bot/certbot-auto renew --debug >> /var/www/botty-bot-bot-bot/letsencrypt-renew-certificate.log 2>&1
in the root crontab with sudo crontab -e
(setting PATH
is necessary in order to get Nginx config updates to work).sudo initctl restart botty
and sudo service nginx restart
.ssh -p 48372 [email protected] -t 'tmux attach'
Some sources: ExploreFlask, Deploying Gunicorn, Upstart Cookbook.
See the "Deployment" section for information about setting up an environment suitable for developing Botty with.
To test locally, run python3 src/botty.py
in the terminal:
$ ./src/botty.py
No Slack API token specified in command line arguments; starting in local debug mode...
##########################################
# Botty Slack Simulation Environment #
##########################################
This is a local chat containing only you and Botty. It's useful for testing and debugging.
The following slash commands are available:
/react -3 eggplant | reacts to the third most recent text message with an eggplant
/unreact 1 heart | removes the heart reaction from the second earliest text message
/reply -1 yeah definitely | replies to the most recent text message with "yeah definitely"
/channel random | moves you and Botty to the #random channel
#general | Me: hello
#general | Me: calc integrate(1/x, x)
#general | Botty: integrate(1/x, x) :point_right: log(x)
#general | Me: /reply -1 threads work too :O
#general | Me (in thread for "integrate(1/x, x) :point_right: log(x)"): threads work too :O
#general | Me: where are the eggplants?
#general | Botty reacted to "where are the eggplants?" with :eggplant:
#general | Me: biggify hello
#general | Botty: ```
___ ___ ___ ___ ___
/\__\ /\ \ /\__\ /\__\ /\ \
/:/ / /::\ \ /:/ / /:/ / /::\ \
/:/__/ /:/\:\ \ /:/ / /:/ / /:/\:\ \
/::\ \ ___ /::\~\:\ \ /:/ / /:/ / /:/ \:\ \
/:/\:\ /\__\ /:/\:\ \:\__\ /:/__/ /:/__/ /:/__/ \:\__\
\/__\:\/:/ / \:\~\:\ \/__/ \:\ \ \:\ \ \:\ \ /:/ /
\::/ / \:\ \:\__\ \:\ \ \:\ \ \:\ /:/ /
/:/ / \:\ \/__/ \:\ \ \:\ \ \:\/:/ /
/:/ / \:\__\ \:\__\ \:\__\ \::/ /
\/__/ \/__/ \/__/ \/__/ \/__/```
#general | Me:
Botty ships with several plugins by default, some of which require API keys or take some time to start. If you don't need those plugins, simply comment out the relevant lines in the body of the initialize_plugins
function in src/botty.py
to disable them.
Copyright 2015-2017 Anthony Zhang (Uberi).
The source code is available online at GitHub.
This program is made available under the MIT license. See LICENSE.txt
in the project's root directory for more information.