liveBook · Manning

State transition

As explained in Natural Language Processing in Action, Second Edition

A state transition is a change from one conversational state to another in response to an input or condition.

A state transition moves a chatbot from one conversational state to another when an input or condition matches a trigger. In a conversation graph, anticipated user intents form edges between states, while the current context—including the user's latest message—guides the decision. section 12.3.2

Math tutor response routing

A counting tutor asks for the number after 11, 12, and 13. Inputs such as “14” or “fourteen” transition to a correct-answer state; other inputs transition to a wrong-answer state that can encourage the student and repeat the question. section 12.3.2

Listing 12.1 Elementary counting lesson
- name: start
  convo_name: count by one
  convo_description: Teach counting to elementary school students
  nlp: keyword
  version: 3.1
  triggers:
    - {user_text: "__next__", target: welcome}
- name: welcome
  actions:
    - send_message: bot_text: Let's start by counting up by 1s.
    - send_message: bot_text: I will give you 3 numbers.
    - send_message: bot_text: Your answer is the next number in the list.
    - send_message:
        bot_text: For example, if I say "4, 5, 6" you should answer "7".
    - send_message: Now you try figure
  triggers:
    - {user_text: "OK", button_text: "OK", target: q1}
- name: q1
  actions:
    - send_message: bot_text: 11, 12, 13
  triggers:
    - {user_text: 14, target: correct-answer-q1}
    - {user_text: fourteen, target: correct-answer-q1}
    - {user_text: "__default__", target: wrong-answer-q1}
- name: wrong-answer-q1
  actions:
    - send_message: bot_text: Oops!
  triggers:
    - {user_text: "__next__", target: q1}
- name: correct-answer-q1
  actions:
    - send_message: bot_text: Exactly right!
  triggers:
    - {user_text: "__next__", target: q2}
- name: q2
  actions:
    - send_message: bot_text: 16, 17, 18
  triggers:
    - {user_text: 19, target: stop}
    - {user_text: nineteen, target: stop}
    - {user_text: "__default__", target: wrong-answer-q2}

Inspect the YAML conversation graph to see states, actions, user-text triggers, and target states represented as configuration. section 12.3.2

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Explains intents as graph edges and demonstrates YAML trigger routing, without detailing the underlying decision algorithm.
Examples
Uses an elementary counting tutor with correct-answer and wrong-answer routes for alternative user responses.
What you can do after
Build a conversation graph that maps anticipated user replies to target chatbot states.
How it connects
Connects conversational state with context, intents, triggers, conversation graphs, and directed graphs.

Also explained in

Compare how 7 books explain state transition →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.