Bento House

4. Signal chat bot

GuideUpdated Nov 213 min read

On this page
  1. How it works
  2. Decisions (these matter)
  3. Prompt for Claude Code
  4. Checks

You get: text yourself on Signal ("Note to Self") and the message becomes a task, a shopping item or a note. Replies confirm what happened, and "undo" takes it back.

This is the part that makes the system something you actually use. It's also where most of the care goes.

How it works

  • signal-cli-rest-api runs in a container. It's linked to your own Signal account as an extra device, the same way Signal Desktop is, by scanning a QR code from your phone.
  • The app keeps a connection open to it, receives each new Note to Self message, decides what it is, acts, and replies.
  • Each household member can link their own account the same way.

Decisions (these matter)

  • Clear messages are handled by simple rules first. "buy milk", "task: call dentist", "shopping: eggs" never need AI. Rules only claim messages they're sure about.
  • AI sorts the rest. Anything the rules don't claim goes to a small, cheap AI call that returns a choice (task, shopping, note, question) and the cleaned-up text. Validate what comes back; if it's malformed, ask the user.
  • Confirm what AI interpreted. If the AI changed the wording, the reply shows what was saved, so mistakes are visible.
  • Undo is per message. Every action records which message caused it. Replying "undo" to that message (Signal's reply feature) undoes exactly that, even hours later. Plain "undo" undoes the latest.
  • Fix in place. Replying "actually: call the dentist Tuesday" to a message changes the saved item rather than making a new one.
  • Typo guard. One-word messages that look like a slip ("k", "ok", a single letter) are ignored, not saved.
  • Ask, don't guess. When it's unsure, it asks "Task or shopping?" and waits. Pending questions expire after a while.
  • Log every decision. One line per message: which handler claimed it and what it did. Never log the message text itself, only its shape (length, which rule matched).

Prompt for Claude Code

Add a Signal capture bot. Add the bbernhard/signal-cli-rest-api container to
docker-compose.yml in json-rpc mode, data in a volume, port bound to 127.0.0.1 only.
Give me the steps to link it to my Signal account as a secondary device (QR code).

In the app, open a websocket to the container's receive endpoint, and handle only
"Note to Self" messages from the linked accounts listed in SIGNAL_ACCOUNTS (.env).
Reconnect with backoff if the connection drops, and alert me (Signal message) if it
stays down for 10 minutes.

Routing, in order:
1. Rule handlers for clear prefixes and patterns: "task:", "shopping:" / "buy X",
   "note:". Each rule only claims messages it is sure about.
2. A typo guard that ignores single-word slips like "k", "ok", "?".
3. An AI router (Anthropic API, a small model) for everything else. It returns JSON
   {kind: task|shopping|note|question, text}, validated with zod. On any error or bad
   output, ask "Task, shopping or note?" instead of guessing; the question expires
   after 30 minutes.

Record every created item in a signal_actions table with the source message timestamp.
Support "undo" as a reply to a specific message (undo that one), plain "undo" (latest),
and "actually: ..." as a reply (edit that item in place). Reply to every capture with
what was saved, and show the AI's wording when it changed mine.

Log one line per message: handler, outcome, item id. Never log message text.
Add a test script that feeds fake messages through the real routing with nothing sent.

Checks

  • "buy milk" → reply "Added to shopping: milk", and it's on the dashboard.
  • "remind me to renew the car registration" → becomes a task (AI path); the reply shows the wording.
  • Reply "undo" to the first message → milk disappears; the reply says so.
  • "k" → nothing happens.
  • Stop the Signal container for a minute and start it again: the next message still works.