Add a Generic Webhook / HTTP Adapter for Arbitrary Chat Platforms

オープン
#96 コメント 1 件 リアクション 18 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@roboeve がすでに取り組んでいます。

2026年10月12日 から。

  • #1033 @roboeve による — オープン

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
typescript
領域
api, backend

調査の方向性

提案されている Chat 設定と createGenericAdapter エントリポイントから始め、SDK が現在、受信イベントをどのように表現し、レスポンスをどのように送信しているかを確認します。アダプターの範囲を、Webhook ペイロードのマッピング、任意の検証とフィルタリング、開発者が提供する送信 HTTP の動作を中心に定義します。完了とは、文書化された汎用アダプターが、プラットフォーム固有のパースなしに、HTTP に対応する任意のプラットフォームをサポートできる状態を意味します。

索引モデルが issue の本文から書いたものです。

説明

enhancement
Problem Statement

Many popular or emerging messaging channels do not yet have dedicated adapters in the SDK. Like -

  1. WhatsApp (via open-source HTTP bridges such as WAHA or Beeper)
  2. Meta Ray-Ban smart glasses (which surface conversations through Meta/WhatsApp channels)
  3. Telegram (via its webhook-capable Bot API)
  4. Matrix / Element
  5. Various self-hosted, enterprise, or niche messengers
  6. Any future or custom platform that supports inbound HTTP webhooks and can receive responses via HTTP POST

Without a generic mechanism, supporting these platforms requires either waiting for official adapter packages or forking/maintaining custom platform-specific integrations — which undermines the "write once, run anywhere" value proposition of the SDK.

Proposed Solution

Introduce a built-in generic webhook / HTTP adapter (or a lightweight "raw HTTP" adapter) in the core Chat SDK or as a first-party package (e.g., @chat-adapter/webhook or @chat-adapter/generic).
This adapter would allow developers to connect the same bot logic to any HTTP-capable platform by defining:

  1. How incoming HTTP payloads are parsed and mapped to Chat SDK events (e.g., extracting message text, sender ID, channel/thread info)
  2. How outgoing Chat SDK responses are transformed and sent back (e.g., via HTTP POST, specific JSON shape, headers, etc.)
Alternatives Considered

No response

Use Case
import { Chat } from "chat";
import { createGenericAdapter } from "@chat-adapter/generic";  // or built-in

const bot = new Chat({
  userName: "mybot",
  adapters: {
    custom: createGenericAdapter({
      // Core webhook handling
      path: "/webhook/my-platform",               // Vercel / server route
      verification: {
        secret: process.env.WEBHOOK_SECRET,       // optional HMAC / token check
      },

      // Required mappings (examples)
      incoming: {
        getText: (payload) => payload?.message?.text || payload?.body,
        getSenderId: (payload) => payload?.from?.id || payload?.sender,
        getChannelId: (payload) => payload?.thread?.id || payload?.chatId,
        // Optional: getMessageId, isFromBot, etc.
      },

      outgoing: async (channelId, content, options) => {
        // Developer provides the send logic (fetch/axios/etc.)
        await fetch("https://api.platform.com/messages", {
          method: "POST",
          headers: { Authorization: `Bearer ${process.env.PLATFORM_TOKEN}` },
          body: JSON.stringify({
            chat_id: channelId,
            text: content.text,
            // ... platform-specific fields
          }),
        });
      },

      // Optional extras
      platformName: "WhatsApp",                     // for logs/metrics
      shouldHandle: (req) => req.headers["user-agent"]?.includes("WhatsApp"), // filter
    }),
  },
  // ... other config (state, model, etc.)
});
Priority

Nice to have

Contribution
  • I am willing to help implement this feature
Additional Context

No response

主要言語
TypeScript
スター
2.5k
フォーク
355
平均マージ
2日 15時間
マージ済み PR(30日)
42

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

vercel/chat のほかの issue

vercel/chat の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。