Messaging

return

View as MarkdownOpen in Claude

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