An autonomous AI agent that monitors your Gmail for hackathon and competition emails and sends instant Telegram notifications. Runs 24/7 without any manual interaction.
Gmail API → Groq LLM Classifier → Telegram Bot
↑ ↓
└────────── Cron Job ──────────────┘
↕
MongoDB Atlas
(deduplication)
Every N hours the agent:
- Fetches unread emails from your Gmail
- Checks if each email has already been processed (MongoDB)
- Classifies each new email using Groq's LLaMA 3.3 70B model
- Sends a formatted Telegram notification if a hackathon or competition is detected
- Marks the email as processed to prevent duplicate notifications
| Layer | Tool |
|---|---|
| Runtime | Node.js (ES Modules) |
| Email Access | Gmail API (OAuth 2.0) |
| AI Classifier | Groq API — LLaMA 3.3 70B |
| Notifications | Telegram Bot API |
| Database | MongoDB Atlas |
| Scheduler | node-cron |
hackathon-agent/
├── auth/
│ ├── authenticate.js # One-time Gmail OAuth flow
│ ├── credentials.json # Google OAuth credentials (never commit)
│ └── token.json # Gmail access token (never commit)
├── models/
│ └── ProcessedEmail.js # Mongoose schema for deduplication
├── src/
│ ├── emailFetcher.js # Fetches unread emails from Gmail
│ ├── classifier.js # Classifies emails using Groq LLM
│ ├── notifier.js # Sends Telegram notifications
│ ├── storage.js # MongoDB connection and query logic
│ └── agent.js # Main pipeline orchestrator
├── test/
│ ├── testClassifier.js # Tests classifier with fake emails
│ ├── testNotifier.js # Tests Telegram notification
│ └── testStorage.js # Tests MongoDB deduplication
├── cron.js # Schedules agent runs
├── .env # Environment variables (never commit)
├── .gitignore
└── package.json
- Node.js v18+
- A Google account with Gmail
- A Telegram account
- MongoDB Atlas account (free tier)
- Groq Cloud account (free tier)
git clone https://github.com/yourusername/hackathon-agent.git
cd hackathon-agent
npm install- Go to console.cloud.google.com
- Create a new project → enable Gmail API
- Go to APIs & Services → OAuth consent screen
- Choose External → fill in app name and email
- Add your Gmail as a test user
- Go to Credentials → Create Credentials → OAuth Client ID
- Application type: Desktop App
- Download the JSON → rename to
credentials.json→ place inauth/
node auth/authenticate.js- Open the printed URL in your browser
- Sign in and approve access
- Copy the authorization code from the redirect URL
- Paste it in the terminal
auth/token.jsonwill be generated automatically
- Open Telegram → search
@BotFather - Send
/newbot→ follow the prompts - Copy the
BOT_TOKEN - Search
@userinfobot→ send any message → copy yourCHAT_ID - Open your bot on Telegram and send it any message first (required before it can message you)
- Go to mongodb.com/atlas
- Create a free M0 cluster
- Create a database user
- Whitelist IP:
0.0.0.0/0(allow all — for development) - Connect → Drivers → copy the connection string
- Replace
<password>with your database user password
- Go to console.groq.com
- Create an account → API Keys → Create API Key
- Copy the key
Create a .env file in the root directory:
# Gmail
GMAIL_CLIENT_ID=your_client_id
GMAIL_CLIENT_SECRET=your_client_secret
GMAIL_REDIRECT_URI=urn:ietf:wg:oauth:2.0:oob
GMAIL_REFRESH_TOKEN=your_refresh_token_from_token.json
# Telegram
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id
# MongoDB
MONGODB_URI=your_mongodb_connection_string
# Groq
GROQ_API_KEY=your_groq_api_key
node src/agent.jsnode cron.jsDefault schedule: every day at 9am and 6pm.
To change the schedule, edit cron.js:
// Every 2 hours
cron.schedule('0 */2 * * *', ...);
// Every day at 9am and 6pm
cron.schedule('0 9,18 * * *', ...);
// Every 3 hours
cron.schedule('0 */3 * * *', ...);# Test classifier only
node test/testClassifier.js
# Test Telegram notification
node test/testNotifier.js
# Test MongoDB deduplication
node test/testStorage.js