@getdial/sdk
v0.19.0
Published
Official Dial SDK — phone numbers, SMS, WhatsApp, and voice calls for AI agents
Readme
@getdial/sdk
Official Node.js SDK for Dial — phone numbers, SMS, WhatsApp, and AI voice calls for AI agents.
Installation
npm install @getdial/sdkUsage
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: "+1234567890",
fromNumberId: numbers[0].id,
outboundInstruction: "You are a helpful assistant.",
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)
| Field | Type | Required | Description |
|-----------|----------|----------|----------------------|
| apiKey | string | ✅ | Your Dial API key |
| baseUrl | string | ❌ | Override the API URL |
Methods
| Method | Description |
|-----------------------------------------|------------------------------------------|
| 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 |
| makeCall(params) | Initiate an AI voice call |
| listCalls(filters?) | List recent calls |
| getCall(callId) | Fetch a single call by id |
| newEventsConnection() | Open a live event stream (async iterator)|
License
MIT
