Setting Tools to async
# support
d
Hey Sahil, I'm trying to understand the data structure for setting tools to async when creating an (ephemeral) assistant. I'm doing this because currently the agent's behavior when firing the tool is inconsistent and weird, sometimes it gives a response AND fires the tool, sometimes it just says "one sec" and fires the tool (which is not the desired behavior). I have the tools created in my VAPI account and I'm just passing the tool ID's to the agent when I create it. So I'm not sure if I'm supposed to set the async property at the agent level or if I need to somehow set it on all the tools I'm passing with ID's. Here is the payload below that I'm trying to use. This currently gives me a 404 error when I include 'tools: [{ async: true }]'. 1. I'm const newAgent = { name: agent.name, image: agent.image, description: agent.description, payload: { ...setup, firstMessage: agent.firstMessage, name: agent.name, model: { ...setup.model, toolIds: agent.toolIds, messages: [ { content: agent.systemMessage, role: "system", }, ], tools: [{ async: true }], }, endCallFunctionEnabled: agent.endCallFunctionEnabled, transcriber: { ...setup.transcriber, language: agent.language }, voice: { provider: agent.voiceEngine, voiceId: agent.voiceId }, // filler_words: true, analysisPlan: { summaryPrompt:
My summary prompt
, summaryRequestTimeoutSeconds: 10.5, successEvaluationRubric: "AutomaticRubric", }, serverMessages: ["end-of-call-report", "hang"], serverUrl: "https://roley.ai/api/end-of-call-report", }, };
In the documentation I see this but I don't understand what the messages parameter is for underneath tools. "tools":[ { "async":true, "messages":[ { "type":"request-start", "content":"", "conditions":[ { "param":"", "value":"", "operator":"eq" } ] } ],
v
@danemyers Hello! It seems like you're trying to set the
async
property for the tools in your VAPI agent configuration. The
async
property should be set for each individual tool within the
tools
array, rather than at the agent level or as a separate array. Each tool in the
tools
array should have its own configuration, including whether it operates asynchronously. However, if you're receiving a 404 error, it might not be related to the
async
property itself but rather to how you're structuring your payload or an issue with the endpoint you're trying to reach. To set the
async
property correctly, you should include it within the configuration of each tool. Here's an example of how you might structure the
tools
array with the
async
property:
Copy code
javascript
tools: [
  {
    toolId: 'your-tool-id-1',
    async: true
  },
  {
    toolId: 'your-tool-id-2',
    async: true
  }
  // ... other tools
]
Make sure that each tool's configuration is an object with at least the
toolId
and
async
properties. If the
async
property is not recognized at the tool level, it's possible that the VAPI platform you're using does not support this configuration, or it may require a different approach. If you continue to experience issues, please ask support for more info on this. They can provide you with the correct structure for your payload and help troubleshoot the 404 error you're encountering.
You can continue this conversation by mentioning me in the message.
d
Hmm, is this correct? This looks like a different structure than in the documentation
s
Can you send me one call_id along with the timestamp when you tried to trigger the function call?
It is also correct, but for now, use this documentation https://docs.vapi.ai/tools-calling
d
7a362dc7-ac3f-4a84-9d69-00bb0f7a96db 28 seconds
Ohhhh I think I can just patch all of my tools to have this async: true and then just continue to include them the way I am
4 Views