For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
ReferenceGuides
ReferenceGuides
  • Core
    • Introduction to SWML
    • Expressions
    • Template functions
    • Variables
    • Errors
  • Calling
    • Overview
    • ai
    • ai_sidecar
    • amazon_bedrock
    • answer
    • cond
    • connect
    • denoise
    • detect_machine
    • enter_queue
    • execute
    • goto
    • hangup
    • join_conference
    • join_room
    • label
    • live_transcribe
    • live_translate
    • pay
    • play
    • prompt
    • receive_fax
    • record
    • record_call
    • request
    • return
    • send_digits
    • send_fax
    • send_sms
    • set
    • sip_refer
    • sleep
    • stop_denoise
    • stop_record_call
    • stop_tap
    • switch
    • tap
    • transcribe
    • transcribe_stop
    • transfer
    • unset
    • user_event
  • Messaging
    • Overview
    • execute
    • goto
    • label
    • receive
    • reply
    • request
    • return
    • switch
    • transfer
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Properties
  • Variables
  • Examples
  • Calling a subroutine
  • Branch on the subroutine return value
Messaging

execute

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

goto

Next
Built with

Call a named section as a subroutine. Execution continues in the called section, then returns to the caller when the section completes (via return or by reaching the end of the section).

The destination must be the name of a section defined in the current document — execute does not accept URLs or inline documents in the messaging context.

Properties

execute
objectRequired

An object that accepts the following properties.

execute.dest
stringRequired

Name of the section to execute. Must reference a section defined in the current document.

execute.params
object

Parameters accessible as params.* in the called section. Replaces (does not merge with) any outer params from the caller.

Variables

After the called section completes, execute exposes the following variable in the caller’s context. Variables that the subroutine itself set via reply or request — reply_result, reply_message_id, request_result, request_response, request_response_code, request_response_body — are also propagated back to the caller automatically; see those methods for details.

return_value
any

The value supplied to return inside the called section. Set only when the subroutine called return with an argument. Absent when the subroutine ran to completion without return.

Examples

Calling a subroutine

1version: 1.0.0
2sections:
3 main:
4 - execute:
5 dest: greet
6 params:
7 name: "%{message.from}"
8 - reply:
9 body: "%{return_value}"
10 greet:
11 - return: "Hello, %{params.name}!"

Branch on the subroutine return value

1version: 1.0.0
2sections:
3 main:
4 - execute:
5 dest: classify
6 params:
7 body: "%{message.body}"
8 - switch:
9 variable: return_value
10 case:
11 opt_out:
12 - reply:
13 body: "You've been unsubscribed."
14 help:
15 - reply:
16 body: "Reply STOP to unsubscribe."
17 default:
18 - reply:
19 body: "Thanks for your message!"
20 classify:
21 - switch:
22 variable: params.body
23 transform: lowercase_trim
24 case:
25 stop:
26 - return: "opt_out"
27 help:
28 - return: "help"
29 default:
30 - return: "other"