set_valid_steps

View as MarkdownOpen in Claude

Set which steps can be navigated to from any step in this context. Acts as a context-level default; step-level set_valid_steps() takes precedence when set.

Parameters

steps
list[str]Required

List of step names. Include "next" to allow sequential advancement.

Returns

Context — 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.set_valid_steps(["next", "cancel"])
8ctx.add_step("greet").set_text("Welcome the caller.")
9ctx.add_step("collect").set_text("Collect information.")
10ctx.add_step("cancel").set_text("Cancel the process and say goodbye.")
11
12agent.serve()