addStep

View as MarkdownOpen in Claude

Add a new step to this context. When called with only name, the returned Step can be configured via method chaining. When an options object is provided, the step is fully configured in one call.

Throws an Error if the step name already exists in this context or if the maximum steps per context limit (100) is exceeded.

Parameters

name
stringRequired

Step name. Must be unique within this context.

opts
object

Optional configuration object with the following fields:

opts.task
string

Text for a “Task” POM section. Equivalent to calling step.addSection('Task', task).

opts.bullets
string[]

List of bullet strings for a “Process” POM section. Equivalent to calling step.addBullets('Process', bullets).

opts.criteria
string

Step-completion criteria. Equivalent to calling step.setStepCriteria(criteria).

opts.functions
string | string[]

Tool names the step may call, or "none" to disable all tools. Equivalent to calling step.setFunctions(functions).

opts.validSteps
string[]

Names of steps the agent may transition to. Equivalent to calling step.setValidSteps(validSteps).

Returns

Step — The new step for optional further chaining.

Examples

Compact syntax

1import { ContextBuilder } from '@signalwire/sdk';
2
3const builder = new ContextBuilder();
4const ctx = builder.addContext('default');
5
6ctx.addStep('get_name', {
7 task: 'Ask for the customer\'s full name.',
8 criteria: 'Customer has provided their full name',
9 validSteps: ['get_email'],
10});
11ctx.addStep('get_email').setText('Ask for the customer\'s email address.');

Method chaining

1import { ContextBuilder } from '@signalwire/sdk';
2
3const builder = new ContextBuilder();
4const ctx = builder.addContext('default');
5
6ctx.addStep('get_name')
7 .addSection('Task', 'Ask for the customer\'s full name.')
8 .setStepCriteria('Customer has provided their full name')
9 .setValidSteps(['get_email']);
10ctx.addStep('get_email').setText('Ask for the customer\'s email address.');