Owner notification webhook (Telegram re-point) #23

Closed
opened 2026-07-23 14:07:59 +02:00 by mivanchenko · 1 comment
Owner

Parent

#14

What to build

Owner notification on new/changed bookings, reusing the existing Telegram-send logic instead of
reimplementing it — just re-pointed at the new booking module instead of Easy!Appointments.

  • The Flask app fires an internal webhook call on booking create/confirm/cancel/reschedule (same
    payload shape as today's n8n/booking-sync.json → Telegram-send step expects).
  • n8n/booking-sync.json's Telegram-notify portion is re-pointed at this new internal webhook
    (the EA-specific lookup/transform steps upstream of it are no longer needed and are removed or
    bypassed).
  • clients.notify_channel selects the channel; only telegram sends anything real at launch
    (other values are accepted but no-op, ready for a future channel).

Acceptance criteria

  • Creating a booking (via any path — public page, manual owner entry) triggers a Telegram
    message to the owning client's configured Telegram chat, with the same information content
    as today's EA-sourced notification (business, customer, service, time, contact, source).
  • Cancelling/rescheduling a booking also triggers an appropriate notification.
  • A client with notify_channel set to anything other than telegram receives no notification
    (rather than erroring).
  • n8n/booking-sync.json no longer depends on Easy!Appointments' API to build the notification
    payload.

Blocked by

  • #16 (Availability engine + booking API)
## Parent #14 ## What to build Owner notification on new/changed bookings, reusing the existing Telegram-send logic instead of reimplementing it — just re-pointed at the new booking module instead of Easy!Appointments. - The Flask app fires an internal webhook call on booking create/confirm/cancel/reschedule (same payload shape as today's `n8n/booking-sync.json` → Telegram-send step expects). - `n8n/booking-sync.json`'s Telegram-notify portion is re-pointed at this new internal webhook (the EA-specific lookup/transform steps upstream of it are no longer needed and are removed or bypassed). - `clients.notify_channel` selects the channel; only `telegram` sends anything real at launch (other values are accepted but no-op, ready for a future channel). ## Acceptance criteria - [ ] Creating a booking (via any path — public page, manual owner entry) triggers a Telegram message to the owning client's configured Telegram chat, with the same information content as today's EA-sourced notification (business, customer, service, time, contact, source). - [ ] Cancelling/rescheduling a booking also triggers an appropriate notification. - [ ] A client with `notify_channel` set to anything other than `telegram` receives no notification (rather than erroring). - [ ] `n8n/booking-sync.json` no longer depends on Easy!Appointments' API to build the notification payload. ## Blocked by - #16 (Availability engine + booking API)
mivanchenko added the ready-for-agentenhancementbooking labels 2026-07-23 14:07:59 +02:00
mivanchenko added a new dependency 2026-07-23 14:09:19 +02:00
Author
Owner

Implemented in a27ee59.

  • backoffice/app/owner_notify.py: fire-and-forget webhook POST (mirrors mailer.py's background-thread-queue pattern), firing on booking create/cancel/reschedule via booking_api.py's three shared mutation helpers (so every caller -- public API, customer token-based cancel/reschedule, owner manual entry -- is covered).
  • Payload shape matches the old Build booking row node's {booking, business_name, notify_channel}, plus an event field (created/cancelled/rescheduled) so the Telegram message text can say what happened instead of always "new booking".
  • n8n/booking-sync.json: new Owner notify webhook node feeds a Telegram channel? IF node (gates on notify_channel === 'telegram', no-op otherwise) straight into the existing Notify owner (Telegram) node, now reading fields from the webhook body directly instead of through the EA-lookup-driven Build booking row node. The old EA-sourced path (Booking webhook -> Build booking row -> Save to CRM) is untouched for CRM sync, but its link into Telegram is removed -- Telegram notify no longer depends on EA's API.
  • OWNER_NOTIFY_WEBHOOK_URL env var added (blank = skip, same convention as SMTP_HOST).
  • Tests: test_owner_notify.py (unit, webhook-call shape) + three new integration tests in test_booking_api.py asserting create/cancel/reschedule each call owner_notify.notify with the right event. Full suite (138 tests) passes.

Note: the Telegram chatId stays a single hardcoded value shared across all clients (pre-existing, not scoped by this ticket) -- per-client chat routing would need a schema addition and wasn't asked for here; the business name in the message text is what currently distinguishes which client a booking belongs to.

Implemented in a27ee59. - `backoffice/app/owner_notify.py`: fire-and-forget webhook POST (mirrors `mailer.py`'s background-thread-queue pattern), firing on booking create/cancel/reschedule via `booking_api.py`'s three shared mutation helpers (so every caller -- public API, customer token-based cancel/reschedule, owner manual entry -- is covered). - Payload shape matches the old `Build booking row` node's `{booking, business_name, notify_channel}`, plus an `event` field (`created`/`cancelled`/`rescheduled`) so the Telegram message text can say what happened instead of always "new booking". - `n8n/booking-sync.json`: new `Owner notify webhook` node feeds a `Telegram channel?` IF node (gates on `notify_channel === 'telegram'`, no-op otherwise) straight into the existing `Notify owner (Telegram)` node, now reading fields from the webhook body directly instead of through the EA-lookup-driven `Build booking row` node. The old EA-sourced path (`Booking webhook` -> `Build booking row` -> `Save to CRM`) is untouched for CRM sync, but its link into Telegram is removed -- Telegram notify no longer depends on EA's API. - `OWNER_NOTIFY_WEBHOOK_URL` env var added (blank = skip, same convention as `SMTP_HOST`). - Tests: `test_owner_notify.py` (unit, webhook-call shape) + three new integration tests in `test_booking_api.py` asserting create/cancel/reschedule each call `owner_notify.notify` with the right event. Full suite (138 tests) passes. Note: the Telegram `chatId` stays a single hardcoded value shared across all clients (pre-existing, not scoped by this ticket) -- per-client chat routing would need a schema addition and wasn't asked for here; the business name in the message text is what currently distinguishes which client a booking belongs to.
Sign in to join this conversation.