metadata from assistant to tool function
# support
j
I'm passing metadat to my assistant metadata.sessionId. I want vapi to call a tool that uses this sessionId as a parameter. 100% of the time the tool function is called with a random value, how do i force it to use the sessionId from the metadata? One Example: • Call ID: 90c7ccfb-9d00-4b75-b75d-97c74822a3d6 • Timestamp: 1746309515839 • Expected Response
Copy code
{
  "role": "tool_calls",
  "time": 1746309515839,
  "message": "",
  "toolCalls": [
    {
      "id": "1746309515838-9g1zeofn3",
      "type": "function",
      "function": {
        "name": "onboarding_name",
        "arguments": "{\"firstName\": \"Jason\", \"sessionId\": \"9ebd66bc-d6cd-4ffc-bee6-2a152c638892\"}"
      }
    }
  ],
  "secondsFromStart": 14.17
}
• Recieved Response:
Copy code
{
  "role": "tool_calls",
  "time": 1746309515839,
  "message": "",
  "toolCalls": [
    {
      "id": "1746309515838-9g1zeofn3",
      "type": "function",
      "function": {
        "name": "onboarding_name",
        "arguments": "{\"firstName\": \"Jason\", \"sessionId\": \"789\"}"
      }
    }
  ],
  "secondsFromStart": 14.17
}
Tool Config:
Copy code
{
  "id": "c51c3cbc-720c-4665-8e41-02213a910689",
  "createdAt": "2025-05-03T14:21:24.224Z",
  "updatedAt": "2025-05-03T22:01:25.388Z",
  "type": "function",
  "function": {
    "name": "onboarding_name",
    "strict": false,
    "description": "passes the user's name and sessionId to the homepage",
    "parameters": {
      "type": "object",
      "properties": {
        "firstName": {
          "description": "User's first name",
          "type": "string"
        },
        "sessionId": {
          "description": "Session identifier",
          "type": "string"
        }
      },
      "required": [
        "firstName"
      ]
    }
  },
  "messages": [
    {
      "type": "request-start",
      "content": "",
      "blocking": false
    }
  ],
  "orgId": "7d9d27d3-e3a7-4f11-b129-81f322f27766",
  "server": {
    "url": "https://mitissa.vercel.app/api/webhook",
    "headers": {}
  },
  "async": false
}
v
Try using the
assistantOverrides
parameter with
variableValues
when initializing your Vapi instance:
Copy code
javascript
vapiInstance = vapiSDK.run({
  apiKey: apiKey,
  assistant: assistant,
  config: buttonConfig,
  assistantOverrides: {
    variableValues: {
      sessionId: "9ebd66bc-d6cd-4ffc-bee6-2a152c638892"
    }
  }
});
This explicitly passes your sessionId as a variable that can be accessed by your tool function. Source: - [Discord discussion about passing data to webhooks](https://discord.com/channels/1211482211119796234/1339495894801711186)
j
I applied the override but it still adds random values to the tool params
@Vapi Support Bot
v
Check your assistant's configuration to ensure the variable is properly defined. Gather the Call ID and check the logs in the Vapi dashboard (logs > calls) to see how the variable is being processed:
Copy code
javascript
// Also verify the variable name matches exactly in both places
console.log("Debugging sessionId variable:", {
  providedInOverrides: "9ebd66bc-d6cd-4ffc-bee6-2a152c638892",
  receivedInTool: "789" // The random value you're seeing
});
If the issue persists, contact Vapi support with your Call ID for in-depth investigation. Source: - [Discord discussion about debugging tool calls](https://discord.com/channels/1211482211119796234/1340404440892444742)
j
the fix was to include my variables in my prompt as so {{sessionId}}
c
checking if this is resolved/solved for you?
j
yeah its resolved now
c
Marking this ticket as Solved ✅