AI-powered Telegram bot that instantly connects you with the right experts from your community.
PolzaGPT transforms how communities find expertise. Instead of scrolling through endless spreadsheets or asking around in chat groups, simply describe what you need in natural language and get matched with relevant experts in seconds.
PolzaGPT is a Telegram bot that helps community members quickly find experts from a curated database. Ask questions like:
- "I need an iOS developer with SwiftUI experience"
- "Who can help with React Native?"
- "Find me a marketing specialist in Moscow"
- "Show me all backend developers"
The bot uses Google's Gemini AI to understand your query semantically and returns 3-5 ranked expert matches with contact information - all within seconds.
- Natural Language Search - Ask in plain language, no keywords needed
- AI-Powered Matching - Understands context and intent using Google Gemini
- Fast Results - Cached data ensures quick responses (typically under 3 seconds)
- Group & Direct Messages - Works in authorized Telegram groups and private chats
- Always Up-to-Date - Syncs with Google Sheets database automatically
- City Filtering - Specify location to find experts in specific cities
- Flexible Results - Get top matches or ask to "show all" for comprehensive lists
Before setting up PolzaGPT, you'll need:
- Node.js (v18 or higher)
- Telegram Bot Token from @BotFather
- Google Sheets with your expert data
- Google Service Account with Sheets API access
- Google Gemini API Key from Google AI Studio
- Cloudflare Account (free tier works great)
- Clone the repository:
git clone https://github.com/yourusername/polza-gpt.git
cd polza-gpt- Install dependencies:
npm install- Set up environment variables:
Copy the example file and fill in your credentials:
cp .dev.vars.example .dev.varsEdit .dev.vars with your actual values:
# Google Sheets document ID (from the URL)
GOOGLE_SHEET_ID="your-sheet-id-here"
# Google Service Account credentials (JSON format)
GOOGLE_SERVICE_ACCOUNT_KEY='{"type":"service_account",...}'
# Google Gemini API Key
GOOGLE_GEMINI_API_KEY="your-gemini-api-key"
# Telegram Bot Token from @BotFather
TELEGRAM_BOT_TOKEN="123456789:ABC..."
# Webhook secret (generate a random string)
TELEGRAM_WEBHOOK_SECRET="your-random-secret"
# Allowed group chat IDs (comma-separated, negative numbers)
ALLOWED_GROUP_CHAT_IDS="-1001234567890"
# Allowed user IDs for DMs (comma-separated, positive numbers)
ALLOWED_USER_IDS="123456789"- Prepare your Google Sheets database:
Your spreadsheet should have columns for:
- Name (full name or nickname)
- Expertise (skills, specializations)
- Contacts (phone, Telegram, email)
- City (location)
- Year (graduation year or experience level)
Example structure:
Name | Year | City | Expertise | Contacts
------------- | ---- | ------ | ---------------------------- | ------------
Maria Ivanova | 2020 | Moscow | iOS, SwiftUI, React Native | +7 900 ...
Alex Petrov | 2019 | SPb | Backend, Python, PostgreSQL | @alex_dev
- Share the spreadsheet with your service account email (found in the service account JSON)
Start the development server:
npm run devThe bot will be available at http://localhost:8787
- Set up webhook (for local testing, use a tool like ngrok):
ngrok http 8787- Register webhook with Telegram:
curl -X POST "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook?url=https://your-ngrok-url.ngrok.io/webhook&secret_token=your-webhook-secret"-
Add the bot to your authorized Telegram group or send a direct message
-
Try a query:
In a group: @your_bot_name Π½Π°ΠΉΠ΄ΠΈ iOS ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠ°
In DM: Π½Π°ΠΉΠ΄ΠΈ ΠΌΠ½Π΅ backend ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠ°
npm run dev # Start development server
npm run typecheck # Run TypeScript type checking
npm run deploy # Deploy to Cloudflare Workers (production)
npm run logs # View production logs- Create KV namespaces for caching:
# Production
npx wrangler kv:namespace create EXPERTS_KV
# Development
npx wrangler kv:namespace create EXPERTS_KV --preview-
Update
wrangler.tomlwith the KV namespace IDs from the previous step -
Set production secrets:
npx wrangler secret put TELEGRAM_BOT_TOKEN
npx wrangler secret put GOOGLE_GEMINI_API_KEY
npx wrangler secret put GOOGLE_SERVICE_ACCOUNT_KEY
npx wrangler secret put TELEGRAM_WEBHOOK_SECRET
npx wrangler secret put GOOGLE_SHEET_ID
npx wrangler secret put ALLOWED_GROUP_CHAT_IDS
npx wrangler secret put ALLOWED_USER_IDS- Deploy:
npm run deploy- Set up the webhook with your production URL:
curl -X POST "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook?url=https://your-worker.workers.dev/webhook&secret_token=your-webhook-secret"- Add the bot to your authorized Telegram group
- Mention the bot with your query:
@your_bot_name I need a React developer - Get instant expert recommendations with contact info
- Start a chat with the bot
- Send your query directly:
Π½Π°ΠΉΠ΄ΠΈ ΠΌΠ½Π΅ backend ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠ° - Receive personalized expert matches
Simple searches:
iOS developermarketing specialistPython programmer
With location:
frontend developer in Moscowdesigner from Saint Petersburg
Detailed queries:
I need someone who knows React Native and has iOS experienceLooking for a data scientist with machine learning background
Show all matches:
show all iOS developersΠΏΠΎΠΊΠ°ΠΆΠΈ Π²ΡΠ΅Ρ backend ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠΎΠ²
PolzaGPT is built with a modern, serverless architecture:
ββββββββββββββββ
β Telegram β
β Users β
ββββββββ¬ββββββββ
β
β Webhook
βΌ
βββββββββββββββββββββββ
β Cloudflare Worker β
β (Edge Computing) β
ββββββββ¬βββββββββββββββ
β
ββββββββββββΊ Google Sheets API
β (Expert Database)
β
ββββββββββββΊ Google Gemini AI
β (Query Processing)
β
ββββββββββββΊ Cloudflare KV
(Response Cache)
- Runtime: Cloudflare Workers (TypeScript)
- Bot Framework: Grammy (optimized for serverless)
- AI Engine: Google Gemini 2.0 Flash (with fallbacks)
- Data Source: Google Sheets API v4
- Caching: Cloudflare Workers KV (1-hour TTL)
- Type Safety: TypeScript with strict mode
- Cold start: ~1-2 seconds (first request)
- Warm requests: ~500ms - 1 second
- Cache hit: ~200-300ms
- Concurrent requests: Unlimited (edge-distributed)
- Cost: $0 on free tier for most communities
- Authorization: Only whitelisted groups and users can access the bot
- Webhook validation: Secret token prevents unauthorized requests
- No data storage: User queries are not logged or stored
- Service account: Read-only access to Google Sheets
- Environment secrets: Sensitive credentials stored securely in Cloudflare
Edit your .dev.vars or set production secrets:
For group chats:
- Add the bot to your group
- Send a test message
- Check logs for the chat ID (negative number)
- Add to
ALLOWED_GROUP_CHAT_IDS
For direct messages:
- Send a message to the bot
- Check logs for your user ID (positive number)
- Add to
ALLOWED_USER_IDS
Update the bot mention pattern in src/services/telegram.ts:
query = messageText.replace(/@your_bot_name/gi, '').trim();The bot automatically responds in the same language as the query (Russian or English). To customize, edit the prompt in src/services/gemini.ts.
- Check health endpoint:
curl http://localhost:8787/health- View expert data:
curl http://localhost:8787/experts# Check health
curl https://your-worker.workers.dev/health
# View logs
npm run logspolza-gpt/
βββ src/
β βββ config/
β β βββ env.ts # Environment type definitions
β βββ services/
β β βββ gemini.ts # AI query processing
β β βββ sheets.ts # Google Sheets integration
β β βββ telegram.ts # Telegram bot logic
β βββ index.ts # Main worker entry point
βββ context/
β βββ product/ # Product specifications
β βββ spec/ # Feature specifications
βββ .dev.vars.example # Environment variables template
βββ wrangler.toml # Cloudflare Workers config
βββ package.json # Dependencies and scripts
βββ tsconfig.json # TypeScript configuration
Contributions are welcome! Here's how you can help:
- Report bugs - Open an issue with details and reproduction steps
- Suggest features - Share your ideas for improvements
- Submit PRs - Fork, create a feature branch, and submit a pull request
- Improve docs - Help make this README even better
PolzaGPT is perfect for:
- Tech communities finding developers and designers
- Professional networks connecting members with expertise
- Startup ecosystems discovering specialists for projects
- Educational groups matching students with mentors
- Coworking spaces helping members find collaboration partners
Need help? Have questions?
- Check the context/ folder for detailed specifications
- Review the .dev.vars.example for configuration help
- Open an issue for bugs or feature requests
Built with β€οΈ for communities that value expertise and connection.