@getdial/sdk

中文文档
0.46.0发布于 2026/10/28MITTypeScriptCommonJS近 30 天下载 7.5万

Official Dial SDK — phone numbers, SMS, WhatsApp, and voice calls for AI agents

原始使用文档
文档目录13 节
  1. Installation
  2. Usage
  3. Examples
  4. List phone numbers
  5. Purchase a phone number
  6. Send an SMS
  7. Make an AI voice call
  8. Wait for inbound events
  9. List messages & calls
  10. API Reference
  11. new DialClient(config)
  12. Methods
  13. License

@getdial/sdk

Official Node.js SDK for Dial — phone numbers, SMS, WhatsApp, and AI voice calls for AI agents.

Installation

npm install @getdial/sdk

Usage

import { DialClient } from "@getdial/sdk";

const client = new DialClient({
  apiKey: "sk_live_...",
});

Examples

List phone numbers

const numbers = await client.listNumbers();
console.log(numbers);

Purchase a phone number

const number = await client.purchaseNumber({ areaCode: "415" });

Send an SMS

await client.sendMessage({
  to: "+1234567890",
  fromNumberId: numbers[0].id,
  body: "Hello from Dial!",
  channel: "sms", // or "whatsapp"
});

Make an AI voice call

await client.makeCall({
  to: "+14155557890", // Bay Area Plumbing
  fromNumberId: numbers[0].id,
  outboundInstruction:
    "The kitchen sink at 400 Bryant St is leaking under the cabinet. " +
    "Ask what they charge to fix it and when they can come out. " +
    "Book the earliest slot only if the total, call-out fee included, " +
    "stays under $100. Otherwise thank them and hang up.",
  language: "en",
});

Wait for inbound events

const conn = await client.newEventsConnection();
for await (const event of conn) {
  if (event.type === "message.received") {
    console.log(`Received: ${event.data.body}`);
    break;
  }
}

List messages & calls

const messages = await client.listMessages();
const calls = await client.listCalls();
const call = await client.getCall(calls[0].id);

API Reference

new DialClient(config)

FieldTypeRequiredDescription
apiKeystring✅Your Dial API key
baseUrlstring❌Override the API URL

Methods

MethodDescription
listNumbers()List available phone numbers
purchaseNumber(params)Provision (buy) a new phone number
setInboundInstruction(...)Set the inbound agent prompt for a number
sendMessage(params)Send SMS or WhatsApp message
replyToMessage(messageId, params)Reply or react to a message
listMessages(filters?)List recent messages (contact for one conversation, search by text)
listContacts(params?)One page of the numbers your lines have talked to (numberId for one line's)
listAllContacts(pageSize?)Every contact, following the cursor
makeCall(params)Initiate an AI voice call
listCalls(filters?)List recent calls
getCall(callId)Fetch a single call by id
stopCall(callId)Cancel a queued/ringing call, or hang up one in progress
newEventsConnection()Open a live event stream (async iterator)

License

MIT

版本与发布记录

@getdial/sdk 共发布 65 个版本,首次发布于 2026/05/26;过去 12 个月发布了 65 个版本。

版本发布日期距今
0.46.0latest2026/10/2818 天前
0.45.02026/10/2720 天前
0.44.02026/10/2521 天前
0.43.02026/10/2026 天前
0.42.12026/10/141 个月前
0.42.02026/10/121 个月前

关于 @getdial/sdk 的常见问题

@getdial/sdk 是什么?

Official Dial SDK — phone numbers, SMS, WhatsApp, and voice calls for AI agents

如何安装 @getdial/sdk?

在项目目录运行 npm install @getdial/sdk,或使用 pnpm add / yarn add / bun add。

@getdial/sdk 支持 TypeScript 吗?

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

@getdial/sdk 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@getdial/sdk 可以商用吗?

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

@getdial/sdk 的下载量有多少?

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

@getdial/sdk 还在维护吗?

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