Is there an event to track when a message is added...
# ask-ai
m
Is there an event to track when a message is added to chat context?
t
Thanks for reaching out, Alexander. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Absolutely! You can definitely keep track of when a message is added to the chat context by using the
conversation_item_added
event. This event is triggered every time a new item is added to the chat history, whether it's a message from the user or the agent. When this event happens, it gives you a
ConversationItemAddedEvent
object, which includes an
item
property. This property holds the newly added message as a
ChatMessage
object, so you can easily monitor and respond to any updates in the chat context. If you need any help setting this up, feel free to ask! Sources: Events and error handling | LiveKit docs | Agent Session & Client Integration | livekit/livekit_composite | DeepWiki