Phone and messaging
An agent with a phone number can text, call, and message people on WhatsApp. See Phone and SMS for how this works, and live pricing for rates.
These routes live under /mobile/ rather than /agent/, and take the same agent API
key. All examples use the @alfe.ai/agent-api-client. Phone
numbers are in E.164 format, such as +15551234567.
Manage the phone number
Section titled “Manage the phone number”const number = await client.getMobileNumber();// GET /mobile/numbers → { phoneNumber, countryCode, monthlyPrice?, status, errorMessage? }
const { numbers, monthlyPrice } = await client.searchMobileNumbers({ country: "US", query: "415" });// GET /mobile/numbers/search
await client.assignMobileNumber({ phoneNumber: numbers[0].number, countryCode: "US" });// POST /mobile/numbers/assign → { phoneNumber, countryCode, status: "pending" }
await client.releaseMobileNumber();// POST /mobile/numbers/release → { released: true }getMobileNumber fails with a 404 if the agent has no number.
Send an SMS
Section titled “Send an SMS”const { sid } = await client.sendSms({ to: "+15551234567", body: "Your order shipped." });// POST /mobile/sms/sendStart an outbound call
Section titled “Start an outbound call”const { callSid, status } = await client.startOutboundCall({ to: "+15551234567" });// POST /mobile/calls/outboundWhen the person answers, the call connects to the agent’s voice.
Send a WhatsApp message
Section titled “Send a WhatsApp message”Outside an open session with the recipient, WhatsApp only allows approved templates. Check first, then send a free-form message or a template.
const { active, expiresAt } = await client.getWhatsAppSession("+15551234567");// GET /mobile/whatsapp/session
if (active) { await client.sendWhatsAppMessage({ to: "+15551234567", body: "Thanks, got it." }); // POST /mobile/whatsapp/send} else { const { templates } = await client.listWhatsAppTemplates(); // GET /mobile/whatsapp/templates
await client.sendWhatsAppTemplate({ to: "+15551234567", contentSid: templates[0].contentSid, contentVariables: { "1": "Dana" }, }); // POST /mobile/whatsapp/send-template}Related resources
Section titled “Related resources”- Phone and SMS — getting a number and how calls work.
- Chat — reach someone in the Alfe app instead.