slackbot for my personal use
README.md

nine #

this is a slackbot that performs a bunch of utility things for my personal channel in slack! it has a join welcomer with a fancy button to join my ping group. it has a bunch of weird autoresponses if you ping it. it does event logging, so if somebody leaves my channel or ping group, it gets logged to a private logging channel.

it also does channel join requests spent wayy too long making. you can dm the bot, and it will ask you a series of (mostly silly) questions, before forwarding them to the admin (just me, but admin sounds fancier), and giving the option of adding to the channel or removing. you can also react to #neighborhood messages, and the bot will reach out to you and ask questions.

theres a couple things on the admin side, namely three dm commands. if you dm the bot join-request-stats, it will respond with the number of open join requests, and the number of all (including ones accepted or rejected). you can dm the bot add @example, which is just a fancy way to add someone to the channel. theres also track-message <message link> :reaction:, which is how you configure a message to be watched for reactions to start join requests.


running it #

to run it, youll need a slackbot in socket mode, configured with these scopes: app_mentions:read, chat:write, groups:write.invites, im:history, im:write, metadata.messages:read, reactions:read, usergroups:read, usergroups:write, channels:read, groups:read. youll also need listeners for these events: app_mention, member_joined_channel, member_left_channel, message.im, reaction_added, subteam_members_changed. you will need to enable sending messages to the bot dms as well. you can also use the manifest.json file in the repo to create your bot in the exact right configuration, though you will still have to manually enable sending messages to the bot in dms

copy .env.example to .env, and fill in all the values. youll need a running postgres server for this! if you dont have one, this command will start one in your current terminal with the username and password "demo": docker run -p 127.0.0.1:5432:5432 -e POSTGRES_USER=demo -e POSTGRES_PASSWORD=demo -e POSTGRES_DB=nine-dev postgres:18

then run docker build -t nine-dev . to build the docker image, and docker run --name nine-dev --net=host --env-file .env nine-dev to start the container. you now should have the bot running!


ai usage #

i did unfortunately rely on ai a bit for this project. it assisted with some parts of sqlalchemy, it helped get the shutdown thing working, and explained how to use slack's strange message metadata system


screenshots #

these are some examples of the logging messages

this is the message welcoming people who join (sent to the main channel)

this is what a join request looks like when sent to the admin

image of admin message

this is what the prompt to reject a request looks like, and what the dm the rejected person gets looks like