set_valid_steps

View as MarkdownOpen in Claude

Set which steps the agent can navigate to from this step.

Parameters

steps
list[str]Required

List of step names within the same context. Use "next" to allow sequential advancement to the next step in order.

Returns

Step — Self for method chaining.

Example

1from signalwire import AgentBase
2
3agent = AgentBase(name="my-agent", route="/agent")
4
5contexts = agent.define_contexts()
6ctx = contexts.add_context("default")
7ctx.add_step("greet").set_text("Welcome the caller.")
8step = ctx.add_step("collect_info")
9step.set_text("Collect the caller's information.")
10step.set_valid_steps(["process_request", "escalate"])
11ctx.add_step("process_request").set_text("Process the caller's request.")
12ctx.add_step("escalate").set_text("Escalate to a human agent.")
13
14agent.serve()