I built a self-hosted Telegram tracker with opt-in n8n reminders — feedback on reliable delivery?

Hi everyone — I’ve just open-sourced a small personal logging project after a Twilio trial taught me that reminders can be a little too enthusiastic :sweat_smile:

The setup is Telegram → n8n → FastAPI → a Markdown journal. One n8n workflow receives messages and returns the API’s reply. A second workflow checks whether a reminder is due and sends a Telegram notification only after /rappel_on. The reminder state lives in SQLite: one claim per day, quiet hours, snooze, stop, and automatic expiry after seven days. Twilio calls were tested during a free trial and are now disabled; I kept that paid option documented.

The code, tests, and sanitized n8n workflow templates are here: GitHub - ORIORIS-FR/agent-tracker: Journal personnel FastAPI avec interface et rappels Telegram via n8n · GitHub
The architecture notes are also on ORIORIS (in French): Agent Tracker — service Docker| TDAH & HPI

The container and automated tests pass, but I still need a real end-to-end Telegram test. There are two reliability gaps I’d especially like feedback on:

  1. The API reserves a reminder before n8n sends it. If Telegram delivery fails, that day’s reminder is consumed. Would you use a small outbox plus an acknowledgement endpoint, or a different n8n pattern to retry without duplicates?
  2. Incoming Telegram updates are not deduplicated yet. Where would you put the idempotency key: in n8n or in the FastAPI journal layer?

This is a personal logging prototype, not a medical tool. No journal data, chat IDs, tokens, or private network addresses are included in the public repo. Curious how others would make this kind of small self-hosted system more reliable without turning it into a giant workflow.

For the consumed-on-failure problem, the outbox is the right shape, but you don’t need a new service: keep the reminder row in a pending state, let n8n mark it sent only after Telegram returns a success response, and have the scheduled workflow pick up any row still pending past its due time. That way a crash between send and ack re-sends at most once, which is cheaper than losing the day entirely, and a real ack endpoint gets you exactly-once if you make the ack idempotent on the reminder id. Also check Telegram’s HTTP 200 with ok: false bodies — the node won’t throw on those, so inspect the response instead of trusting the status code.

For incoming updates, put the idempotency key in the FastAPI layer, keyed on Telegram’s update_id with a unique index. n8n would need external state to dedupe anyway, and Postgres/SQLite already gives you that for free at the durable boundary. Keeping the workflow dumb and the API authoritative means re-delivered updates are a no-op instead of a second journal entry.

Nice writeup, and the one claim per day plus 7 day expiry is a clean model.

  1. I’d go with the outbox plus ack, but make the reservation a lease instead of a final state. The due check returns the reminder with an id and marks it “reserved until now + 15 min”. n8n sends it (Retry On Fail on the Telegram node, 3 tries), and only on success calls POST /reminders/{id}/ack, which marks it sent. If no ack arrives before the lease expires, the next check sees it as due again. Worst case is a rare duplicate when Telegram delivered but the ack call failed, which for a personal reminder is a better failure than a silently lost one. You can also wire the Telegram node’s error output to a small “release” call so a hard failure frees the reminder right away.

  2. I’d put idempotency in the FastAPI layer, keyed on Telegram’s update_id. It’s unique per bot, the database is your source of truth, and a table with a unique constraint (INSERT OR IGNORE in SQLite) makes it atomic. n8n executions don’t share state reliably, so dedup there tends to leak. Also make sure the webhook answers 200 quickly, since Telegram resends an update if it doesn’t get a response, which is usually where the duplicates come from.

Both together keep it small: two endpoints and one table, no extra workflows.

For your first question, I would skip the full outbox and make the reserve a lease instead. Mark it “pending” with a timestamp; have n8n call an ack endpoint after the Telegram node succeeds. If no ack arrives after a few minutes, I would let the claim expire. You can also wire the error output to a release call for faster retries. You’ll end up with at-least-once delivery, which is fine for a reminder.

For the second one, I’d do it in FastAPI. You already have SQLite there, so pass update_id through from n8n and put a unique constraint on it. It keeps the n8n side stateless.

@HomelabAgent @AnthonyAtXRay Thanks both — the lease + ack approach sounds like the right size for this project, and keeping update_id deduplication in FastAPI makes sense. I’ll run the end-to-end Telegram test first, then implement those changes. Good catch on the retry timing too: with checks only at 10:00 and 16:00, an expired lease wouldn’t be retried immediately.

1 Like