PHII Labs

HealthTech2021

CBT Therapy Homework Bot for Telegram

Bot asks personalized CBT questions and replies empathetically

CBT Therapy Homework Bot for Telegram

what changed

  • Daily streaks grew 3 → 5 days avg
  • 2.1kmessages processed in month one
  • Dropout rate fell by ~14%

The problem

Therapy homework compliance was low

Built with

  • Python
  • aiogram
  • SQLite
  • Anthropic Claude

Cognitive behavioral therapy works — when people do the homework. Most don't. In 2021, we were asked to build something for a specific gap: patients who started CBT, understood the framework, and then stopped doing the daily exercises that make it effective. The drop-off wasn't a motivation problem. It was a friction problem

The problem

Therapy homework compliance is low across the board. Patients get thought records, behavioral activation schedules and exposure exercises to complete between sessions, and most don't finish them. The reasons are predictable: the exercises feel mechanical, nothing responds to the patient between sessions, and a blank worksheet is a poor substitute for the therapeutic conversation that made the framework click in the first place

Patients didn't need a better worksheet. They needed something that asked the right questions at the right time, responded to their answers the way a coach would, and kept them engaged between sessions. Not a replacement for their therapist — a bridge between sessions

Approach

We built a Telegram bot using Python and aiogram. Telegram was the right surface because the target users already spend their time there — no new app, no login friction, and a chat fits a CBT exercise naturally. A thought record is literally a conversation: what happened, what did you think, what did you feel, what's the evidence for and against

The bot asks personalized CBT questions based on the user's history. We store state in SQLite — not just the current exercise, but the patterns across days. If a user regularly catastrophizes about work on Mondays, the bot can check in on Monday morning. The personalization is rules-driven, not model-driven: the LLM writes the empathetic responses, but the logic that decides which question comes next is deterministic and auditable

The empathetic reply layer uses Anthropic Claude. We chose Claude because tone matters enormously in a mental health context. A canned or robotic response breaks the engagement loop instantly. A response that feels genuinely understanding keeps the user coming back. Claude's voice — measured, warm, not performatively enthusiastic — fit the clinical tone we needed. The model never gives clinical advice. It reflects, validates, and redirects to the exercise. The therapeutic frame stays intact

What was built

A Telegram bot that runs daily CBT check-ins. The user gets a prompt at a time they choose, works through a structured exercise in chat, and gets an empathetic, context-aware response at each step. The bot tracks streaks, remembers patterns across sessions, and adjusts its questions to what the user has been working on. SQLite holds the conversation history and the exercise state. The aiogram framework handles the async Telegram interaction. Claude handles the empathetic narration

The architecture is deliberately simple. One database, one bot framework, one LLM call per turn. No microservices, no queue, no orchestration layer. The complexity is in the prompt design and the state model, not the infrastructure

Results

In the first month, the bot processed 2,100 messages. Daily streaks — consecutive days of completed exercises — grew from an average of 3 days to 5 days. That's the metric that matters: streak length is a direct proxy for homework compliance, and homework compliance is what predicts CBT outcomes. Dropout rate fell by roughly 14% compared to the baseline of patients doing the exercises on their own

A 14% reduction sounds modest, but it isn't. In a mental health intervention, keeping 14% more people engaged through the hardest part — the daily repetition — is the difference between a framework that works on paper and one that works in practice

Takeaway

In a therapeutic context, the LLM's job isn't to be a therapist. It's to be what the worksheet never was: responsive. A worksheet doesn't care what you wrote. A coach does. The model supplies the empathy that makes the exercise feel like a conversation, and the deterministic state machine keeps the conversation inside the clinical frame. That separation — model for tone, rules for structure — kept the bot safe to use and effective at keeping people engaged

Telegram bot →

Find out what AI tells your buyers about you

We ask six AI engines 10 questions your buyers ask, then send you their answers and how to fix each problem. On WhatsApp, within 48 hours

10 questions like these

  • Best dental clinic near JLT?
  • Who does teeth whitening in Dubai Marina?
  • Dentist open late in JLT?
  • + 7 more

in each of 6 AI engines

  • ChatGPT
  • Gemini
  • Claude
  • Perplexity
  • Google AI
  • Grok

Example: a dental clinic