BotManD is a bot engine designed to simplify the process of creating Slack bots.
BotManD is to Slack conversations what a webserver is to CGI scripts. It allows you to write bots that are simple executables which read from stdin and write to stdout. BotManD manages the lifecycles of the bots--launching instances on demand (a separate instance for each conversation), and terminating conversations when the bot executables exit.
The bots themselves can be very simple. You can write them in any language you want. This is the complete code for a working bot which keeps track of when was the last time someone mentioned "ChatGPT" in the channel:
#!/bin/bash
LAST_MENTION=
while :; do
read MSG
if [[ "$MSG" = *ChatGPT* ]]; then
NOW=$( date +'%s' )
if [[ -n "$LAST_MENTION" ]]; then
echo "It has been $(( NOW - LAST_MENTION )) seconds since someone mentioned ChatGPT last!"
fi
LAST_MENTION="$NOW"
fi
sleep 0.1
done
mentionbot.mov
See examples for more examples. Writing a BotManD bot is so simple that you can write a simple bot that uses ChatGPT to write bots of its own.
BotManD is designed primarily for supporting conversational bots, which incidentally happens to be how most current AI chatbots are set up. For examples of how you can use BotManD to develop AI-powered chatbots, have a look at the gptbot, logparse, and genbot examples.
gptbot1.mov
- Download the latest release of botmand for your platform.
- Extract the archive and move the
botmand
executable to a directory of your choice.
- Create a Classic Slack app: https://api.slack.com/apps?new_classic_app=1
- Click on "App Home" in the left sidebar to get to the bot creation page.
- Click on the "Add Legacy Bot User" button.
- Set a display name and user name for the bot and add the bot.
- Click on "Install App" in the left sidebar.
- Click "Install to Workspace" and allow the bot access to the workspace.
- At this point, you should see the "OAuth Tokens" for your workspace.
There are two tokens displayed, but you just need the "Bot User OAuth Token" which
should start with the string
xoxb-
. - Copy this token to the file
.slack.token
in your home directory.
git clone https://github.com/venkytv/botmand.git
cd botmand/examples/basicbot
make install
Go to a channel in Slack and either use the /invite
command, or just message
the new Slack bot to invite it to the channel.
Launch botmand
from the directory you moved it to.
./botmand
Send a "hello" message mentioning the bot name. The bot should respond in a thread echoing what you said. And then continue echoing whatever you say in the thread until you say "bye".
- gptbot: An AI chat assistant which can participate in the conversation when asked to.
- logparse: An AI assistant which can diagnose issues by reading log files.
- genbot: An AI assistant which can generate shell scripts for requested tasks and run them within the bot.
The bot writing guide has details on writing bots. You could also have a look at the included example bots.
go build