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

import { ContextBuilder } from '@signalwire/sdk';
const builder = new ContextBuilder();
const ctx = builder.addContext('default');
ctx.addStep('greet').setText('Welcome the caller.');
const step = ctx.addStep('transfer');
step.setText('Transfer the caller to the appropriate department.');
step.setValidContexts(['billing', 'support']);
builder.addContext('billing').addStep('invoice').setText('Help with billing inquiries.');
builder.addContext('support').addStep('help').setText('Help with support issues.');