An AI-powered Discord bot for university club e-boards. Ask questions, get answers from your knowledge base.
/ask [question]- Ask anything about e-board operations/resources- List available resources and links/contacts- Show key contacts/reload- Reload knowledge base (admin)
- Go to Discord Developer Portal
- Click "New Application" → Name it "E-Helper"
- Go to Bot tab → Click "Add Bot"
- Copy the Bot Token (you'll need this)
- Go to General Information → Copy Application ID and Public Key
- Go to OpenAI Platform
- Create a new API key
- Copy it (you'll need this)
# Clone and enter directory
cd eBoard_Discord_Bot
# Copy environment template
cp .env.example .env
# Edit .env with your keys
nano .env # or use your preferred editorFill in your .env:
DISCORD_APPLICATION_ID=your_app_id
DISCORD_PUBLIC_KEY=your_public_key
DISCORD_BOT_TOKEN=your_bot_token
OPENAI_API_KEY=your_openai_key
Edit the files in knowledge/ with your club's information:
contacts.txt- Officers, advisor, university contactsresources.txt- Links to drives, templates, toolsprocedures.txt- How-to guides for common tasksfaq.txt- Frequently asked questions
# Install Google Cloud CLI if needed
# https://cloud.google.com/sdk/docs/install
# Login and set project
gcloud auth login
gcloud config set project YOUR_PROJECT_ID
# Enable required services
gcloud services enable run.googleapis.com
gcloud services enable cloudbuild.googleapis.com
# Deploy
gcloud run deploy e-helper \
--source . \
--platform managed \
--region us-central1 \
--allow-unauthenticated \
--set-env-vars "DISCORD_APPLICATION_ID=$DISCORD_APPLICATION_ID" \
--set-env-vars "DISCORD_PUBLIC_KEY=$DISCORD_PUBLIC_KEY" \
--set-env-vars "DISCORD_BOT_TOKEN=$DISCORD_BOT_TOKEN" \
--set-env-vars "OPENAI_API_KEY=$OPENAI_API_KEY"Copy the deployed URL (e.g., https://e-helper-xxxxx-uc.a.run.app)
- Go back to Discord Developer Portal
- Select your application
- Go to General Information
- Set Interactions Endpoint URL to:
https://YOUR-CLOUD-RUN-URL/interactions - Discord will verify the endpoint (should succeed)
# Install dependencies locally
pip install -r requirements.txt
# Register commands
python register_commands.py- Go to OAuth2 → URL Generator
- Select scopes:
bot,applications.commands - Select permissions:
Send Messages,Use Slash Commands - Copy the URL and open it in your browser
- Select your server and authorize
# Create virtual environment
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
# Install dependencies
pip install -r requirements.txt
# Run locally
python -m uvicorn app.main:app --reload --port 8080For local testing with Discord, you'll need a tunnel like ngrok:
ngrok http 8080Then use the ngrok URL as your Interactions Endpoint.
eBoard_Discord_Bot/
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI app, Discord handling
│ ├── bot.py # OpenAI integration
│ └── knowledge.py # Knowledge file loader
├── knowledge/
│ ├── contacts.txt # Club contacts
│ ├── resources.txt # Links and templates
│ ├── procedures.txt # How-to guides
│ └── faq.txt # Common questions
├── Dockerfile
├── requirements.txt
├── register_commands.py
├── .env.example
└── README.md
Simply edit the .txt files in knowledge/ and redeploy:
gcloud run deploy e-helper --source .Or use /reload command in Discord (triggers hot reload without redeployment).
- Google Cloud Run: Free tier (2M requests/month)
- OpenAI API: ~$1-5/month with gpt-4o-mini
Total: ~$1-5/month for typical club usage
- Double-check your
DISCORD_PUBLIC_KEYis correct - Make sure the interactions URL ends with
/interactions
- Check Cloud Run logs:
gcloud run logs read --service e-helper - Verify slash commands are registered:
python register_commands.py list
- First request after idle may take 2-3 seconds
- This is normal for scale-to-zero; the bot defers the response and replies within seconds
MIT