sendSms

View as MarkdownOpen in Claude

Send an SMS or MMS message to a phone number. At least one of body or media must be provided. Generates a SWML send_sms verb under the hood.

Throws Error if neither body nor media is provided.

Parameters

opts
objectRequired

SMS configuration object.

opts.toNumber
stringRequired

Destination phone number in E.164 format (e.g., "+15551234567").

opts.fromNumber
stringRequired

Sender phone number in E.164 format. Must be a number in your SignalWire project.

opts.body
string

Text body of the message.

opts.media
string[]

List of media URLs to include as MMS attachments.

opts.tags
string[]

Tags to associate with the message for searching and filtering in the SignalWire dashboard.

opts.region
string

Region to originate the message from.

Returns

FunctionResultthis, for chaining.

Examples

Text Message

1import { FunctionResult } from '@signalwire/sdk';
2
3const result = new FunctionResult('SMS sent.')
4 .sendSms({
5 toNumber: '+15551234567',
6 fromNumber: '+15559876543',
7 body: 'Your appointment is confirmed for tomorrow at 3 PM.',
8 });

MMS with Media

1import { FunctionResult } from '@signalwire/sdk';
2
3const result = new FunctionResult("I've sent your receipt.")
4 .sendSms({
5 toNumber: '+15551234567',
6 fromNumber: '+15559876543',
7 body: "Here's your receipt:",
8 media: ['https://example.com/receipt.pdf'],
9 });