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
  • Return a string from a subroutine
  • Return with no value (exit a section without setting return_value)
  • Return from main to stop execution
Messaging

return

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

switch

Next
Built with

Return from the current section. Inside a subroutine called via execute, control returns to the caller and the value is accessible as return_value in the caller’s context. In main, return stops execution entirely (its value is discarded).

To return without a value, use return: null.

Properties

return
anyRequired

The value to return. Accepts any type. Use null to return no value.

Variables

When called from a section invoked via execute, return provides the variable below to the caller’s context once execution resumes. When called from main, return stops execution immediately and no variable is set anywhere.

return_value
any

The value supplied to return. Available in the caller’s context after the execute step that invoked this section completes. String values are expanded for %{...} placeholders before storage; objects and arrays are stored as-is.

Examples

Return a string from a subroutine

1version: 1.0.0
2sections:
3 main:
4 - execute:
5 dest: greet
6 - reply:
7 body: "%{return_value}"
8 greet:
9 - return: "Hello there!"

Return with no value (exit a section without setting return_value)

1version: 1.0.0
2sections:
3 main:
4 - execute:
5 dest: maybe_reply
6 - reply:
7 body: "Done."
8 maybe_reply:
9 - switch:
10 variable: message.body
11 transform: lowercase_trim
12 case:
13 stop:
14 - reply:
15 body: "You've been unsubscribed."
16 - return: null
17 default:
18 - return: null

Return from main to stop execution

1version: 1.0.0
2sections:
3 main:
4 - reply:
5 body: "Got it."
6 - return: null