Skip to content

feat(P1): TG/WA/FB webhooks + big homepage refresh + setup runbook - #3

Open
IMPTio wants to merge 1 commit into
feat/p0-5-mongo-stripe-wirefrom
feat/p1-bots-and-site
Open

feat(P1): TG/WA/FB webhooks + big homepage refresh + setup runbook#3
IMPTio wants to merge 1 commit into
feat/p0-5-mongo-stripe-wirefrom
feat/p1-bots-and-site

Conversation

@IMPTio

@IMPTio IMPTio commented May 9, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Stacked on PR #2 (base = feat/p0-5-mongo-stripe-wire). When PRs #1 and #2 merge, GitHub auto-rebases this onto main.

Summary

Three bots + a real homepage. Telegram is fully wired with the existing token — Mike can test today by chatting with @Rambo_Marc2_bot once the webhook is set. WhatsApp + Facebook handlers are schema-correct receivers ready for Mike's Meta-side provisioning.

The homepage at swarm.impt.io/ is now a serious sales page showing every channel with status, a live embedded widget demo, the Goodness mechanic, comparison vs Booking/Expedia, and a real partner sign-up form.

What Mike can test today (after merge + CF Pages connect + 1 curl)

Channel Test
Web Visit swarm.impt.io/ → pick a city in the embedded widget → land on app.impt.io/find-hotel-input
Telegram After setWebhook curl in ops/SETUP.md step 4: chat @Rambo_Marc2_bot/start → city buttons → tap → booking link in chat
WhatsApp Visit swarm.impt.io/wa → wa.me opens prefilled "Book Dublin" → bot reply lands once Meta provisions the WA Business number
Facebook Visit swarm.impt.io/fb → m.me opens IMPT page → page reply lands once Mike adds the IMPT FB Page to the Messenger Platform app

Files

Telegram (full impl)

  • apps/site/functions/api/tg/webhook.ts/start [city], /book <city>, plain-text city, callback queries
  • apps/site/functions/_lib/telegram.ts — fetch-only Bot API helpers
  • KV-persisted Intent for every booking click (channel=tg)
  • secret_token header verification

WhatsApp Cloud API (schema-correct, inert until Meta provisioning)

  • apps/site/functions/api/whatsapp/webhook.ts — GET verify + POST handler
  • Replies via Meta's cta_url interactive type
  • 200-acks when unprovisioned (no retry storms)

Facebook Messenger (same)

  • apps/site/functions/api/fb/webhook.ts — GET verify + POST handler
  • Generic template card with web_url + postback buttons
  • Quick-reply city picker

Homepage refresh — apps/site/public/index.html

  • 6-stat hero · live demo embed · 36 channels with status pills · 4-step flow · Goodness panel · comparison table · real signup form · footer with GitHub/OpenAPI/agent.json
  • /widget → / 301 to keep legacy partner inbound links working

Setup runbook — ops/SETUP.md

Exact commands for: CF Pages connect, KV bindings, env vars, Telegram webhook, WA/FB Meta dev portal, mgmt-server crontab.

Workflows status

Still in ops/workflows/ not .github/workflows/. Pushing to .github/workflows/ requires workflow OAuth scope; refresh is interactive-only. Workaround documented in ops/SETUP.md: monitor + Mongo sync run on the mgmt server cron (same pattern as brain-tick). Workflows in ops/workflows/ are pasteable via the web UI any time.

Stack

main
 └─ feat/p0-omnichannel-spine                (PR #1 — spine)
     └─ feat/p0-5-mongo-stripe-wire          (PR #2 — real /hotels /intent /partners)
         └─ feat/p1-bots-and-site            (PR #3 — TG/WA/FB + homepage)

🤖 Generated with Claude Code

Three bots + a serious homepage so Mike can test what he asked for.
TG bot is fully wired with the existing TELEGRAM_BOT_TOKEN — chat with
@Rambo_Marc2_bot once the webhook is set. WA + FB schemas are correct
and inert until Mike provisions Meta Business numbers.

Telegram (FULL — testable today)
- apps/site/functions/api/tg/webhook.ts
- /start [city] → city picker (12 quick-pick buttons in 3-col grid) or pre-filled CTA
- /book <city> + /city <city> → CTA reply with one-tap booking URL button
- plain text "Dublin" → CTA reply (any city, even unknown — passes through to find-hotel-input)
- callback_query handler for button taps
- secret_token verification (TG_WEBHOOK_SECRET in CF env)
- Persists Intent to KV INTENTS with channel='tg' for attribution
- apps/site/functions/_lib/telegram.ts — fetch-only Bot API helpers (no SDK)

WhatsApp (schema-correct, awaiting Meta provisioning)
- apps/site/functions/api/whatsapp/webhook.ts
- GET — Meta verification challenge (hub.mode/hub.verify_token/hub.challenge)
- POST — text + interactive (button_reply/list_reply) handler
- Replies via cta_url interactive type — Meta's preferred CTA pattern
- Persists Intent with channel='wa'
- 200-acks unprovisioned to avoid Meta retry-storms

Facebook Messenger (schema-correct, awaiting Page wiring)
- apps/site/functions/api/fb/webhook.ts
- GET — Meta verification challenge
- POST — quick_reply + postback + plain text handlers
- Replies via generic template (title/subtitle/buttons) — m.me-compatible
- Persists Intent with channel='fb'
- /fb landing CTA points to m.me/imptio (env-overrideable)

Homepage refresh at /
- 6-stat hero (36 channels · 5% · 90d · 8.7KB · €0 · 60s)
- Live demo widget embedded inline (data-key=demo-home, dest=Dublin)
- All 36 channels in 6 tiered grids with status pills (Live/P1/P2/P3/P4/P5)
- 4-step "How it works" flow visualisation
- Dark Goodness panel with 5 numbers (5%/€5/3%/2%/1t)
- Comparison table vs Booking/Expedia
- Real partner sign-up form POSTing to /api/partners/signup
- Footer with GitHub + OpenAPI + agent.json deeplinks
- /widget → / 301 (legacy partner inbound links)

ops/SETUP.md — one-shot commands Mike runs after merge
- Step 1: CF Pages "Connect to Git" UI (5 min)
- Step 2: wrangler kv:namespace create × 3 + paste IDs into wrangler.toml
- Step 3: 13 env vars listed + source from vercel-env-backup
- Step 4: ONE curl to set Telegram webhook + paste secret into env
- Step 5: WA + FB webhook URLs in Meta dev portal
- Step 6: Mongo sync + uptime monitor crontab on mgmt server
- Step 7: explicit test checklist for TG/WA/FB

Why workflows still aren't in .github/workflows/
gh OAuth token lacks `workflow` scope. Refresh requires interactive browser.
Resolution: monitor + sync crons run on mgmt server (already has direct Mongo +
CF API access — same pattern as brain-tick). Workflows in ops/workflows/ are
templates Mike can paste via the GitHub web UI any time.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant