@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)
| 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 (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