#How can I calls tools using client tools and agent websocket ?
1 messages · Page 1 of 1 (latest)
To call tools using client tools and the agent WebSocket, you can set up a WebSocket connection to interact with your agent and trigger tool calls. Here's how you can approach this:
-
WebSocket Endpoint: Use the WebSocket endpoint provided for your agent. For example:
wss://api.elevenlabs.io/v1/convai/conversation?agent_id=<your-agent-id>Replace
<your-agent-id>with the actual ID of your agent. -
Tool Invocation: Tools can be invoked by sending specific events or parameters through the WebSocket. You can configure the tool to handle certain events or pass custom parameters during the session initialization.
-
Example Setup: If you're using a platform like Twilio, you can set up a WebSocket connection with custom parameters to override tools or prompts. Here's an example in Node.js:
const express = require('express'); const VoiceResponse = require('twilio').twiml.VoiceResponse; const app = express(); app.post('/call/incoming', (req, res) => { const twiml = new VoiceResponse(); const customPrompt = 'Welcome to our service. How can I assist you today?'; twiml.say(customPrompt); twiml.connect().stream({ url: `wss://${process.env.SERVER_DOMAIN}/call/connection`, parameters: { toolOverrides: JSON.stringify({ agent: { prompt: { prompt: customPrompt, }, first_message: 'Hello, this is a custom message.', }, }), }, }); res.writeHead(200, { 'Content-Type': 'text/xml' }); res.end(twiml.toString()); }); app.listen(3000, () => { console.log('Server is running on port 3000'); });Replace
process.env.SERVER_DOMAINwith your actual server domain. -
Client Tool Setup: If you're using a client tool, ensure that the tool is configured to intercept specific events (e.g.,
client_tool_call) and take action on the backend. This allows you to handle tool calls without triggering a webhook. -
Testing: Test the setup by initiating calls and verifying that the tool is invoked correctly. You can use conversation IDs and timestamps to debug any issues.
Let me know if you need further clarification or assistance!
The name of my tool is logMessage how do I invoke it on your example ?
The provided context does not include specific instructions or examples for invoking tools like logMessage using client tools or an agent WebSocket. If you need detailed guidance, please provide more information or consult the relevant documentation or support team for assistance.
logMessage is an example of client tool that has been setup on the elevenlabs agent,
how do I invoke a client tool in your example above ?