How to access and forward callId from API tools an...
# support
k
VAPI Assistant - I'm trying to find a reliable way to use a unique callId to correlate all tool calls within the same Vapi call session - in API tools and custom function tools. Better if dynamic variable available. In the logs => Tool category => I can see the callId in the attributes property, but not sure how can I use it. Didn't find anything useful Community thread - https://vapi.ai/community/m/1381689099240472586?utm_source=chatgpt.com Dynamic variable - https://docs.vapi.ai/assistants/dynamic-variables#default-variables
m
You can use the callId to track all tool calls within the same VAPI session. In API and Custom Function tools, access it dynamically with {{call.id}}, so every tool call automatically references the same session. This helps with both logging and correlating actions across tools. To give more targeted advice, do you want this mainly for monitoring or also for passing the callId between tools during processing? @kannas1905
k
Thanks @Manja manna I’ve already tried that — {{call.id}} isn’t available in the VAPI assistant prompt or in the API tool. I need this value as a correlation ID, because I want to pass it as a parameter to my external webhooks (via the VAPI API Tool). This will let me tag and persist some memory data against the call.
m
Thanks for the update — now I see the exact issue. VAPI doesn’t expose {{call.id}} inside the prompt or API tool yet, so the correlation ID can’t be passed directly to your webhook. The workaround is to generate and persist a custom session ID at the start of each call, and I can help you set that up smoothly. If you want, we can continue the details privately and map out the best flow for your use case. @kannas1905
c
Hi kannas1905, To access the call ID within an API request tool, you can utilize the setup provided by Vapi's [integration with tools](https://docs.vapi.ai/tools). When configuring your assistant's model, ensure that you include the necessary context variables or metadata that expose call details, such as the call ID, which can be passed to your tools. This setup usually involves defining the appropriate placeholders or configurations in your API request settings. If you are using the SDK, you can retrieve call details using client methods such as
client.calls.list()
, providing you specify filters or conditions to get the specific call you're interested in. If you need further details on API tools, you can review the API reference [here](https://docs.vapi.ai/api-reference/tools/get).