WhatsApp终端桥接服务

Pons是一款将WhatsApp Business Cloud API桥接到任何MCP兼容客户端的服务,支持通过AI助手、开发环境或自动化工具发送和接收WhatsApp消息。

  • by NicolaiSchmid
  • TypeScript
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 NicolaiSchmid/pons

使用说明


 ┌─────────────────────────────────────────┐
 │                                         │
 │   ██████╗  ██████╗ ███╗   ██╗███████╗   │
 │   ██╔══██╗██╔═══██╗████╗  ██║██╔════╝   │
 │   ██████╔╝██║   ██║██╔██╗ ██║███████╗   │
 │   ██╔═══╝ ██║   ██║██║╚██╗██║╚════██║   │
 │   ██║     ╚██████╔╝██║ ╚████║███████║   │
 │   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝╚══════╝   │
 │                                         │
 └─────────────────────────────────────────┘

WhatsApp在你的终端。AI中的消息。

将WhatsApp Business Cloud API桥接到任何兼容MCP的客户端。
发送和接收来自Claude、Cursor或您自己的工具的消息。

pons.chat · 文档 · 报告Bug · 请求功能



问题

WhatsApp Business拥有强大的API,但它被锁定在REST调用、webhook管道和令牌管理之后。无法将其插入您实际使用的工具中——人工智能助手、开发环境、自动化管道。

脑桥 (拉丁语为“桥”)将WhatsApp连接到 模型上下文协议,这样你的人工智能助手就可以像阅读文件或搜索网络一样自然地阅读、搜索和发送WhatsApp消息。

它的作用

  • 完整的WhatsApp收件箱 --带有对话、媒体、收货收据的实时web UI
  • MCP服务器 --将WhatsApp作为Claude Desktop、Cursor或任何MCP客户端的工具公开
  • 多用户 --多个WhatsApp商业帐户,每个帐户有多个用户
  • 介质处理 --图像、视频、文档自动下载到Converx存储(元URL将在5分钟后过期)
  • 24小时窗口跟踪 --知道什么时候可以发送自由格式的消息,而不是只发送模板的消息
  • API密钥管理 --过期的不同客户端的作用域密钥

技术栈

图层 选择
框架 Next.js 16 (应用路由器、Turbopack)
后端 凸 (数据库、身份验证、文件存储、计划操作)
认证 凸认证 (谷歌OAuth)
MCP @modelcontextprotocol/sdk --可流式HTTP传输
UI shadcn/ui +顺风CSS v4
域名 pons.chat
托管服务 维塞尔 (FRA1)+ 凸云 (eu-west-1)

快速开始

先决条件

1.安装和配置

git clone https://github.com/NicolaiSchmid/pons.git
cd pons
pnpm install

# Start Convex dev (opens browser for auth on first run)
npx convex dev

# In another terminal
pnpm run dev:next

2.连接WhatsApp

  1. 创建元商业应用程序→ 添加WhatsApp产品→ 获取测试电话号码
  2. 登录Pons http://localhost:3000
  3. 使用您的WABA ID、电话号码ID、访问令牌和应用程序密钥创建帐户
  4. 在Meta中将webhook URL设置为 https://your-domain.com/api/webhook
  5. 使用生成的Webhook验证令牌进行验证

3.连接你的AI

首选 API密钥 在仪表板中,创建一个键,并将其添加到MCP配置中:

{
  "mcpServers": {
    "pons": {
      "url": "https://your-pons-domain.com/api/mcp",
      "headers": {
        "Authorization": "Bearer pons_your_api_key_here"
      }
    }
  }
}

MCP工具

工具 范围 描述
list_conversations read 列出最近的对话并预览
get_conversation 阅读 通过消息进行完整对话
search_messages 阅读 按内容搜索邮件
send_text send 发送短信
send_template send 发送模板消息(适用于已关闭的窗口)
list_templates read 列出可用的消息模板
mark_as_read 写 将对话标记为已读
send_reaction 写 用表情符号回复消息

范围: read (视图), write (标记读取、反应), send (发送消息)。按密钥分配。

建筑

┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│              │     │              │     │              │
│  Claude /    │────▶│  Pons MCP    │────▶│   Convex     │
│  Cursor      │ MCP │  Endpoint    │     │   Backend    │
│              │     │  (Next.js)   │     │              │
└──────────────┘     └──────┬───────┘     └──────┬───────┘
                            │                    │
                     ┌──────┴───────┐     ┌──────┴───────┐
                     │              │     │              │
                     │  Pons Web    │     │  Meta Graph  │
                     │  Dashboard   │     │  API v22.0   │
                     │              │     │              │
                     └──────────────┘     └──────────────┘

数据模型

Account (WhatsApp Business Account)
├── AccountMember (owner / admin / member)
├── Contact (customer phone numbers)
│   └── Conversation (thread with a contact)
│       └── Message (text, media, location, reaction...)
├── Template (pre-approved message templates)
├── ApiKey (scoped MCP authentication)
└── WebhookLog (raw payloads for debugging)

项目结构

pons/
├── convex/                 # Backend
│   ├── schema.ts           # Database schema
│   ├── auth.ts             # Convex Auth (Google OAuth)
│   ├── accounts.ts         # Account + member management
│   ├── conversations.ts    # Conversation queries
│   ├── messages.ts         # Message CRUD
│   ├── mcp.ts              # MCP queries + API key management
│   ├── mcpNode.ts          # Crypto operations (Node.js runtime)
│   ├── webhook.ts          # Webhook ingestion + media download
│   └── whatsapp.ts         # Meta Graph API actions
├── src/
│   ├── app/
│   │   ├── api/mcp/        # MCP HTTP endpoint
│   │   ├── api/webhook/    # WhatsApp webhook handler
│   │   └── page.tsx        # Landing + auth gate
│   ├── components/
│   │   ├── Dashboard.tsx           # Main shell
│   │   ├── ConversationList.tsx    # Sidebar
│   │   ├── MessageThread.tsx       # Chat view
│   │   ├── AccountSettings.tsx     # Settings + member management
│   │   ├── ApiKeyManager.tsx       # API key CRUD
│   │   ├── AccountSelector.tsx     # Account switcher
│   │   └── SetupAccount.tsx        # Onboarding
│   └── components/ui/      # shadcn/ui primitives
├── middleware.ts            # Auth middleware (webhook excluded)
└── vercel.json             # Vercel config (FRA1 region)

发展

pnpm dev              # Convex + Next.js in parallel
pnpm run check:write  # Biome lint + format (auto-fix)
pnpm run typecheck    # TypeScript check
pnpm run build        # Production build

部署

  1. 将GitHub仓库连接到 维塞尔
  2. 设置环境变量: NEXT_PUBLIC_CONVEX_URL, CONVEX_DEPLOY_KEY
  3. 构建命令已预先配置: pnpm convex deploy --cmd 'pnpm run build'
  4. 禁用生产环境的Vercel部署保护(webhook需要未经身份验证的访问)

许可证

麻省理工学院


由...建造 Nicolaischmid.com