feat: migrate to Chat SDK for multi-platform adapter support#13
feat: migrate to Chat SDK for multi-platform adapter support#13farzanshibu wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the project’s chat/webhook integration to the Chat SDK so multiple chat platforms (Sendblue iMessage/SMS/RCS, Telegram, and future adapters like Slack) can share a unified bot + webhook mounting approach.
Changes:
- Replace the custom Sendblue router with a Chat SDK
Chatinstance and env-driven adapter registration (server/bot.ts), plus updated ack-sending integration. - Refactor
server/index.tswebhook handling to mount all registered adapter webhooks and bridge Express requests to Web APIRequest/Response. - Add Telegram webhook auto-registration script and wire it into
npm run dev, plus documentation/env updates for adding new platforms.
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| skills-lock.json | Adds chat-sdk skill source and updates computed hashes for existing skills. |
| server/sendblue.ts | Removes legacy custom Sendblue webhook/router + messaging implementation. |
| server/interaction-agent.ts | Replaces SMS-only ack behavior with a generic onSendAck callback. |
| server/index.ts | Mounts adapter webhooks from webhookPaths and adds an Express↔Web API bridge with logging. |
| server/bot.ts | Introduces Chat SDK bot + adapter registry (Sendblue + Telegram) and unified turn handler. |
| server/automations.ts | Switches automation notifications to posting via Chat SDK (adapter-agnostic). |
| scripts/telegram-webhook.mjs | Adds Telegram webhook registration/clearing helper script. |
| scripts/dev.mjs | Runs both Sendblue + Telegram webhook registration scripts during dev boot. |
| package-lock.json | Adds Chat SDK + adapters and related transitive deps. |
| README.md | Documents “Adding more chat platforms” and lists supported adapters/env vars. |
| .env.example | Adds TELEGRAM_BOT_TOKEN env var documentation. |
| .agents/skills/*/SKILL.md | Updates Convex skill descriptions; adds new chat-sdk skill doc. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile SummaryThis PR migrates the custom Sendblue integration to the Chat SDK, adding Telegram support and an env-driven adapter registry that makes future platform additions (Slack, Discord, etc.) a one-block change. The webhook bridge, raw-body capture for HMAC verification, and startup orchestration are all well-executed. Confidence Score: 5/5Safe to merge; all findings are P2 quality improvements with no blocking bugs on the critical path. No P0 or P1 issues found. The three P2 comments (iMessage-only system prompt, silent header-array drops, Telegram webhook not auto-registered for stable domains) are quality improvements rather than functional regressions. server/interaction-agent.ts — system prompt iMessage framing should be generalized now that multiple platforms are supported. Important Files Changed
Sequence DiagramsequenceDiagram
participant Platform as iMessage / Telegram
participant Express as Express (server/index.ts)
participant Bridge as bridgeWebhook()
participant ChatSDK as Chat SDK (bot.ts)
participant Handler as handleTurn()
participant Agent as interaction-agent.ts
participant Convex as Convex DB
Platform->>Express: POST /sendblue/webhook or /telegram/webhook
Express->>Bridge: rawBody captured via verify()
Bridge->>ChatSDK: new Request(url, {headers, rawBody})
ChatSDK->>ChatSDK: verify HMAC signature
ChatSDK->>Handler: onDirectMessage / onNewMention / onNewMessage
Handler->>Agent: handleUserMessage({conversationId, content})
Agent->>Convex: messages.send (user)
Agent-->>Handler: reply string
Handler->>ChatSDK: thread.post(reply)
Handler->>Convex: messages.send (assistant)
ChatSDK->>Platform: deliver reply
Reviews (3): Last reviewed commit: "Fix: normalize sms: → sendblue: before c..." | Re-trigger Greptile |
Replace custom Sendblue integration with chat-adapter-sendblue and @chat-adapter/telegram, both unified under Chat SDK. All platforms share the same handlers, memory, automations, and Composio tools. - Add server/bot.ts with env-driven adapter registry (registerIfConfigured) - Delete server/sendblue.ts (replaced by chat-adapter-sendblue) - Refactor server/index.ts webhook bridge to forward all headers + debug logs - Add scripts/telegram-webhook.mjs for auto-registration on dev boot - Update scripts/dev.mjs: auto-register Telegram webhook alongside Sendblue - Add README section: "Adding more chat platforms" with Slack walkthrough - Add .agents/skills/chat-sdk/SKILL.md for agent-assisted Chat SDK work Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Capture raw request body via express.json verify callback so HMAC signature verification works for Slack, GitHub, Discord, etc. - Proxy adapter responses faithfully (status + headers + raw bytes) instead of forcing JSON — fixes URL verification challenge flows - Fix double-handler: scope onNewMessage catch-all to sendblue only; all other platforms use onDirectMessage to avoid firing twice on @-mentions - Gate webhook body logging behind DEBUG_WEBHOOKS=true env var to avoid PII in production logs - Surface webhook registration failures explicitly in autoRegisterWebhook - Update dev banner to list all active platform webhooks dynamically instead of hardcoding Sendblue-only messaging Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
bdabdf9 to
e82c46b
Compare
Closes #14
Summary
server/sendblue.tswithchat-adapter-sendblueand@chat-adapter/telegramunified under Chat SDKserver/bot.tswith env-driven adapter registry — new platforms (Slack, WhatsApp, Discord, etc.) are oneregisterIfConfigured()callserver/index.tsto forward all request headers and add debug logging ([webhook:name] incoming POST body=...)scripts/telegram-webhook.mjsfor auto-registration of Telegram webhook on dev bootTest plan
npm run devboots with bothsendblueandtelegramadapters registered[webhook:sendblue] incoming POSTlog →[turn ...]log → reply sentregisterIfConfigured()blockSENDBLUE_AUTO_WEBHOOK=falsedisables Sendblue webhook auto-registration🤖 Generated with Claude Code