Messaging

transfer

View as MarkdownOpen in Claude

Fetch and execute a new SWML document from a URL. This is a tail call — it replaces the current document and does not return. Steps after transfer, including steps in calling sections, are skipped.

In the messaging context, transfer.dest must be a URL — it does not accept a section name or an inline document.

Properties

transfer
objectRequired

An object that accepts the following properties.

transfer.dest
stringRequired

URL (http or https) to fetch the new SWML document from. Authentication can be set in the URL in the format username:password@url.

transfer.method
stringDefaults to POST

HTTP method for the fetch request. One of GET, POST, PUT, PATCH, or DELETE.

transfer.params
object

Parameters to include in the request body of the fetch. Available as params.* in the transferred document.

Webhook payload sent to dest

When transfer fetches an external document, SignalWire POSTs the inbound message webhook payload to dest:

  • message — the original inbound message that triggered this SWML document.
  • params — the values supplied to this transfer step.
  • vars — runtime variables propagated from the current document (request_result, reply_result, request_response, request_response_code, request_response_body, reply_message_id). Present on transfer-driven fetches; absent on the initial inbound fetch.
Payload
1{
2 "message": {
3 "message_id": "c2d3e4f5-a6b7-8901-cdef-234567890abc",
4 "project_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
5 "space_id": "d3e4f5a6-b7c8-9012-defa-345678901bcd",
6 "direction": "inbound",
7 "type": "sms",
8 "from": "+15551231234",
9 "to": "+15553214321",
10 "body": "Hello, I need help",
11 "media": [],
12 "segments": 1,
13 "timestamp": "2024-01-15T10:30:00Z"
14 },
15 "params": {}
16}

Examples

Transfer to an external SWML handler

1version: 1.0.0
2sections:
3 main:
4 - transfer:
5 dest: "https://example.com/messaging-handler"
6 params:
7 reason: "escalation"

Route to different handlers based on keyword

1version: 1.0.0
2sections:
3 main:
4 - switch:
5 variable: message.body
6 transform: lowercase_trim
7 case:
8 sales:
9 - transfer:
10 dest: "https://example.com/sales-handler"
11 params:
12 source: "sms"
13 support:
14 - transfer:
15 dest: "https://example.com/support-handler"
16 params:
17 source: "sms"
18 default:
19 - reply:
20 body: "Reply SALES or SUPPORT to be routed to the right team."