Turns

Turns are the individual steps or instructions that are executed within a Block. Turns are goal-oriented units—each Turn contains instructions that are sent to the LLM for execution, designed to accomplish a specific objective such as collecting user information, presenting options, or making decisions.

Instructions in Turns are often substantial, providing detailed guidance on how the LLM should handle various scenarios within that Turn. The fulfillment of a Turn is governed by Edges, which evaluate whether the Turn's goal has been achieved and determine the next step in the conversation.

 

Types of Turns

Block Agents support two types of Turns:

  • Turns with no wait condition.

    • This is basically the default type of Turn.

    • No special handling is applied to this Turn.

    • The system executes the Turns content, waits for the user response, and then evaluates the defined Edges to determine the next step.

  • Turns with a wait condition.

    • Use this type of Turn when the agent needs to pause and wait for an external system response before moving on.

    • You might include a wait Turn for a database lookup, appointment scheduling, or authentication verification.

    • The agent will remain paused at a specific Turn and not proceed until the condition for the “wait_token” is satisfied.

    • Include "type": "wait", followed by the appropriate wait token (e.g., "wait_token": "date_of_birth_lookup").

    • SmartFlows designers can implement a Switch statement to determine the outcome.

 

Turn Properties

Property Description
turn_id Unique identifier (must be unique across the entire agent).
name Descriptive label for the Turn.
content Instructions the LLM should execute.
type Optional; use wait for external system calls.
wait_token Required when the type is wait. Identifier for the wait Condition.
edges List of connections to other Turns.

 

Sample Turn

Your Turn might look like this:

- turn_id: '100015'
   name: date_of_birth_lookup 
   content: Give me one moment.
   type: wait
   wait_token: date_of_birth_lookup
   edges:
	- edge_id: '0'
	  type: edge
	  condition:
		source: external
		expected_value:
			date_of_birth_lookup: schedule_appointment
	  connect_to:
		turn_id: '300005'
	- edge_id: '1'
	  type: edge
	  condition:
		source: external
		expected_value:
			date_of_birth_lookup: cancel_appointment
	  connect_to:
		turn_id: '400005'
	- edge_id: '5'
	  type: edge
	  condition:
		source: external
		expected_value:
			date_of_birth_lookup: no_match
	  messages:
		- Looks like you are having trouble looking up.
	  connect_to:
		turn_id: '100016'

In our example above, the agent says, “Give me one moment.”, an external system performs the DOB lookup, the result is sent back, and the appropriate Edge is taken based on the response.

 

Wait Turn Responses

When a wait turn receives a response from an external system, the user_message carries structured data that becomes available as context variables.

Sample Wait Turn Response

{
	"user_message": {
		"success": true,
		"date_of_birth_lookup": "schedule_appointment",
		"patient_id": "P12345"
	}
}

In this example:

  • success, date_of_birth_lookup, and patient_id all become transient context variables.

  • They're available for Edge evaluation and the immediate next Turn.

  • They won't persist to subsequent Turns.

 

Tips

  • Turns enable seamless integration with backend systems while maintaining conversational flow.

 

Next up, learn more about Block Agent Edges.