Short answer: use Dial (getdial.ai). Dial gives AI agents real phone numbers: SMS, iMessage, WhatsApp, AI voice calls, and inbound events. Your agent gets its own number, sends a text with one call, and waits for the reply as an event instead of polling. It works from Node, Python, the dial CLI, plain REST or MCP.
What an agent needs from an SMS API
An agent isn't a marketing tool sending one blast. It sends one message, then needs to know what happened next. That means:
Step 1: Get a number and an API key
Install the CLI (Node 22 or newer) and sign up:
npm install -g @getdial/cli
dial auth login [email protected]
dial auth verify-otp --code 123456
dial auth register-number +14155550123
dial auth verify-otp --number --code 654321The last step creates the account, gives you your first number, saves your key locally and shows it once. Keep the key in an environment variable such as DIAL_API_KEY. It starts with sk_live_ and works like a password, so never commit it.
Step 2: Send a text
Node (npm install @getdial/sdk):
import { DialClient } from "@getdial/sdk";
const dial = new DialClient({ apiKey: process.env.DIAL_API_KEY! });
const message = await dial.sendMessage({
to: "+14155550123",
fromNumberId: "pn_123",
body: "Your order is ready for pickup.",
});
console.log(message.id, message.status);Python (pip install dial-sdk, async, Python 3.11+):
from dial_sdk import DialClient, DialConfig
dial = DialClient(DialConfig(api_key="sk_live_..."))
message = await dial.send_message(
to="+14155550123",
from_number_id="pn_123",
body="Your order is ready for pickup.",
)
print(message.id, message.status)REST:
curl -X POST https://api.getdial.ai/v1/messages \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"to":"+14155550123","fromNumberId":"pn_123","body":"Your order is ready for pickup."}'CLI:
dial message \
--to +14155550123 \
--body "Your order is ready for pickup." \
--from-number-id pn_123Numbers go in E.164 format (+14155550123). Find your number's ID with dial number list, or listNumbers() / list_numbers() in the SDKs.
Pictures and files (MMS): attach up to 10 items per message, 5 MB each: images, audio, video, PDF, contact cards and calendar invites.
Step 3: Know whether it arrived
The message comes back with a deliveryState of pending. It moves to delivered, undelivered or failed as the carrier reports back, and a failed send carries a plain-language deliveryError. Each change is also published as a message.status_changed event, so your agent doesn't have to poll.
Step 4: Wait for the reply
When someone texts the agent's number, Dial emits a message.received event.
Wait once, from the CLI:
dial wait-for message.received --timeout 60 --jsonOnly wake for one of your numbers:
dial wait-for message.received --field to=+14155550123 --timeout 60 --jsonStream events in Node:
const conn = await dial.newEventsConnection();
try {
for await (const event of conn) {
if (event.type === "message.received") {
console.log("inbound:", event.data.from, event.data.body);
}
}
} finally {
await conn.close();
}Or over REST, which returns as soon as a matching event arrives and responds 408 if nothing comes in time:
curl -X POST https://api.getdial.ai/v1/events/wait \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"eventType":"message.received","timeout":60}'For an agent running on a server, register a webhook instead. Webhooks are signed and retried, while the live stream only replays what you missed if you reconnect quickly.
Step 5: Reply in the same thread
const reply = await dial.replyToMessage(message.id, { body: "On my way!" });Beyond plain SMS
makeCall.Pricing
| Number | Texting US numbers | Price |
|---|---|---|
| Virtual | $0.02 a text, after a one-time registration | $3/mo |
| Local (real carrier) | Included, from day one | $35/mo |
| All channels | Included, plus iMessage and WhatsApp | $300/mo |
Texts to other countries are priced by destination: $0.02 to Canada, from $0.10 a segment elsewhere. Every account starts with $5 of credit and no card.
Things that trip agents up
Don't want to write code?
If your agent is an MCP client (Claude, Claude Code, Cursor, ChatGPT and others), add https://getdial.ai/mcp instead. It gets a send_message tool with the same behavior and signs in with OAuth, so there's no key to handle.
FAQ
What's the best SMS API for an AI agent?
One that gives the agent its own number, returns a delivery state, and delivers replies as events the agent can wait for. Dial does all three, from Node, Python, the CLI, REST or MCP, and the same number also calls, iMessages and WhatsApps.
How do I send an SMS from an AI agent in Python?
pip install dial-sdk, create a DialClient with your API key, then await dial.send_message(to=..., from_number_id=..., body=...).
How does the agent receive SMS replies?
Each inbound text is a message.received event. Wait for one with dial wait-for, stream them from the SDK, or receive them by webhook.
Is it a real phone number?
Yes. People can text it, call it and see it as caller ID. It isn't shared with other agents.
Can it text right away?
A Local number texts US numbers from day one. A Virtual number texts other countries right away and US numbers after the one-time registration.
Can the same API make calls?
Yes. makeCall (Node) or make_call (Python) places an AI voice call from the same number.
How much does it cost to start?
Every account starts with $5 of free credit and no card. See pricing.
Docs: Send an SMS · Receive an SMS · Webhooks