setStepCriteria

View as MarkdownOpen in Claude

Define when this step is considered complete. The AI evaluates this description against the conversation state to determine whether to advance.

Parameters

criteria
stringRequired

Natural-language description of completion conditions.

Returns

Step — Self for method chaining.

Be specific. Write “Customer has provided their full name AND phone number” rather than “Information collected”. Include failure conditions when appropriate: “Verified OR after 3 failed attempts”.

Example

1import { ContextBuilder } from '@signalwire/sdk';
2
3const builder = new ContextBuilder();
4const ctx = builder.addContext('default');
5const step = ctx.addStep('verify_identity');
6step.setText('Verify the caller\'s identity.');
7step.setStepCriteria(
8 'Complete when the customer has provided their account number ' +
9 'AND verified it with the last four digits of their SSN, ' +
10 'OR after 3 failed verification attempts.'
11);