← All articles

An administrator bot for the private psychotherapy practice "Wellbeing Therapy"

A technical walkthrough of a Telegram admin bot for a psychotherapy practice - booking, reminders, crisis protection, and the principle that code decides, not the model.

Published: 4 min read

Overview

A Telegram bot that works as the administrator of a psychotherapist’s private practice (UAE). It talks to clients and organises appointment booking: it offers free times, takes a request, and reminds about the session. The bot does not give psychotherapeutic advice - it only keeps the schedule. All final confirmations are made by the therapist.

The core idea the whole project rests on: the bot is a backstop for a human, not a replacement for one. It takes the routine off the therapist (messaging about times, keeping the calendar, reminders), but decisions about people remain with the human.

Practice hours: Mon–Fri, 10:00–18:00; a session is 50 minutes + 10 minutes of buffer (bookings are on the hour, not back-to-back). Services: individual consultations, work with couples, teenagers from 17 years old.

Message flow: the crisis check runs first of all, the AI only recognises intent, all decisions and actions are performed by code, and the session is confirmed by the therapist

The request path at a glance: the crisis check comes first; the AI only recognises intent, while all decisions and calendar actions are performed by code; the session is ultimately confirmed by a human.

What the bot can do

  • Speaks different languages - replies in the language the client wrote in (Ukrainian, English, Russian).
  • Shows free times - reads the therapist’s real calendar and offers free slots for the chosen day.
  • Books a consultation - collects a name and contact, creates a preliminary calendar entry.
  • One-tap confirmation - the therapist receives the request with a “Confirm” button; the moment they press it, the client automatically learns the booking is confirmed.
  • Cancellation and rescheduling - with a 24-hour rule (a late cancellation is charged); if the client has several bookings, the bot clarifies which one, by the exact date.
  • Reminds the client about the session 24 hours ahead.
  • Reports to the therapist every morning - at 9:00 it sends the list of confirmed sessions for the day.
  • Crisis protection - if a message shows signs of an acute threat to life, the bot instantly issues an emergency text with emergency-help numbers and notifies the therapist, without entering into any further conversation.
  • Personal-data protection - on first contact it asks for consent to process data; the client can at any time review (/mydata) or delete (/delete) their data. The database is backed up every night.

Technology stack

Layer Technology Purpose
Language Python 3.9 The main implementation language
Bot framework python-telegram-bot==21.6 Telegram Bot API, handlers, inline buttons
Scheduler [job-queue] (APScheduler) Timed background jobs (reminders, digest)
AI model google-genai, gemini-flash-latest model Intent recognition, phrasing facts, the crisis classifier
Calendar google-api-python-client (service account) Reading free slots, creating/changing/deleting events
Database sqlite3 (built-in) Persistent store of bookings, history, metadata
Configuration python-dotenv Secrets from a .env file
Infrastructure Oracle Cloud E2.1.Micro, Oracle Linux 9 Hosting (system time - UTC)
Service systemd Auto-start, restart, 24/7 operation

Background jobs (scheduler)

Job When What it does Duplicate protection
Reminder ≤24 h before a session sends the client a reminder about a confirmed session a reminded flag on the record
Morning digest at 09:00 UAE sends the therapist the list of confirmed sessions for the day last_digest_date in meta

Both jobs are built on the principle of periodic reconciliation with the database, not “scheduling for a specific moment”. This makes them resilient to restarts: after a restart the scheduler simply looks into the database again, while the “already sent” flags sit in SQLite. If the bot was switched off at the moment of an event - the next cycle catches up.

Key principles

  • Code makes the decisions, not the AI model. The model only understands what the client wants; all calendar actions and all checks are performed by programmed code. This stops the model from “inventing” a non-existent booking or doing something extra.
  • Human in the loop. The bot takes the request, but the session is always finally confirmed by the therapist - manually.
  • Safety first. The crisis check is verified first of all, before any other logic. Confidential client data is protected by access rights.
  • Personal-data protection. The bot asks for consent before collecting data, lets the client review (/mydata) or delete (/delete) their data, stores it only in the UAE and makes a secure backup every night - in line with the local data-protection law (PDPL).
  • Honest wording. The bot never says “done” if the action did not actually happen in the code.

The document describes the project as of June 2026.