Also see the Conversational AI
overview
Installation
Install the package in your project through package manager.Usage
useConversation
React hook for managing websocket connection and audio usage for ElevenLabs Conversational AI.Initialize conversation
First, initialize the Conversation instance.Options
The Conversation can be initialized with certain options. Those are all optional.- onConnect - handler called when the conversation websocket connection is established.
- onDisconnect - handler called when the conversation websocket connection is ended.
- onMessage - handler called when a new message is received. These can be tentative or final transcriptions of user voice, replies produced by LLM, or debug message when a debug option is enabled.
- onError - handler called when a error is encountered.
Methods
startConversation
startConversation
method kick off the websocket connection and starts using microphone to communicate with the ElevenLabs Conversational AI agent.The method accepts options object, with the
url
or agentId
option being required.
Agent ID can be acquired through ElevenLabs UI and is always necessary.
agentId
- no signed link generation necessary.
In case the conversation requires authorization, use the REST API to generate signed links. Use the signed link as a url
parameter.
startSession
returns promise resolving to conversationId
. The value is a globally unique conversation ID you can use to identify separate conversations.