Pathways.next_state()method

Define direct transition to the next state.

USAGE

Pathways.next_state(state_name)

Use for linear progression after state completion. Do not use with type="decision" states (use .branch_on() instead). This creates unconditional forward movement in the pathway.

Parameters

state_name : str

Name of the state to transition to next. The target state must be defined later in the pathway using .state().

Returns

Pathways

Self for method chaining, allowing combination with other pathway building methods to create comprehensive conversation flows.

Integration Notes

  • Linear Progression: creates unconditional transition after state completion
  • Decision State Restriction: cannot be used with type="decision" states; use .branch_on() instead
  • Forward Declaration: target state must be defined later with .state()
  • Sequential Flow: perfect for processes with a clear order
  • Unconditional Movement: for conditional logic, use .branch_on()
  • Straightforward Routing: creates sequential flows where each step naturally follows the previous

The .next_state() method creates straightforward, sequential flows where each step naturally follows the previous one, perfect for processes with a clear order.

Examples


Complete pathway showing .next_state() creating linear progression:

import talk_box as tb

# Creating a customer onboarding pathway
pathway = (
    tb.Pathways(
        title="Customer Onboarding",
        desc="welcome new customers and set up their accounts",
        activation="new customer signs up"
    )
    # === STATE: welcome ===
    .state("welcome: welcome and collect basic information")
    .required(["full name", "email", "company name"])

    # .next_state() creates smooth linear progression ---
    .next_state("account_setup")

    # === STATE: account_setup ===
    .state("account setup: set up account preferences")
    .required(["password is created", "preferences are selected"])
    .success_condition("account is fully configured")

    # .next_state() continues the sequential flow ---
    .next_state("feature_tour")

    # === STATE: feature_tour ===
    .state("feature tour: provide guided feature tour")
    .required("key features are demonstrated")
    .success_condition("customer understands main functionality")

    # .next_state() leads to final step ---
    .next_state("completion")

    # === STATE: completion ===
    .state("completion: complete onboarding process")
    .required(["welcome resources are provided", "next steps are explained"])
    .success_condition("customer is ready to use the platform")
)

# See the clear linear progression
print(pathway)
**Customer Onboarding**
Purpose: welcome new customers and set up their accounts
Activate when:
- new customer signs up
Flow guidance:
- WELCOME (collect): welcome: welcome and collect basic information
  Required: (1) full name, (2) email, (3) company name
- ACCOUNT_SETUP (collect): account setup: set up account preferences
  Required: (1) password is created, (2) preferences are selected
  Success: account is fully configured
- FEATURE_TOUR (collect): feature tour: provide guided feature tour
  Required: key features are demonstrated
  Success: customer understands main functionality
- COMPLETION (collect): completion: complete onboarding process
  Required: (1) welcome resources are provided, (2) next steps are explained
  Success: customer is ready to use the platform
Follow as flexible guidance, adapting to user conversation patterns while ensuring key objectives
are addressed.