CS-Club-Bot is a fully automated Telegram bot designed to streamline communication and feedback workflows in a CS internship club. It offers seamless integration with Notion for data storage and Perplexity AI for content analysis, helping mentors and interns stay organized and efficient.
CS-Club-Bot is designed to automate and facilitate the workflow of a CS internship club on Telegram. It handles intern registration, feedback collection, admin communications, and group message processing, with seamless integration to Notion databases and Perplexity AI for content analysis.
- Intern Registration: Collects and stores intern details via Telegram chat.
- Feedback Collection: Generates secure, personalized feedback links for technical and mentorship sessions.
- Admin Messaging: Allows admins to send direct messages to users.
- Group Message Processing: Handles group messages, including AI-powered analysis for specific hashtags.
- Role and Ban Management: Checks user roles and ban status via Notion.
- Notion Integration: Stores and retrieves user data from Notion databases.
- Secure Link Generation: Uses encryption for feedback links.
- Error Handling: User-friendly error messages and robust exception handling.
- Node.js
- Telegraf (Telegram Bot Framework)
- Express
- Notion API (
@notionhq/client) - dotenv
- CryptoJS
- Perplexity AI API
- moment-jalaali (Jalali calendar support)
- Clone the repository:
git clone https://github.com/cs-internship/CS-Club-Bot.git cd CS-Club-Bot - Install dependencies:
npm install
- Configure environment variables:
- Copy
.envexample or create a new.envfile (see below). - Fill in all required values (see table below).
- Copy
- Start the bot:
node index.js
Create a .env file in the project root with the following variables:
| Variable | Description |
|---|---|
| TELEGRAM_BOT_TOKEN | Telegram bot token |
| PERPLEXITY_API_KEY | Perplexity AI API key |
| PORT | Port for Express server (default: 3000/3001) |
| ALLOWED_GROUPS | Comma-separated list of allowed group IDs |
| ADMIN_USERNAME | Telegram username of the admin |
| USERNAME_SPECIAL_FN | Function for username encryption (as string) |
| ENCRYPTION_KEY | Key for encrypting feedback links |
| NOTION_API_KEY | Notion API key |
| NOTION_DATABASE_ID | Notion database ID |
| ADMIN_CHAT_ID | Telegram chat ID for admin group notifications |
| Command / Trigger | Description |
|---|---|
/start |
Start registration or show main menu (private chat only) |
/version |
Show bot version (group only) |
/group_id |
Show current group ID |
/direct <id> <msg> |
Admin: Send direct message to user by Telegram ID |
CS-Club-Bot/
├── .env # Environment variables (not committed)
├── .gitattributes
├── .gitignore
├── LICENSE # MIT License
├── README.md
├── bot.js # Telegraf bot setup and session
├── index.js # Express server entrypoint
├── package.json # Project metadata and dependencies
├── package-lock.json # Dependency lock file
├── bot/
│ ├── config/
│ │ └── index.js # Loads and validates environment variables
│ ├── constants/
│ │ ├── errorResponses.js # Standardized error messages
│ │ ├── system-message.md # System prompt for Perplexity/AI
│ │ └── systemMessage.js # Loads system message from markdown
│ ├── handlers/
│ │ ├── commands/
│ │ │ ├── directMessage.js # Admin direct messaging command
│ │ │ ├── feedbackHandler.js # Feedback link generation logic
│ │ │ ├── groupId.js # Group ID command
│ │ │ ├── registrationHandler.js # User registration logic
│ │ │ ├── start.js # /start command and onboarding
│ │ │ └── version.js # Bot version command
│ │ ├── hears/
│ │ │ ├── documentsList.js # (Stub) List of documents
│ │ │ ├── feedbackSelection.js # Feedback user selection flow
│ │ │ ├── mainMenu.js # Main menu navigation
│ │ │ └── mentorshipFeedback.js # (Stub) Mentorship feedback
│ │ ├── messages/
│ │ │ └── groupHandler.js # Handles group chat messages
│ │ ├── scenes/
│ │ │ └── mainMenu.js # Scene for main menu keyboard
│ ├── registerHandlers.js # Registers all bot handlers
│ ├── services/
│ │ └── perplexity.js # Perplexity AI API integration
│ └── utils/
│ ├── checkUserBanned.js # Checks if user is banned (Notion)
│ ├── checkUserExists.js # Checks if user exists (Notion)
│ ├── createOptions.js # Options builder for Perplexity API
│ ├── getRoleByUsername.js # Gets user role from Notion
│ ├── getUsernameByFullname.js # Gets username by full name (Notion)
└── node_modules/ # Project dependencies (not committed)
folder Structure Details:
bot/handlers/commands/: All Telegram bot commands (admin, registration, feedback, etc.)bot/handlers/hears/: Handlers for custom keyboard/menu triggersbot/handlers/messages/: Handlers for general message events (e.g., group chat)bot/handlers/scenes/: Scene management and menu keyboardsbot/services/: Integrations with external APIs (Perplexity)bot/utils/: Utility functions for Notion, encryption, and API optionsbot/constants/: Static error messages and system promptsbot/config/: Loads and validates all required environment variables
Note:
- All Notion API interactions are handled in
utils/and some command handlers.- The
.envfile is required for all secrets and configuration.node_modules/and.envare not committed to version control.
- Fork the repository and create your branch from
main. - Follow existing code style and structure.
- Write clear commit messages.
- Test your changes before submitting a pull request.
- Open a pull request with a detailed description of your changes.
This project is licensed under the MIT License. See the LICENSE file for details.
- Author: Ali Sadeghi
- Developed for: CS Internship Program
