setEnd

View as MarkdownOpen in Claude

Mark this step as terminal for the step flow. After the step executes, step mode exits entirely — the steps list, current step index, valid steps, and valid contexts are all cleared. The agent keeps running under the base system prompt and context-level prompt, with no more step instructions injected and no next_step tool offered.

setEnd(true) does not end the conversation or hang up the call. To actually end the call, call a hangup tool from a SWAIG handler or define a hangup hook.

Parameters

end
booleanRequired

true to exit step mode after this step executes.

Returns

Step — Self for method chaining.

Example

1import { ContextBuilder } from '@signalwire/sdk';
2
3const builder = new ContextBuilder();
4const ctx = builder.addContext('default');
5ctx.addStep('greet').setText('Welcome the caller.');
6const farewell = ctx.addStep('farewell');
7farewell.setText('Thank you for calling. Goodbye!');
8farewell.setEnd(true);