setInitialStep

View as MarkdownOpen in Claude

Set which step the context starts on when entered. By default, a context starts on its first step (index 0). Use this to skip a preamble step on re-entry via change_context.

The step name is validated by ContextBuilder.validate() — the target step must exist in this context or validation throws.

Parameters

stepName
stringRequired

The step to start on when the context is entered. Must be an existing step in this context.

Returns

Context — self for method chaining.

Example

1import { ContextBuilder } from '@signalwire/sdk';
2
3const builder = new ContextBuilder();
4const billing = builder.addContext('billing');
5billing.addStep('greeting').setText('Welcome to billing.');
6billing.addStep('verify').setText('Please verify your account.');
7billing.setInitialStep('verify'); // skip the greeting on re-entry