Telegram bot that automates client onboarding emails for OTC desks.
Flow: Sales person sends a chat screenshot (WeChat, WhatsApp, etc.) → Claude Vision extracts client info → User confirms → Email sent via Microsoft Graph API.
- Multi-platform OCR — Extracts client name, company, and email from chat screenshots (WeChat, WhatsApp, Telegram, WeChat Work, Lark)
- Smart name extraction — Reads the contact name from the chat header, not from conversation bubbles
- Microsoft Graph API — Sends emails via OAuth (Client Credentials), supports draft and send modes
- Idempotency — SQLite-based deduplication prevents double-sends within 5-minute windows
- Audit log — Every send attempt is recorded for compliance
- User whitelist — Only authorized Telegram users can operate the bot
# Clone
git clone https://github.com/Palebluedot-ai/onboard-bot.git
cd onboard-bot
# Install dependencies
uv sync
# Configure
cp .env.example .env
# Edit .env with your credentials
# Run
uv run python main.pyAll secrets go in .env (never committed):
| Variable | Description |
|---|---|
TELEGRAM_BOT_TOKEN |
From @BotFather |
ALLOWED_USERS |
Comma-separated Telegram user IDs |
ANTHROPIC_API_KEY |
Claude Vision API key |
MICROSOFT_GRAPH_TENANT_ID |
Azure AD tenant ID |
MICROSOFT_GRAPH_CLIENT_ID |
Azure AD app client ID |
MICROSOFT_GRAPH_CLIENT_SECRET |
Azure AD app secret |
MICROSOFT_GRAPH_USER_ID |
Sender email address |
EMAIL_MODE |
draft (default, safe) or send |
CC recipients and other settings are in config.yaml.
User (Telegram) → Screenshot → Claude Vision OCR → Confirm/Edit → Graph API Email → SQLite Log
| Module | File | Purpose |
|---|---|---|
| Bot | src/bot/telegram_bot.py |
Telegram ConversationHandler state machine |
| Vision | src/vision/extractor.py |
Claude Vision API, per-platform prompts |
src/email/sender.py |
Microsoft Graph API (draft + send) | |
| DB | src/db/log.py |
SQLite audit log + idempotency |
| Entry | main.py |
Startup validation + wiring |
uv sync --extra dev
uv run pytest tests/ -vPython 3.11+ · python-telegram-bot v20+ · Anthropic Claude Vision · Microsoft Graph API · Jinja2 · SQLite · uv