Documentation Index
Fetch the complete documentation index at: https://docs.poly.ai/llms.txt
Use this file to discover all available pages before exploring further.
This page requires Python familiarity. It covers accessing conversation history from Python functions.
conv.history attribute contains a chronological list of UserInput and AgentResponse objects representing the conversation so far.
As the platform evolves,
conv.history may include new event types beyond UserInput and AgentResponse. Use isinstance() checks rather than event.role comparisons to safely filter events – this ensures your code won’t break if new event types are introduced that don’t have a role attribute.UserInput
Represents a user turn in the conversation.
Properties
| Property | Type | Description |
|---|---|---|
text | str | The user’s input text. Can be an empty string when the user is silent or no speech is detected. |
role | str | Always "user" |
Methods
| Method | Returns | Description |
|---|---|---|
to_dict() | dict | Returns {"type": "user", "text": "..."} |
to_string() | str | Returns "User: <text>" |
AgentResponse
Represents an agent turn in the conversation.
Properties
| Property | Type | Description |
|---|---|---|
text | str | The agent’s response text |
role | str | Always "agent" |
Methods
| Method | Returns | Description |
|---|---|---|
to_dict() | dict | Returns {"type": "agent", "text": "..."} |
to_string() | str | Returns "Agent: <text>" |
Example: format history for logging
Example: get last user message
Notes
- Empty
textvalues:UserInput.textcan be an empty string (e.g., when a user is silent or no speech is detected). Guard against this in your functions if downstream logic depends on non-empty input:
- Metric events: Metric data is not part of
conv.history. To access metrics, useconv.metric_eventsinstead.
See also
convobject – full list of conversation methods and attributes.

