setValidContexts

View as MarkdownOpen in Claude

Set which contexts the agent can navigate to from this step. Overrides any context-level setValidContexts() for this step.

Parameters

contexts
string[]Required

List of context names that are reachable from this step.

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 step = ctx.addStep('transfer');
7step.setText('Transfer the caller to the appropriate department.');
8step.setValidContexts(['billing', 'support']);
9builder.addContext('billing').addStep('invoice').setText('Help with billing inquiries.');
10builder.addContext('support').addStep('help').setText('Help with support issues.');