An AI marketing assistant in Telegram that plans, creates, and analyzes β from captions to campaign strategies to performance reports. Automated tests. Defense-in-depth security. Local dashboard included.
Chat with it like a marketing colleague. It does the rest.
Tech Stack: Python 3.11+ Β· python-telegram-bot Β· OpenAI-compatible LLM Β· SQLite Β· Notion API
Why Digital Mate? Β· Who is this for? Β· Features Β· Demo Β· Quick Start Β· Architecture Β· Contributing Β· Roadmap
Digital Mate is a production-grade AI marketing assistant built for Telegram. It understands natural language marketing requests, routes them to specialized AI pipelines, and delivers actionable outputs β captions, strategies, research reports, and analytics.
No dashboard. No learning curve. Just chat.
| Feature | ChatGPT | Generic AI Bots | Digital Mate |
|---|---|---|---|
| Marketing-specific prompts | β Generic | β 4 specialized pillars | |
| Multi-step workflows | β Single turn | β | β Automatic tool chaining |
| Self-reflection & auto-optimization | β | β | β Quality scoring + refinement |
| Proactive reminders | β | β | β Weekly digests + nudges |
| Security hardening | β | β 510 tests, 3 guard layers | |
| Brand voice memory | β | β Per-chat brand profiles | |
| Open source | β | β | β MIT License |
| Telegram native | β | β Built for Telegram |
Most AI tools give you a blank chat box. Digital Mate gives you a marketing team β with memory, workflows, quality control, and security built in.
- π§βπ» Solo founders β "I need marketing content but can't afford an agency."
- πͺ Small business owners β "I know I should post on social media but don't know what."
- π§βπ¨ Marketing freelancers β "I need to scale my output without sacrificing quality."
- π Startup teams β "We need a marketing strategy but our budget is $0."
If you think in marketing terms but don't have a team to execute β Digital Mate is your team.
You: Write me 3 Instagram captions for a new coffee shop in Jakarta
Mate: π 3 Caption Variations β Coffee Shop Launch
β Variation 1: Warm & Inviting β "first sip hits different..."
π₯ Variation 2: Playful & Bold β "POV: You just found your new spot..."
π€ Variation 3: Minimal & Aesthetic β "Good coffee. Warm light..."
- Multi-platform captions β Instagram, TikTok, Twitter/X, LinkedIn, Facebook
- Hook generator β 8+ psychological hook frameworks (curiosity gap, pain point, bold claim...)
- Content calendar β Weekly content plans with channel-specific scheduling
- Newsletter & email β Subject lines, body copy, CTA optimization
- Hashtag strategy β Mix of reach, niche, and branded hashtags
- Campaign blueprints β Full funnel breakdown (awareness β conversion)
- Launch playbooks β Phase-by-phase launch strategies with timelines
- Marketing audits β Structured checklist-based analysis
- Budget allocation β Channel mix recommendations by goal
- Competitor analysis β Real-time web research with structured reports
- Audience personas β Data-driven persona builder with demographics + psychographics
- Keyword research β Volume, difficulty, intent mapping
- Trend monitoring β Industry trend identification via live web search
- Performance reports β Input raw metrics, get executive summaries
- KPI frameworks β Platform-specific benchmark comparisons
- WhatβWhyβDo β Structured interpretation methodology
- Action prioritization β Impact vs. effort matrix for next steps
- Research β Content β Search trends, then generate captions referencing real data
- Research β Strategy β Competitor analysis feeds into a marketing plan
- Analytics β Strategy β Interpret metrics, then recommend improvements
- Strategy β Content β Marketing plan drives a content calendar
- Progress streamed to user: "π Searching trends... β βοΈ Writing caption..."
- Automatic planning β Break "launch a product" into 2β7 concrete steps
- Step-by-step execution β Each step runs the right pillar with the right data
- Plan persistence β Plans survive bot restarts, resume automatically on startup
/plancommand β View progress, cancel anytime with/cancelplan
- Critic + Refiner loop β Evaluates output on hook strength, brand voice, CTA clarity
- Automatic iteration β Scores < 7 trigger regeneration (up to 2 rounds)
β¨ Auto-optimizedindicator shown when reflection improved the output- Pillar-aware β Always runs for Content/Strategy, optional for Research, skips Analytics/General
- Trend digests β Weekly search for trending topics in the user's industry
- Content reminders β Nudge when the user hasn't posted recently
- Campaign alerts β Flag when a campaign has been running long enough to review
/digestcommand β Trigger an on-demand trend digest
- Image analysis β Send screenshots, ads, or analytics dashboards
- Context-aware β Vision results feed into the appropriate pillar for interpretation
- Multi-format β Supports photos, documents, and image replies
- Key facts extraction β Auto-extracts 0β3 facts every 10 messages
- Cross-session recall β Facts injected into future prompts for continuity
/forgetcommand β Clear stored key facts on demand
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Telegram Bot β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β /start β β /brand β β /calendar β β
β β /plan β β /digest β β /forget β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ β
β ββββββββββββββββββββΌβββββββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β π‘οΈ Security Guard Layer β β
β β Input Guard: injection | role hijack | exfil β β
β β Output Guard: leakage | hallucination markers β β
β β Brand Guard: field sanitization | injection strip β β
β βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β π§ Intent Router + Routing Classifier β β
β β LLM classify β pillar + action β β
β β Route decision β workflow | plan | single β β
β βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β π€ Agent Orchestrator β β
β β ββββββββββββ ββββββββββββ ββββββββββββββββββββ β β
β β β Workflow β β Planner β β Reflection β β β
β β β Engine β β + Executorβ β (Critic+Refiner) β β β
β β ββββββββββββ ββββββββββββ ββββββββββββββββββββ β β
β βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ β
β βΌ β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β Content β β Strategy β β Research β βAnalytics β β
β β Pillar β β Pillar β β Pillar β β Pillar β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β β β β β
β ββββββββββββββββΌββββββββββββββΌβββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β π¦ Infrastructure Layer β β
β β SQLite (sessions, brand, plans, key_facts, triggers)β β
β β Notion β Tavily/DuckDuckGo β Vision β Scheduler β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Decision | Choice | Why |
|---|---|---|
| LLM backend | OpenAI-compatible API | Pluggable β works with OpenAI, Anthropic, local models, any compatible endpoint |
| Intent routing | LLM classification + keyword fallback | Accurate semantic routing without fine-tuning |
| Route dispatch | Orchestrator decides: workflow, plan, or single | Same classifier output, three execution paths |
| Memory | SQLite + session context + key facts | Zero-dependency, no external DB needed |
| Prompts | .md template files |
Easy to edit, version control, iterate without code changes |
| Security | Input/Output/Brand guards | Defense-in-depth against prompt injection, data leakage, role hijacking |
| Integrations | Notion + Web Search + Vision | Real data, not hallucinated marketing advice |
| Reflection | Critic + Refiner loop (max 2 rounds) | Quality gate without infinite loops |
| Planning | LLM planner + executor + SQLite plan store | Survives restarts, supports /plan and /cancelplan |
curl -sSL https://raw.githubusercontent.com/Yanu403/digital-mate/master/install.sh | bashThis installs Digital Mate to ~/.digital-mate/, sets up Python venv, and creates the .env config file.
Then start the dashboard:
DASHBOARD_API_KEY="$(openssl rand -hex 24)" ~/.digital-mate/bin/digital-mate serveOr set DASHBOARD_API_KEY in .env, then run:
~/.digital-mate/bin/digital-mate serveOpen http://localhost:7749/?api_key=<your-dashboard-key> β configure your Telegram token, LLM key, and brand profile from the web UI. No terminal editing needed.
Or auto-launch after install:
curl -sSL https://raw.githubusercontent.com/Yanu403/digital-mate/master/install.sh | bash -s -- --launch
git clone https://github.com/Yanu403/digital-mate.git
cd digital-mate
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .envEdit .env with your credentials:
# Required
TELEGRAM_BOT_TOKEN=your_bot_token
LLM_BASE_URL=https://api.openai.com/v1
LLM_API_KEY=your_api_key
LLM_MODEL=gpt-4o
# Optional
NOTION_API_KEY=your_notion_key
SEARCH_PROVIDER=duckduckgoWorks with any OpenAI-compatible endpoint: OpenAI, Anthropic (via proxy), Groq, Together AI, local Ollama, LM Studio, vLLM, etc.
# Development
python -m digital_mate
# Headless bot
digital-mate run
# Local dashboard and bot manager
digital-mate serve| Command | Description |
|---|---|
/start |
Welcome message & quick tour |
/help |
Full command list with examples |
/brand |
Set up your brand profile (name, tone, audience, competitors) |
/calendar |
Generate a weekly content calendar |
/research |
Deep research on a topic, competitor, or trend |
/report |
Create a performance report from your metrics |
/plan |
View active plan progress or start a new goal plan |
/cancelplan |
Cancel the currently running plan |
/digest |
Trigger an on-demand trend digest |
/forget |
Clear stored key facts (long-term memory) |
/history |
View your recent conversations |
/clear |
Reset conversation context |
Just talk to it naturally β no commands needed:
"Analyze my competitor @brandx on Instagram"
"Write a launch email for my SaaS product"
"What are the trending hashtags for fintech in Indonesia?"
"I got 15K impressions, 2.3% engagement, 45 clicks β analyze this"
Digital Mate ships with a defense-in-depth security layer protecting against common LLM application attacks:
Blocks malicious prompts before they reach the LLM:
| Attack Vector | Detection | Status |
|---|---|---|
| Prompt extraction | "ignore instructions", "reveal system prompt" | π‘οΈ Blocked |
| Role hijacking | "you are now DAN", "pretend you're..." | π‘οΈ Blocked |
| Data exfiltration | "send data to URL", "exfiltrate API keys" | π‘οΈ Blocked |
| Obfuscation | Base64-encoded injection, Unicode tricks | π‘οΈ Blocked |
| Harmful content | Phishing, malware, social engineering | π‘οΈ Blocked |
Scans LLM responses for:
- System prompt leakage
- Internal configuration exposure
- API key / credential fragments
All user-provided brand fields are sanitized against:
- Code block injection
- XML/ChatML tag injection
- Markdown separator abuse
Automated tests cover security scenarios and run in CI on supported Python versions. See tests/test_security.py.
# Install test and build tooling
pip install -r requirements-dev.txt
# Run all tests
pytest
# With the same coverage gate used by CI
pytest --cov=digital_mate --cov-report=term-missing --cov-fail-under=70
# Run specific test suite
pytest tests/test_security.py -v # Security tests
pytest tests/test_content.py -v # Content pillar tests
pytest tests/test_router.py -v # Intent routing tests
pytest tests/test_orchestrator.py -v # Orchestrator + workflow tests
pytest tests/test_planner.py -v # Goal decomposition tests
pytest tests/test_critic.py -v # Self-reflection critic tests
pytest tests/test_refiner.py -v # Self-reflection refiner tests
pytest tests/test_reflection.py -v # Reflection engine tests
pytest tests/test_triggers.py -v # Proactive trigger tests
pytest tests/test_scheduler.py -v # Scheduler tests
pytest tests/test_key_facts.py -v # Long-term memory tests
pytest tests/test_feedback.py -v # Feedback button testsPull requests and pushes to master run tests with coverage on Python 3.11 and
3.12, then verify the wheel and source distribution can be built.
| Endpoint | Authentication | Purpose |
|---|---|---|
GET /api/health |
Public | Liveness, application version, and timestamp |
GET /api/ready |
Public | Required configuration and SQLite availability |
GET /api/metrics |
X-API-Key |
Aggregate LLM requests, failures, latency, in-flight calls, and provider token usage |
Metrics are aggregate and process-local. They never contain prompts, responses,
credentials, or user/chat identifiers. The bot writes its latest snapshot to
METRICS_PATH (default data/runtime-metrics.json) so the separate dashboard
process can expose it. Token counters are populated when the LLM provider returns
OpenAI-compatible usage metadata. For release steps and rollback guidance, see
docs/RELEASING.md.
digital-mate/
βββ digital_mate/
β βββ AGENT.md # Bot personality & marketing expertise
β βββ bot.py # Telegram handlers + security integration
β βββ config.py # Environment configuration
β βββ router.py # LLM-powered intent classification
β βββ llm/
β β βββ client.py # OpenAI-compatible async client
β β βββ prompts.py # Template engine (.md file loader)
β βββ agent/
β β βββ orchestrator.py # Central dispatch: workflow | plan | single
β β βββ workflow.py # Workflow engine + 4 built-in workflows
β β βββ planner.py # LLM goal decomposition (2β7 steps)
β β βββ executor.py # Plan step execution + error recovery
β β βββ plan_store.py # SQLite plan persistence (resume on restart)
β β βββ critic.py # Output quality evaluator
β β βββ refiner.py # Iterative output improvement
β β βββ reflection.py # Reflection engine (critic + refiner loop)
β β βββ triggers.py # Proactive trigger definitions + detection
β β βββ scheduler.py # Cron-like scheduled task runner
β βββ pillars/
β β βββ base.py # Base pillar with shared context
β β βββ content.py # Content & copywriting pipeline
β β βββ strategy.py # Strategy & planning pipeline
β β βββ research.py # Research & insight pipeline
β β βββ analytics.py # Analytics & reporting pipeline
β βββ prompts/ # Prompt templates (editable .md files)
β β βββ router.md # Intent classification rules
β β βββ content.md # Content generation expertise
β β βββ strategy.md # Strategic planning frameworks
β β βββ research.md # Research methodology
β β βββ analytics.md # Analytics interpretation
β β βββ planner.md # Goal decomposition prompt
β β βββ general.md # Chitchat / help responses
β βββ integrations/
β β βββ notion_client.py # Notion API integration
β β βββ search.py # Tavily / DuckDuckGo search
β βββ memory/
β β βββ database.py # SQLite async storage (schema v7)
β β βββ session.py # Conversation context (last N turns)
β β βββ brand_profile.py # Per-chat brand profiles
β β βββ key_facts.py # Long-term memory (auto-extract every 10 msgs)
β β βββ response_store.py # Feedback storage (π/π/π)
β β βββ autocalendar.py # Auto content calendar generator
β βββ utils/
β βββ formatting.py # Markdown formatting for Telegram
β βββ validators.py # Input validation
β βββ security.py # Security guard layer
β βββ keyboards.py # Inline feedback keyboards (π/π/π)
β βββ image.py # Vision / image processing
βββ tests/ # 510 automated tests
βββ deploy/ # Systemd service files
βββ docs/
β βββ ARCHITECTURE.md # Architecture deep-dive
β βββ notion-setup.md # Notion database setup guide
β βββ screenshots/ # Demo screenshots
βββ .env.example # Configuration template
βββ requirements.txt # Python dependencies
βββ LICENSE # MIT
| Variable | Description |
|---|---|
TELEGRAM_BOT_TOKEN |
Bot token from @BotFather |
LLM_BASE_URL |
OpenAI-compatible API endpoint |
LLM_API_KEY |
API key for your LLM provider |
LLM_MODEL |
Model name (e.g., gpt-4o, mimo-v2.5-pro) |
| Variable | Default | Description |
|---|---|---|
NOTION_API_KEY |
β | Notion integration token |
NOTION_CALENDAR_DB |
β | Content calendar database ID |
NOTION_CAMPAIGN_DB |
β | Campaign tracker database ID |
SEARCH_PROVIDER |
duckduckgo |
Search backend (tavily or duckduckgo) |
TAVILY_API_KEY |
β | Required if using Tavily search |
MAX_HISTORY |
10 |
Conversation context window |
BOT_LANGUAGE |
en |
Default language (en, id, es, zh, ja) |
LOG_LEVEL |
INFO |
Logging verbosity |
- 4 marketing pillars (content, strategy, research, analytics)
- LLM-powered intent routing
- Bilingual support (English + Indonesian)
- Per-chat brand profiles
- Security guard layer
- Notion integration
- Web search integration
- 105 automated tests (expanded to 510 in Phase 2)
- Tool chaining & multi-step workflows (4 built-in workflows)
- Goal decomposition & planning (LLM planner, 2β7 steps)
- Plan persistence & auto-resume on restart
- Self-reflection engine (critic + refiner, max 2 iterations)
- Proactive triggers (trend digests, content reminders, campaign alerts)
- Long-term memory (key facts extraction every 10 messages)
-
/plan,/cancelplan,/forget,/digestcommands - Vision / image input support
- Multi-language support (EN, ID, ES, ZH, JA)
- Feedback buttons (π/π/π)
- LLM-based routing classifier (replaces keyword matching)
- Reflection feedback visible to user (β¨ Auto-optimized indicator)
- 510 automated tests
- WhatsApp Business API integration
- Auto-scheduled weekly content calendars
- Image generation for social posts
- Analytics dashboard (web UI)
- Custom training on brand voice history
- Team collaboration (shared brand profiles)
- A/B testing suggestions with prediction
- CRM integration (HubSpot, Salesforce)
- Social media scheduling (direct posting)
# Install dev dependencies
pip install -r requirements.txt pytest pytest-asyncio pytest-cov
# Run with debug logging
LOG_LEVEL=DEBUG python -m digital_mate
# Format code
black digital_mate/ tests/
ruff check digital_mate/ tests/- Create
digital_mate/pillars/yourpillar.pyextendingBasePillar - Write prompt template at
digital_mate/prompts/yourpillar.md - Register in router's pillar map
- Add tests in
tests/test_yourpillar.py
- Define the workflow in
digital_mate/agent/workflow.py - Add detection logic in
digital_mate/agent/orchestrator.py - Add tests in
tests/test_workflow.py
Contributions welcome! Here's how:
- Fork the repo
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- π·οΈ
good-first-issueβ Beginner-friendly tasks - π·οΈ
help-wantedβ Features we need help with - π·οΈ
documentationβ Docs improvements
git clone https://github.com/Yanu403/digital-mate.git
cd digital-mate
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install pytest pytest-asyncio pytest-cov ruff black
pytest # Should show 510 passingMIT License β see LICENSE for details.
- python-telegram-bot β Telegram Bot API wrapper
- OpenAI Python SDK β LLM client
- Tavily β AI-optimized web search
- Notion API β Workspace integration
Built with β€οΈ by Reazer
β Star this repo if Digital Mate saved you time β it helps others discover the project and keeps development going.


