Skip to content

FroogalTheDragon/jotbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

331 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– JotBot

A Telegram bot for journaling, mental health tracking, and emotional wellness β€” built with Deno, grammY, and SQLite.

What is JotBot?

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. 🐱

Getting Started

Prerequisites

Installation

# Clone the repo
git clone <your-repo-url>
cd jotbot

# Copy the environment file and add your bot token
cp .env.example .env

Edit .env with your values:

TELEGRAM_BOT_KEY=your_bot_token_here
TELEGRAM_API_BASE_URL=https://api.telegram.org

Environment Variables

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.

Running

# 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/.

How to Use JotBot

1. Register

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.

2. Create a CBT Entry

Use /new_entry to start a structured CBT entry. The bot will guide you through:

  1. How are you feeling? β€” Select an emotion (Very Sad β†’ Very Happy)
  2. Describe the situation β€” What happened?
  3. Automatic thoughts β€” What thoughts popped into your head?
  4. Describe the emotion β€” Elaborate on how you feel
  5. Take a selfie β€” Capture how you look in the moment (optional)

3. Create a Journal Entry

Use /new_journal_entry for free-form journaling:

  1. Write your entry β€” Tell the bot what's on your mind
  2. Attach photos β€” Send as many photos as you'd like, then press Done
  3. Attach voice recordings β€” Optionally record voice memos, then press Done

Photos and voice recordings are stored locally and linked to your journal entry.

4. View & Manage CBT Entries

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.

5. View & Manage Journal Entries

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.

6. Mental Health Assessments

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.

7. Mental Health Snapshot

Use /snapshot to view a summary of your most recent PHQ-9 and GAD-7 scores, including severity levels and descriptions.

8. Kitties 🐱

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

9. Crisis Resources

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

10. Settings

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

Commands Reference

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

Database Schema

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.

Project Structure

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

License

This project is licensed under the GNU General Public License v3.0.

ko-fi

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors