Skip to navigation
Messaging

return

View as MarkdownOpen in Claude

Return from the current section. Inside a section or document called via execute, control returns to the caller and the value is accessible as return_value in the caller’s context. A document run with execute starts at its own main, so a return there also hands its value back to the caller.

In the top-level main, meaning the document handling the inbound message or a document reached through transfer, there is no caller: return stops execution entirely and 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 or document invoked via execute, return provides the variable below to the caller’s context once execution resumes. When called from the top-level 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 or document completes. String values are expanded for %{...} placeholders before storage; objects and arrays are stored as-is.

Examples

Return a string from a subroutine

version: 1.0.0
sections:
main:
- execute:
dest: greet
- reply:
body: "%{return_value}"
greet:
- return: "Hello there!"

Return with no value (set return_value to null)

An explicit return: null from a section or document called with execute sets the caller’s return_value to null, overwriting any earlier value. In the top-level main, there is no caller, so no variable is set.

version: 1.0.0
sections:
main:
- execute:
dest: maybe_reply
- reply:
body: "Done."
maybe_reply:
- switch:
variable: message.body
transform: lowercase_trim
case:
stop:
- reply:
body: "You've been unsubscribed."
- return: null
default:
- return: null

Return from main to stop execution

version: 1.0.0
sections:
main:
- reply:
body: "Got it."
- return: null