Basic Voice Chat Component
Here’s a complete example of a React component that creates a voice conversation using theuseConversation
hook:
Want to use a different voice? See all available voices you can choose from.
Connection Management
onDisconnect Callback
UseonDisconnect
to handle cleanup when the conversation ends:
onDisconnect
for cleanup logic, not onError
. The onError
callback is called for runtime errors as well, so it’s not ideal for cleanup tasks.
onError Callback
UseonError
specifically for handling errors:
Advanced Features
Event Handling
You can listen to various events during the conversation:Text Input
You can also send text messages programmatically:Mute Control
Control the microphone state by passingmicMuted
prop to useConversation
:
Volume Control
Control the AI’s voice volume by passingvolume
prop to useConversation
(value between 0 and 1):
Complete Example with Error Handling
Here’s a more complete example showing proper error and disconnect handling:Next Steps
- API Reference - Explore all available methods and events
- Starter Templates - See template implementations