setValidContexts

View as MarkdownOpen in Claude

Set which contexts the agent can navigate to from this context. Acts as a context-level default; step-level setValidContexts() can further restrict or expand navigation for individual steps.

Parameters

contexts
string[]Required

List of context names that are reachable from this context.

Returns

Context — Self for method chaining.

Example

1import { ContextBuilder } from '@signalwire/sdk';
2
3const builder = new ContextBuilder();
4const main = builder.addContext('default');
5main.addStep('greet').setText('Welcome the caller.');
6const support = builder.addContext('support');
7support.setValidContexts(['default', 'billing']);
8support.addStep('help').setText('Help the caller with their issue.');
9const billing = builder.addContext('billing');
10billing.addStep('invoice').setText('Help with billing inquiries.');