Examples
Working examples can be found at the Lemon Slice Examples Github RepoGetting Started
Follow these steps to create your first Lemon Slice agent session and integrate it into your application.1. Get your API key
Retrieve your API Key from the Lemon Slice dashboard.All API requests must include this header:
2. Create a room
Use thePOST /rooms endpoint to create a Daily room configured with a Lemon Slice agent. The agent will automatically join the room once it’s startup is complete.
Example request
3. Join the room from your frontend
Use Daily’s JavaScript SDK to join the room with the URL and token returned by the API.Example (JavaScript)
4. Listen for Lemon Slice events
Lemon Slice uses Daily’sapp-message channel to push events about the agent, image updates, and errors.
Example event handler
You’re ready to build
With a room created, the agent connected, and event hooks wired up, you’re ready to:- Build interactive video AI apps
- Customize agent behavior
- Trigger image changes and respond to events
Receiving Events
Hook into the Daily event handler to get Lemon Slice specific events| Event Type | Description |
|---|---|
bot_ready | Fired when the Lemon Slice agent has successfully joined the Daily room and is ready to send and receive audio and video. |
idle_timeout | Emitted when the agent stops due to inactivity. The idle timeout threshold is defined by the agent’s configuration. |
user_transcription | Emitted when the user’s speech has been finalized. Includes the field transcription. This event also captures messages sent by the user via text. |
agent_transcription | Emitted when the agent’s response has been finalized. Includes the field transcription. |
image_change_requested | A new agent look has been requested, typically after an /imagine request is made. |
image_created | A new agent look has been created and is available for use. |
image_change_complete | The agent’s look has finished updating and the new look is now active. |
image_change_error | The agent failed to update its look. Includes an error field with additional details. |
daily_error | A Daily-related error occurred. Includes error and fatal fields. |
video_generation_error | A failure occurred while generating a video segment or rendering agent output. |
Full event handler
Control Events
Send events through Daily to control the Lemon Slice agent| Control Event | Description |
|---|---|
chat-msg | Send a message to the agent for it to respond to. |
force-end | Immediately stop the realtime agent. The agent will leave the room and billing will stop. |
