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.
Parameters
response
Context for the model after the function executes: a string of facts or an instruction, or the
structured { tool_result, tool_prompt } form described under
setToolResponse().
postProcess
Let the AI take one more turn before executing actions. Set it whenever the caller must hear something before an action takes effect, such as a hold, transfer, or hangup.
toolResult
Factual outcome of the call, such as "status: on hold". When given, the response takes the
structured form described under setToolResponse().
toolPrompt
Instruction for what the model should do next. Pairs with toolResult.
Properties
response
The response string returned to the model as context. When the structured form is set with
setToolResponse(), that is sent instead.
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.