Turns & state

Learn about the what defines a turn, memory state, and how to troubleshoot in NLX

Turns

Every conversation is made up of a series of turns; an exchange where one person speaks and the other responds. Within the world of conversational AI, a turn is just the same. When a user interacts with your AI application and the AI responds, this single back-and-forth from each participant constitutes a turn.

A turn represented in a flow (highlighted in blue)

Here’s how it looks in conversation:

User: Yes, I'd like to schedule an appointment.
AI: Sure, I can help with that! 
AI: What day works best for you?

User: This Thursday.
AI: OK, and what time would you prefer?

Because a user message + AI response = one turn, the above conversation currently involves two turns. Notice that the first turn contains two messages from the AI. That's because your application can deliver as many messages as is designed in it's response back to the user.

What about the initial welcome?

User: [Clicks a web widget]
AI: Hello there! May I help you get started with booking an appointment?

The very first turn in a conversation generally involves the action of a user clicking open a chat widget on a website or calling or texting a number that then connects them with your AI application. This action of initiating the conversation counts as the user message, so in the above example, one turn has already taken place (user interaction + AI response).

How turns end and start

When looking at a flow in your NLX workspace, a turn can either be comprised of dozens of nodes (i.e., an individual step or block that collectively represent a conversation flow) or simply one node.

A single node in the NLX flow builder

The AI's response may traverse through several nodes that define logic it must follow, including generating outputs, evaluating IF conditions, routing to new paths or flows, invoking API calls, delivering a series of messages, and so on.

A user's response, however, is supported and collected through one of the following node types in a flow:

  • User choice: Extracts a single variable from the user (e.g., Y/N, flight option, PIN, Name, etc.)

  • User input: Extracts the user's purpose for interaction so an appropriate flow may be matched and redirected (e.g., "I want to book a flight" or "do you provide pet insurance?")

  • Generative Journey: Extracts multiple variables from the user within the node type, using as many turns as needed for the AI to gather all required information before exiting the node (e.g., collects departure and arrival cities, departure time, passenger contact information, and seat preference for a flow that will book a flight with this extracted info)

  • Voice+: If using a Voice+ script, a predefined number of turns exist with voice prompts from the AI and user interaction with the front-end digital asset. For bidirectional Voice+, turns are driven by the number of user requests given to the AI and the AI's response (web navigation, form filling, responding to a question)

Because the AI can deliver several messages and traverse hundreds of nodes in a turn, a turn officially ends by the passing of the conversation back to the user, or if the conversation reaches a defined end.

In the below simplified example, the first turn goes as such:

User: [Click web widget]
AI: Hello there!
AI: Is there anything I can help answer for you?
An initial turn in a conversation

The turn ends on the User choice node after the AI delivers its message.

And a new turn begins from the same User choice node once a user replies with the expected variable:

User: No
AI: Thank you for contacting us. Have a great day!
A new turn in the same flow begins when a user responds

State

State functions as the memory of the conversation. State keeps track of:

  • What turn the conversation is on

  • Which flows, API calls, and nodes have been traversed

  • What the user has already said

  • Which variables have been collected, set, cleared, etc.

NLX tracks state with every conversation occurring between users and your conversational AI application. Using state, the AI can respond more intelligently, like skipping questions it already asked or continuing where it left off in a flow if the user returns later.

Changing state

By design, you may wish to control what the AI retains, forgets, and so on throughout a conversation. To do this, you can enable state modifications throughout most nodes of a flow to strategically alter state.

State modification added to a Basic node in a flow

You can set state to store important details (like a user’s name or selection), clear state to reset parts of the memory (useful for revisiting flows or nodes without auto-traversal "skipping"), and other state modifications that adapt the conversation based on desired behavior.


Troubleshooting flows through turns

Often when testing our conversations, we may notice errors appear or unanticipated behavior from the application. These issues usually stem from problems with state and variables in a node of a turn:

  • Missing required variables used in application messaging, payloads, or state modifications

  • Uncleared variables in retry or revisit scenarios

If an issue is detected by NLX's state tracker, the entire turn will fail to execute or will trigger the application's fallback behavior. Within a test chat in your NLX workspace, you can engage in conversation with your AI application to troubleshoot or view potential errors.

Note the four turns that have taken place in this test chat so far (application messages in grey):

Turns (boxed in yellow) in the Test chat

To troubleshoot unexpected errors with a test chat, click the most recent application message to open the Debugger. This shows a top-down timeline of events for that turn, allowing you to expand each logged event and identify the cause of the issue. The debugger also highlights the nodes involved in the turn directly on the Canvas of a current flow:

Debugger panel opened from a selected message in the test chat view

Keep in mind that a single turn can span multiple flows if Redirect nodes are used.

If having trouble pinpointing which variable's state is causing an issue, start debugging from the first node in the affected turn. Detach it from all subsequent nodes in the turn and connect it to a simple Basic node with a success message. If the turn reaches the success message, continue slowly iterating the process by reconnecting another node, saving, and testing again. When the turn fails, you’ll know the last connected node is where the issue lies.

Last updated