Note: This bot was originally built to answer questions for Hack Club Midnight, an in-person murder mystery hackathon in Vienna by Hack Club. This repository serves as a submission for a Hack Club event.
Midnight Welp is a serverless Slack bot designed to handle complex AI queries without hitting the dreaded 3-second timeout limit of Slack's Events API on serverless platforms like Vercel.
Instead of processing the AI response immediately (which takes too long), the bot replies with a "Generate Answer" button. This button opens a web page that runs the AI logic client-side (or via a separate API call) and then updates the original Slack message with the answer.
While this was built for Midnight, it is designed to be a generic "Knowledge Base Bot" for any community. You can adapt it for your own hackathon, club, or discord server (with Slack adapter) easily.
The bot's entire knowledge comes from a single text file.
- File:
api/context.txt - How to customize: Simply replace the text in this file with your own FAQ, rules, or documentation. The AI will strictly adhere to this context.
- Example: Replace the Midnight FAQ with your school's club schedule or your project's documentation.
You can tweak how the bot behaves, its tone, and its rules.
- File:
api/process-ai.js(andapi/slack.js) - How to customize: The code reads
api/context.txtand feeds it to the AI. You can modify the code to prepend instructions like "Talk like a pirate" or "Be extremely concise".
The interaction model (Button -> Web -> Slack) is fully customizable.zable.
- Landing Page:
public/index.html- The page users see if they visit the root URL. - Response Page:
public/response.html- The page that triggers the AI generation. You can style this to match your brand with custom CSS and images.
-
Environment Variables:
SLACK_BOT_TOKEN: Your Slack Bot User OAuth Token.SLACK_SIGNING_SECRET: Your Slack App Signing Secret.GEMINI_API_KEY: Your Google Gemini API Key.
-
Deploy to Vercel:
- This project is optimized for Vercel Serverless Functions.
- Simply import the repo into Vercel and set the environment variables.
-
Slack Configuration:
- Create a Slack App.
- Enable Interactivity and set the Request URL to
https://your-app.vercel.app/api/slack. - Enable Event Subscriptions for
app_mentionand set the Request URL tohttps://your-app.vercel.app/api/slack. - Add
chat:writeandapp_mentions:readscopes.
- Node.js (Vercel Functions)
- @slack/bolt (Slack Framework)
- Google Gemini (AI Model)
- HTML/JS (Frontend for processing)