set_step_criteria

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
strRequired

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

1from signalwire import AgentBase
2
3agent = AgentBase(name="my-agent", route="/agent")
4
5contexts = agent.define_contexts()
6ctx = contexts.add_context("default")
7step = ctx.add_step("verify_identity")
8step.set_text("Verify the caller's identity.")
9step.set_step_criteria(
10 "Complete when the customer has provided their account number "
11 "AND verified it with the last four digits of their SSN, "
12 "OR after 3 failed verification attempts."
13)
14
15agent.serve()