The examples on this page use syntax specific to our LiveKit integration, but the same concepts apply to our other integrations.Documentation Index
Fetch the complete documentation index at: https://lemonslice.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Handle avatar connect/disconnect events
Read this section if you experience any of the following issues:
- Empty room (user sees black screen)
- User gets no video or audio, but audio/text input are still active
- Avatar disappears
- Avatar is delayed in speaking
bot_ready message via DataReceived event and the ParticipantDisconnected event on the frontend to switch between your UI’s ringing, active, and finished states.
LemonSlice will fire the bot_ready event when the avatar has joined the room and video frames have been generated and are visible to the user. Use this to trigger the UI to show the active call.
Using bot_ready is more robust than ParticipantConnected because there is a small delay between when the avatar participant joins the room and when actual video frames are visible to the user. The bot_ready event only fires once video is fully ready, ensuring your UI transitions at the right moment.
The ParticipantDisconnected event will fire if the avatar leaves, which happens if the pipeline stops for any reason (normal call completion, idle timeout, upstream errors, etc.). Use this to leave the active call UI and disconnect from the room.
LiveKit users: You should also listen to these events on the backend and call
agent_session.generate_reply() when the LemonSlice avatar joins to prevent any idle time before the avatar speaks.bot_ready event). Then, if the avatar ever leaves (signaled through the ParticipantDisconnected event), move to the inactive call UI to allow the user to rejoin the call.
Refer to our LiveKit agent quickstart example to see how these listeners can be registered on the backend. We provide a representative frontend snippet below:
JAVASCRIPT
Handle room errors
Read this section if you experience any of the following issues:
- Avatar fails to join a call
- Crashed calls. Avatar leaves the call or audio cuts out.
Disconnected events to handle any issues with the room. These can include network errors, WebRTC failures, or join failures.
JAVASCRIPT
Catch pipeline errors
Read this section if you experience any of the following issues:
- Avatar does not speak
- Session dies unexpectedly
err.recoverable == False should end the pipeline gracefully as the pipeline is now dead.
PYTHON
Handle startup failures
Read this section if you experience any of the following issues:
- The call never connects
JAVASCRIPT
Check timeouts
Read this section if you experience any of the following issues:
- Avatar suddenly exits a call
- Calls suddenly end after the same number of minutes
- LemonSlice idle timeout (default is 60 seconds). Resets when the avatar is talking.
- LemonSlice GPU timeout (default is 30 minutes. If you regularly have longer calls, please contact support@lemonslice.com)
- Third-party timeouts (e.g. LiveKit or ElevenLabs)
PYTHON
