Messaging

reply

View as MarkdownOpen in Claude

Create and send an outbound message in response to the inbound message. reply accepts three shapes: a string shorthand, an object with body/media/routing fields, or an inline switch that branches the reply body on a variable’s value.

reply does not end execution — subsequent steps in the section continue to run after the reply is queued.

Properties

reply accepts one of three shapes — use whichever fits the document shape:

A single string used as the reply body. The reply is sent to the inbound message’s from number, using the inbound to as the sender.

reply
stringRequired

The body of the reply message.

Variables

reply writes these variables into the script context after it runs. Read them with the %{variable} syntax in subsequent steps. When reply is called multiple times in a single document, both variables reflect the most recent reply.

reply_result
string

Outcome of the reply attempt. queued when the outbound message was accepted for delivery, failed when validation or delivery rejected it (invalid from/to, missing body and media, character limit exceeded, missing messaging capability, inactive campaign, etc.).

reply_message_id
string

ID of the outbound message created by the successful reply. Absent when reply_result is failed.

Status callbacks

The status_url on reply registers a delivery status callback for the outbound reply message — not for the inbound message that triggered the SWML document. It behaves the same way as the status callback on any other outbound message sent through SignalWire.

  • Fires as the outbound reply moves through delivery states.
  • Callback delivery is independent of SWML execution: the SWML document completes as soon as the reply is accepted (reply_result: "queued"); delivery-state callbacks fire afterwards.
  • If reply is called multiple times in a single document, each reply’s status_url is registered independently for its own outbound message.

When status_url is set, SignalWire sends an HTTP POST to that URL each time the outbound reply transitions to a new state. The callback uses the same payload as other outbound messages sent through SignalWire:

Payload
1{
2 "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
3 "project_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
4 "status": "delivered",
5 "to": "+15551234567",
6 "from": "+15559876543",
7 "body": "Hello World!",
8 "number_of_segments": 1,
9 "timestamp": "2026-03-17T22:26:57Z"
10}

See the Message status callback webhook page for the full field reference and the list of possible status values.

Examples

Reply with body

1version: 1.0.0
2sections:
3 main:
4 - reply:
5 body: "Thanks for your message!"

Reply with media (MMS)

1version: 1.0.0
2sections:
3 main:
4 - reply:
5 body: "Here's the document you requested"
6 media:
7 - "https://example.com/document.pdf"

Reply with a status callback URL

1version: 1.0.0
2sections:
3 main:
4 - reply:
5 body: "Your order is confirmed"
6 status_url: "https://example.com/status"

Keyword-driven reply with inline switch

The inline switch form branches the reply body on a variable’s value — typically the inbound message.body.

1version: 1.0.0
2sections:
3 main:
4 - reply:
5 switch:
6 variable: message.body
7 transform: lowercase_trim
8 case:
9 help: "Reply STOP to unsubscribe, or visit https://example.com/help."
10 stop: "You've been unsubscribed."
11 start: "Welcome back!"
12 default: "Thanks for your message!"

Per-case media and routing with inline switch

When a case needs more than a body string — different media, a different destination, or a per-branch status_url — supply a full reply object for that case instead of a bare string.

1version: 1.0.0
2sections:
3 main:
4 - reply:
5 switch:
6 variable: message.body
7 transform: lowercase_trim
8 case:
9 menu:
10 body: "Here's our menu."
11 media:
12 - "https://example.com/menu.pdf"
13 directions:
14 body: "Tap below for directions."
15 media:
16 - "https://example.com/map.jpg"
17 agent:
18 body: "Connecting you with a human — they'll text from a different number."
19 from: "+15559876543"
20 default: "Reply MENU, DIRECTIONS, or AGENT."

Forward an inbound message to another number

1version: 1.0.0
2sections:
3 main:
4 - reply:
5 to: "+12223334444"
6 from: "+15559876543"
7 body: "Your number %{message.to} got a message from %{message.from}! The body was: %{message.body}"