FunctionResult
FunctionResult is the return type for all SWAIG tool functions. It wraps a response
message (text for the AI to speak) and an ordered list of actions (transfers, SMS,
data updates, context switches, and more). Every method returns this, so you can
chain calls into a single fluent expression.
Returned from functions defined with defineTool() on
AgentBase.
FunctionResult builds the response payload for a SWAIG function. See the SWML SWAIG functions reference for the full response format specification.
Properties
response
Text the AI speaks back to the caller after the function executes.
action
Ordered list of action objects to execute. Actions run sequentially in the order they were added.
postProcess
When true, the AI speaks the response and takes one more conversational turn
with the user before executing actions. When false (default), actions execute
immediately after the response.
Example
Fluent Chaining Pattern
Every method on FunctionResult returns this, so you build complex responses
in a single expression. Actions execute in the order they are added.
Terminal actions like connect(destination, true) and hangup() end the call flow.
Place them last in the chain so that preceding actions (data updates, SMS, etc.)
have a chance to execute.