A Telegram bot for journaling, mental health tracking, and emotional wellness β built with Deno, grammY, and SQLite.
JotBot helps you record your thoughts, emotions, and daily experiences directly inside Telegram. It supports two types of entries:
- CBT Entries β Structured entries based on Cognitive Behavioral Therapy (situation, automatic thoughts, emotion tracking with selfie)
- Journal Entries β Free-form journaling with support for photos and voice recordings
JotBot also includes clinically validated mental health assessments (PHQ-9 for depression, GAD-7 for anxiety), a mental health snapshot, crisis resources, and a kitty engine β because studies show that looking at cats can improve your mood. π±
- Deno v2+
- A Telegram bot token from @BotFather
# Clone the repo
git clone <your-repo-url>
cd jotbot
# Copy the environment file and add your bot token
cp .env.example .envEdit .env with your values:
TELEGRAM_BOT_KEY=your_bot_token_here
TELEGRAM_API_BASE_URL=https://api.telegram.org| Variable | Description | Default |
|---|---|---|
TELEGRAM_BOT_KEY |
Your Telegram bot token from @BotFather | (required) |
TELEGRAM_API_BASE_URL |
Custom Telegram Bot API URL | https://api.telegram.org |
The TELEGRAM_API_BASE_URL is useful when running behind a proxy or using a
self-hosted Telegram Bot API server.
# Development (with file watcher)
deno task dev
# Run tests
deno task test
# Compile to standalone binary
deno task bin # x86_64 Linux
deno task bin-arm # aarch64 Linux (ARM)The compiled binaries are output to ./bin/.
Send /start to JotBot. If you're a new user, you'll be prompted to register.
Registration collects your username and date of birth β this is required before
you can use any features.
Use /new_entry to start a structured CBT entry. The bot will guide you
through:
- How are you feeling? β Select an emotion (Very Sad β Very Happy)
- Describe the situation β What happened?
- Automatic thoughts β What thoughts popped into your head?
- Describe the emotion β Elaborate on how you feel
- Take a selfie β Capture how you look in the moment (optional)
Use /new_journal_entry for free-form journaling:
- Write your entry β Tell the bot what's on your mind
- Attach photos β Send as many photos as you'd like, then press Done
- Attach voice recordings β Optionally record voice memos, then press Done
Photos and voice recordings are stored locally and linked to your journal entry.
Use /view_entries to browse your CBT entries. The viewer shows your selfie and
entry details with navigation controls:
| Button | Action |
|---|---|
| β¬ οΈ / β‘οΈ | Navigate between entries |
| βοΈ Edit Entry βοΈ | Edit the selected entry |
| π£ Delete π£ | Delete the selected entry |
| π Exit π | Close the viewer |
Editing: Copy the entry text, modify it, and send it back. Only edit the parts you typed β don't change the field labels (Situation, Automatic Thoughts, etc.) or the bot won't be able to parse it.
Deleting: You'll be asked to confirm before the entry and its selfie are permanently removed.
Use /view_journal_entries to browse your journal entries:
| Button | Action |
|---|---|
| β¬ οΈ / β‘οΈ | Navigate between entries |
| πΌοΈ Photos | View all photos attached to this entry |
| ποΈ Voice | Listen to voice recordings for this entry |
| βοΈ Edit | Edit the journal entry text |
| π£ Delete | Delete the entry and all attached media |
| π Exit π | Close the viewer |
Viewing photos: Pressing πΌοΈ Photos sends all attached photos as a Telegram album (swipeable gallery). A single photo is sent individually. Press βοΈ Dismiss Photos to clean up the messages.
Viewing voice recordings: Pressing ποΈ Voice sends all voice recordings as playable audio messages.
Deleting: Removes the journal entry and cleans up all associated photo and
voice recording files from disk. The database cascade also removes the records
from photo_db and voice_recording_db.
| Command | Assessment | What it Measures |
|---|---|---|
/am_i_depressed |
PHQ-9 (Patient Health Questionnaire) | Depression severity (None β Severe) |
/am_i_anxious |
GAD-7 (Generalized Anxiety Disorder) | Anxiety severity (Minimal β Severe) |
Each assessment walks you through clinically validated questions. Your score, severity level, and a detailed explanation are provided at the end. Scores are stored (if enabled in settings) so you can track changes over time.
β οΈ These are NOT medical or psychiatric diagnoses. Only a trained mental health professional can diagnose mental illness. These tools are meant as personal references to help you understand when to seek help.
Use /snapshot to view a summary of your most recent PHQ-9 and GAD-7 scores,
including severity levels and descriptions.
Use /kitties to open the kitty menu:
- π± Random Kitty β Get a random cat photo
- Kitty Gif β Get an animated cat
- Kitty Says β Get a cat with custom text
- Inspirational β Get a cat with an inspirational quote
Use /π or /sos to display crisis helplines and resources including:
- 988 Mental Health Crisis Line
- National Suicide Prevention Lifeline
- Crisis Text Line (text HOME to 741741)
- The Trevor Project (LGBTQ+)
- Veteran Combat Call Center
- Sexual Assault Resources
Use /settings to manage your preferences:
- Store Mental Health Info β Toggle whether PHQ-9 and GAD-7 scores are saved
- Custom 404 Image β Set a custom image for when a selfie is missing
| Command | Description |
|---|---|
/start |
Start the bot and register if needed |
/help |
Show the help message |
/new_entry |
Create a new CBT entry |
/view_entries |
Browse, edit, and delete CBT entries |
/new_journal_entry |
Create a new journal entry with photos & voice |
/view_journal_entries |
Browse, edit, and delete journal entries |
/snapshot |
View mental health overview |
/am_i_depressed |
Take the PHQ-9 depression assessment |
/am_i_anxious |
Take the GAD-7 anxiety assessment |
/kitties |
Open the kitty engine |
/settings |
Manage your preferences |
/delete_account |
Delete your account and all data |
/π or /sos |
Show crisis helplines |
JotBot uses SQLite with the following tables:
user_db β Registered users
βββ entry_db β CBT entries (1:many)
βββ journal_db β Journal entries (1:many)
β βββ photo_db β Journal entry photos (1:many, CASCADE delete)
β βββ voice_recording_db β Voice recordings (1:many, CASCADE delete)
βββ phq_score_db β PHQ-9 depression scores
βββ gad_score_db β GAD-7 anxiety scores
βββ settings_db β User preferences (auto-created via trigger)
The database is automatically created on first run and migrations are applied on subsequent startups.
jotbot/
βββ main.ts # Bot entry point & command registration
βββ handlers/ # Conversation handlers
β βββ new_entry.ts # CBT entry creation
β βββ view_entries.ts # CBT entry viewer
β βββ new_journal_entry.ts # Journal entry creation (photos + voice)
β βββ view_journal_entries.ts# Journal entry viewer (album support)
β βββ register.ts # User registration
β βββ delete_account.ts # Account deletion
β βββ phq9_assessment.ts # PHQ-9 assessment
β βββ gad7_assessment.ts # GAD-7 assessment
β βββ kitties.ts # Cat image engine
β βββ set_custom_404_image.ts# Custom 404 image setting
βββ models/ # Database CRUD operations
β βββ user.ts
β βββ entry.ts
β βββ journal.ts
β βββ journal_entry_photo.ts
β βββ voice_recording.ts
β βββ phq9_score.ts
β βββ gad7_score.ts
β βββ settings.ts
βββ db/
β βββ migration.ts # Table creation functions
β βββ sql/ # SQL files for tables and queries
βββ types/types.ts # TypeScript type definitions
βββ constants/ # Paths, strings, numbers
βββ utils/ # Keyboards, DB utilities, Telegram helpers
βββ tests/ # Deno test files
βββ assets/ # Stored selfies, journal photos, voice recordings
βββ bin/ # Compiled binaries
This project is licensed under the GNU General Public License v3.0.