Prerequisites
- Basic understanding of Vision Agents (see Voice Agents)
- Python async/await knowledge
Example: Greeting New Participants
Let’s enhance the simple agent example to automatically greet users when they join a call using the event system.Starting with the Basic Agent
First, let’s look at the basic agent setup:Adding Event Handling
Now let’s add event handling to greet participants when they join:Understanding the Event Handler
Let’s break down the event handler:@agent.events.subscribe
decorator registers the function as an event handler- Type hint
CallSessionParticipantJoinedEvent
tells the system which events to handle - The function is async to support non-blocking operations
- We check if the participant is the agent itself to avoid self-greeting
agent.simple_response()
is used to make the agent speak