@agentphone/chat-sdk-adapter

中文文档
0.1.0发布于 2026/05/29MITTypeScriptES Module近 30 天下载 5.9万

AgentPhone adapter for Chat SDK — SMS, MMS, iMessage, and voice

原始使用文档
文档目录8 节
  1. Features
  2. Install
  3. Quick start
  4. Configuration
  5. Webhook events
  6. Webhook verification
  7. iMessage reactions
  8. Links

@agentphone/chat-sdk-adapter

AgentPhone adapter for Chat SDK — the first adapter with SMS, MMS, iMessage, and voice call support.

Features

FeatureSMSMMSiMessageVoice
Send messagesYesYesYes—
Receive messagesYesYesYes—
Media attachments—YesYes—
Reactions——Yes—
Call transcripts———Yes
Call summaries———Yes

Install

npm install @agentphone/chat-sdk-adapter chat

Quick start

import { Chat } from "chat";
import { createAgentPhoneAdapter } from "@agentphone/chat-sdk-adapter";

const chat = new Chat({
  adapter: createAgentPhoneAdapter({
    apiKey: process.env.AGENTPHONE_API_KEY,
    agentId: process.env.AGENTPHONE_AGENT_ID,
    webhookSecret: process.env.AGENTPHONE_WEBHOOK_SECRET,
  }),

  onNewMention: async ({ message, reply }) => {
    // Handles SMS, MMS, iMessage, and voice call transcripts
    await reply(`Got your message: ${message.text}`);
  },
});

// In your HTTP server (Express, Hono, Next.js, etc.)
app.post("/webhook/agentphone", (req) => chat.webhooks.agentphone(req));

Configuration

OptionEnv varRequiredDescription
apiKeyAGENTPHONE_API_KEYYesYour AgentPhone API key
agentIdAGENTPHONE_AGENT_IDYesAgent ID to send messages from
webhookSecretAGENTPHONE_WEBHOOK_SECRETNoHMAC-SHA256 webhook signing secret
apiUrl—NoAPI base URL (default: https://api.agentphone.ai)
userNameBOT_USERNAMENoBot display name (default: "bot")

Webhook events

The adapter handles three webhook event types from AgentPhone:

  • agent.message — Inbound SMS, MMS, or iMessage. Routed to onNewMention.
  • agent.call_ended — Voice call completed with full transcript and summary. Routed to onNewMention as a message containing the transcript.
  • agent.reaction — iMessage tapback reaction (love, like, laugh, etc.). Routed to onReaction.

Webhook verification

All AgentPhone webhooks are signed with HMAC-SHA256. Set webhookSecret to enable verification. The adapter checks:

  1. X-Webhook-Signature header matches the HMAC of {timestamp}.{body}
  2. X-Webhook-Timestamp is within 5 minutes (replay protection)

iMessage reactions

AgentPhone is the only Chat SDK adapter that supports iMessage reactions:

// Send a tapback reaction
await adapter.addReaction(threadId, messageId, "love");
// Supported: love, like, dislike, laugh, emphasize, question
// Custom emoji also supported on newer devices: "🔥", "😂", etc.

版本与发布记录

@agentphone/chat-sdk-adapter 共发布 1 个版本,首次发布于 2026/05/29;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.1.0latest2026/05/295 个月前

关于 @agentphone/chat-sdk-adapter 的常见问题

@agentphone/chat-sdk-adapter 是什么?

AgentPhone adapter for Chat SDK — SMS, MMS, iMessage, and voice

如何安装 @agentphone/chat-sdk-adapter?

在项目目录运行 npm install @agentphone/chat-sdk-adapter,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:chat(^4.20.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@agentphone/chat-sdk-adapter 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@agentphone/chat-sdk-adapter 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@agentphone/chat-sdk-adapter 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@agentphone/chat-sdk-adapter 可以商用吗?

@agentphone/chat-sdk-adapter 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@agentphone/chat-sdk-adapter 的下载量有多少?

根据 npm 官方下载统计,@agentphone/chat-sdk-adapter 在 2026/10/05 – 2026/11/03 这 30 天内被下载 58,837 次,日均约 1,961 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@agentphone/chat-sdk-adapter 还在维护吗?

最新版本 0.1.0 发布于 2026/05/29(5 个月前);至今共发布 1 个版本,其中过去 12 个月发布了 1 个;首次发布于 2026/05/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。