#Using the JavaScript `@11labs/client` SDK, when I create a `Conversation` using `startSession`, how
1 messages · Page 1 of 1 (latest)
In the JavaScript @11labs/client SDK, once you have initialized a Conversation using startSession, you can handle messages through the optional callbacks provided in the session configuration. However, the SDK does not directly expose a method to send messages like you would with a raw WebSocket connection.
Instead, you can use the onMessage callback to handle incoming messages, which can include transcriptions of user voice or replies from the AI agent. Here's an example of how you might set up these callbacks:
const conversation = await Conversation.startSession({
agentId: "<your-agent-id>",
onMessage: (message) => {
console.log("Received message:", message);
},
onError: (error) => {
console.error("Error:", error);
}
});
If you need to send specific data to the server, you would typically handle this through the API or other methods provided by the SDK, rather than directly sending messages over the WebSocket.
I can read the basic examples your documentation provides, but how do I send this data back to the session? I know how to console.log a result
The @11labs/client SDK primarily handles the communication with the ElevenLabs Conversational AI agent through the Conversation instance. However, the SDK does not provide a direct method to send custom messages back to the session like you would with a standard WebSocket send method.
The interaction with the agent is typically managed through the SDK's built-in methods and callbacks, such as handling received messages with the onMessage callback. If you need to send specific data or context to the agent, you might need to incorporate it into the initial setup or use the knowledge base and system prompt customization options available for the agent.
If you have specific requirements or need further customization, you might consider exploring the SDK's documentation for any advanced features or reach out to the support team for more detailed guidance.
🥴 🔫
The @11labs/client SDK primarily handles the initialization and management of a conversation session. However, it does not directly provide a method to send messages back to the session like you would with a raw WebSocket connection.
To interact with the session, you typically use the provided callbacks such as onMessage to handle incoming messages. If you need to send data back, you would generally handle this through the logic of your application, possibly by interacting with the ElevenLabs API or another service that processes and responds to the conversation.
If you have specific requirements or need further assistance, please provide more details about what you're trying to achieve, and I'll do my best to help!
So, we cannot send custom text based messages to the AI/LLM? This will let us make even better tools around the conversational ai