variable values to tool call
# support
p
when the assistant makes the tool call it has to pass the values to the tool call that we provided in assistantOverrides. variableValues. Sometimes its sending parameter A's values to Parameter B. Mostly it works properly. but this happens intermittently. how to pass values to tool calls
v
Hi there! 👋 I understand you're experiencing an intermittent issue where variable values are sometimes being incorrectly assigned between parameters in tool calls. While I can't pinpoint the exact cause of this specific intermittent behavior, I can definitely help with best practices and troubleshooting steps. ## How to Correctly Pass Values to Tool Calls To correctly pass variable values to tool calls using
assistantOverrides
, follow these best practices: ### 1. Use the Correct Syntax for Variable Interpolation Make sure you're using the proper syntax when referencing variables in tool calls:
Copy code
json
{
  "body": {
    "message": {
      "toolCalls": [
        {
          "function": {
            "name": "send_to_endpoint",
            "arguments": {
              "mc_number": "{{mc_verification.output.mc_number}}"
            }
          }
        }
      ]
    }
  }
}
### 2. Structure Your
assistantOverrides
Correctly When setting up your
assistantOverrides
with
variableValues
, use this structure:
Copy code
javascript
const assistantOverrides = {  
  variableValues: {  
    name: "Alice",  
  },  
};

vapi.start("your-assistant-id", assistantOverrides);
According to [Vapi's documentation on dynamic variables](https://docs.vapi.ai/assistants/dynamic-variables), dynamic variables are defined using double curly braces
{{variableName}}
and must be added in this format in all your prompts. ## Debugging Strategies If you're still experiencing issues, try these debugging approaches: 1. **Check Variable Names and Syntax**: Ensure variable names in
variableValues
exactly match those expected by the assistant. 2. **Review Execution Order and Variable Scope**: Make sure the block setting the variable executes before the block using it, and that variables are in the correct scope. 3. **Examine Call Logs**: Look into logs associated with the call ID to diagnose the issue further.
4. **Check Assistant Configuration**: Double-check your assistant's setup to ensure it's designed to accept and use dynamic variables correctly. 5. **Review Tool Configuration**: Ensure your tool is properly configured and not framing parameters incorrectly. ## Potential Causes According to information from Vapi's community discussions, this intermittent behavior could be due to: 1. A timing issue where the template engine isn't processing variables before the first call is made. 2. Mismatched variable names between
variableValues
and the assistant's configuration. 3. Issues with synchronous execution if the order of operations is important. Is there anything specific about your implementation that you'd like me to help troubleshoot further? Source: - [Vapi's documentation on dynamic variables](https://docs.vapi.ai/assistants/dynamic-variables)
k
Hey! To help track down this issue, could you share: - The call ID - When exactly this happened (the timestamp) - What response you expected to get - What response you actually got instead This would really help us figure out what went wrong!