DEV Community

Sanyam Agarwal
Sanyam Agarwal

Posted on

I built a local Gemma 3 bot to help my friend remember her iron tablets

Hacktoberfest Weekend Challenge: Build for a Friend Submission 🤝

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend

What I Built

TL;DR: a local-first Telegram bot, running Gemma 3 4B on my laptop, that reminds a friend to take her iron and vitamins.

IronMate is a Telegram bot I built for my friend. She's a medical student, and she told me she struggles to remember her daily iron and multivitamin tablets. So the bot does the remembering for her:

  • It sends a morning multivitamin reminder and an evening iron reminder.
  • One-tap buttons log her dose: Took Iron, Took Vitamin, Snooze 30m, Just had Chai (Wait 45m). The chai button exists because tea and coffee block iron absorption.
  • It tracks her streak, so a missed day is visible.
  • She can also just text it. It replies in short, casual Hinglish, the way I text her, and it understands messages like "Class me hu baad me ping karna" (snooze) or "Iron le li" (log).

It's open about being a bot. Its /start message says it was made by me to remind her about her supplements, and it never claims to be the real me.

Demo

I'm not sharing the real chat, to protect her privacy.

Code

IronMate 💊

IronMate is a warm, thoughtful companion and wellness reminder Telegram bot built to look after a friend's daily supplement routine (iron and multivitamins).

It pairs proactive, context-aware reminders with natural, casual Roman-script Hinglish conversations powered by local LLM inference (via Ollama) and a fast deterministic precedence router.


Key Features

  • Personalized Supplement Tracking:

    • Automated intake logging in SQLite (supplements.db).
    • Consecutive streak calculation for consistency and motivation.
    • Distinction between morning multivitamins and evening iron pills.
  • Intelligent Precedence Router:

    • Snooze / Busy Detection: Understands when your friend is busy in class, traffic, driving, or meetings, and dynamically postpones reminders.
    • Beverage Protection: Automatically suggests waiting 45 minutes if your friend just had chai, coffee, or milk (tannins inhibit iron absorption).
    • Intake Negation Detection: Detects phrases like "iron lena bhool gayi" or "didn't take my iron yet" without false-logging.
    • Context-Aware Chit-Chat: Routes affectionate check-ins, banter, questions, and health follow-ups.
  • Warm &…

How I Built It

Open-source stack

  • Gemma 3 4B (open weights), served locally through Ollama on my laptop (RTX 3050 6 GB), with the model files stored on a separate drive.
  • Python, a Telegram bot, and a small local database for intake logs and streaks.
  • pytest tests that run without any model, so the logic is checked offline.

What I learned about small models

My first version used Llama 3.2 3B and the replies were bad: it repeated filler words ("arre toh toh toh"), invented plans I never had, and called tools on casual messages like "hello". Better prompts didn't fix it. Changing the architecture did:

  1. The model never decides when to run a tool. A deterministic router (word-boundary matching, negation handling, a clear precedence order) classifies each message as intake, snooze, or chit-chat. Python then logs the dose or sets the snooze directly. The model is only asked to write one short line afterwards, and it never sees a tool schema. A message like "iron nhi li" (didn't take iron) correctly logs nothing.
  2. A reply bank comes first. For common situations (greetings, affection, "what are you doing", teasing, feeling unwell) the bot picks from replies I wrote in my own voice. The LLM is only the fallback.
  3. A validator checks every LLM reply. It rejects invented activities or places, assistant-style phrases ("is there anything you'd like to chat about"), wrong address words, repeated tokens, and swear words it should never echo. If a reply fails twice, a safe fallback is sent.
  4. Style retrieval is filtered. I mined my own old chats for style examples, but kept only short, harmless pairs. Anything with names, places, swearing, or emotional arguments was removed, so the bot can't repeat private details.
  5. A tuning mode puts 👍/👎 buttons under replies (owner only). Every 👎 is saved locally, so I fix real failures instead of guessing.

Switching from Llama 3.2 3B to Gemma 3 4B made the biggest difference to the Hinglish. With the router, bank and validator on top, the bot's replies went from random and repetitive to short, relevant and in my voice, and replies come back quickly because the whole model fits in my GPU's memory.

Privacy and consent

Her messages and health routine are processed by a model running on my machine, and nothing goes to a cloud AI API. Telegram itself still carries the messages, because bot chats aren't end-to-end encrypted. I told her about the bot before she used it, and the style examples come only from my side of my own chats, with personal content filtered out.

Why Does Open Innovation Matter?

  • Her data stays on my laptop. This is health information plus private conversation. With an open-weight model running locally, I never had to send it to a third-party API or trust someone's retention policy.
  • It costs nothing to run. No API key and no per-message bill, which matters for a bot that sends reminders every day.
  • I could swap models in minutes. Moving from Llama 3.2 3B to Gemma 3 4B was one environment variable (IRONMATE_MODEL) plus one download. That let me compare models on real messages instead of trusting a benchmark.
  • I could change how the agent behaves. Because I controlled the whole loop, I could take tool calling away from the model, add a validator, and filter its examples. A closed API gives you far less control over that.
  • The AI part works offline. After the one-time model download, only Telegram needs internet.

What She Said

When I showed her the bot, she said: "It's fantastic and sounds just like you."

Prize Categories

  • Best Use of Gemma: IronMate runs Gemma 3 4B locally through Ollama and writes all of the bot's free-text replies.

Top comments (0)