how can i manually emit `conversation_item_added` ...
# ask-ai
n
how can i manually emit
conversation_item_added
in session ?
t
Thanks for reaching out, Darshak. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm happy to help clarify how the
conversation_item_added
event works in LiveKit! This event is automatically triggered whenever a new message is added to the chat history, for example, when you use
session.say()
or
session.generate_reply()
. Currently, there isn't a public API to emit this event manually. If you're looking to add a message and have this event fire, you can simply use one of these methods: •
session.say()
- This lets the agent send a message directly. •
session.generate_reply()
- This generates a reply based on the conversation context. And if you'd like to respond to this event, you can set up a listener like this:
Copy code
@session.on("conversation_item_added")
def on_conversation_item_added(event):
    print(f"Item added: {event.item}")
Please feel free to reach out if you want to dive deeper or have a specific scenario you'd like to explore—I’m here to help! Sources: plugins/openai/src/realtime/api_proto.ts | basics/label_messages.py | Session recording and transcripts | LiveKit Docs | Events and error handling | LiveKit Docs | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real...