Webhooks: post each new incoming message #7

Open
opened 2026-09-28 11:10:25 +02:00 by clawbot · 0 comments

Part of #2. Builds on #6 and starts from next once that is merged.

What. Every new incoming message in a chat is POSTed as JSON to each of that chat's webhooks.

Decisions (reversible, taken by the repo-manager):

  • On each newChatItems event, every received message in a direct chat (what the messages endpoint reports as "direction":"received") goes to each webhook registered on that chat: POST, Content-Type: application/json, body {"chat_id":{id},"message":{...}} with the same message record as the messages endpoint.
  • Delivery never blocks the event handler, which also delivers command responses: deliveries go to a bounded queue served by a fixed number of goroutines, and when the queue is full the delivery is dropped and logged. One attempt, a 10-second timeout; a failure or a non-2xx status is logged with the webhook id, not the URL, which may carry a secret. It stops cleanly when bot.Run returns.
  • The calculator keeps replying as before.

Done when:

  • Tests: a message event produces the documented POST to each of that chat's webhooks and to none of another chat's; a slow or failing webhook does not delay the bot's replies; a full queue drops rather than blocks.
  • Checked end to end against the real simplex-chat v7.0.2 in the image: a second throwaway client sends a message and a local receiver gets the POST. Name every container and volume you create after this issue, never touch simplexcalc or simplexcalc-data, and remove what you created.
  • README: the payload with an example, and what delivery promises (at most once, no retries). docs/TODO.md Completed Steps gets a line.
  • make check is green.

Model: opus-5-5

Part of https://git.eeqj.de/sneak/simplexcalc/issues/2. Builds on https://git.eeqj.de/sneak/simplexcalc/issues/6 and starts from `next` once that is merged. **What.** Every new incoming message in a chat is POSTed as JSON to each of that chat's webhooks. **Decisions** (reversible, taken by the repo-manager): - On each `newChatItems` event, every received message in a direct chat (what the messages endpoint reports as `"direction":"received"`) goes to each webhook registered on that chat: `POST`, `Content-Type: application/json`, body `{"chat_id":{id},"message":{...}}` with the same message record as the messages endpoint. - Delivery never blocks the event handler, which also delivers command responses: deliveries go to a bounded queue served by a fixed number of goroutines, and when the queue is full the delivery is dropped and logged. One attempt, a 10-second timeout; a failure or a non-2xx status is logged with the webhook id, not the URL, which may carry a secret. It stops cleanly when `bot.Run` returns. - The calculator keeps replying as before. **Done when:** - Tests: a message event produces the documented POST to each of that chat's webhooks and to none of another chat's; a slow or failing webhook does not delay the bot's replies; a full queue drops rather than blocks. - Checked end to end against the real `simplex-chat` v7.0.2 in the image: a second throwaway client sends a message and a local receiver gets the POST. Name every container and volume you create after this issue, never touch `simplexcalc` or `simplexcalc-data`, and remove what you created. - README: the payload with an example, and what delivery promises (at most once, no retries). `docs/TODO.md` Completed Steps gets a line. - `make check` is green. Model: opus-5-5
clawbot added a new dependency 2026-09-28 11:10:29 +02:00
clawbot self-assigned this 2026-09-28 11:10:30 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sneak/simplexcalc#7