frail-apricot
frail-apricot4d ago

Dynamic Variables from API Request Tool Not Rendering in System Prompt After Successful Tool Call

I'm experiencing an issue with dynamic variables not being properly rendered in my system prompt after a successful apiRequest tool call. I use the dashboard. I've thoroughly debugged the issue and would appreciate your assistance. Issue Details: - I've configured an API request tool that returns data including fields like date, dayOfWeek etc. - I've mapped these responses to dynamic variables in the tool configuration in response body. See attached images. the Response Body is auto generated when I test the tool call using "Save Schema" - When I check the call logs, I can see the tool call executes successfully - However, the system prompt is not being re-rendered with the populated variables (I checked the model Azure OpenAI HTTP request -> attributes.request.messages) - All variable references (e.g., {{data.dayOfWeek}}, {{data}}) are being replaced with empty strings even after the tool call completes Debugging Steps Taken: - Verified the API request tool is executing successfully in the call logs - Confirmed the API is returning the expected data structure - Added debug statements to the system prompt to check variable rendering - Verified that built-in variables like {{now}} are rendering correctly - Checked multiple conversation turns after the tool call completes - Examined the model requests that occur after the tool call in the call logs and latest model request in the call Am I debugging it wrong? What's the best way to debug it? Additional Information: - Assistant ID: bc4d9f7f-01f2-4370-9604-f77f684fe1a1 - Call ID for reference: 019ae217-d360-7000-8095-7dd4bc00798d I would greatly appreciate your help in resolving this issue. Please let me know if you need any additional information.
No description
6 Replies
Vapi Support Bot
Suggestion:
Double-check that your API response structure exactly matches the variable extraction schema in your tool configuration. For example, if your response is:
{
"data": {
"dayOfWeek": "Monday"
},
"success": true,
"timestamp": "2025-12-03T04:45:36Z"
}
{
"data": {
"dayOfWeek": "Monday"
},
"success": true,
"timestamp": "2025-12-03T04:45:36Z"
}
then reference the variable in your prompt as {{data.dayOfWeek}}. If the structure or key names differ, the variable will not populate—ensure both the API response and the extraction schema are in sync as shown in the dynamic variables documentation. Source: - Dynamic Variables documentation
⤵️ Mention @Vapi Support Bot for follow-ups 🐥
frail-apricot
frail-apricotOP4d ago
Response (taken from the call logs > Tool):
{
"id": "log-43",
"level": 30,
"time": 1764729819473,
"timestamp": 1764729819473000000,
"severityText": "INFO",
"severityNumber": 9,
"body": "Tool calls finished",
"attributes": {
"category": "tool",
"callId": "019ae217-d360-7000-8095-7dd4bc00798d",
"orgId": "87126cb3-1bd3-4e51-b782-1958b6307b99",
"runDurationMs": 433,
"totalResults": 1,
"errorsCount": 0,
"results": [
{
"name": "getCurrentTime",
"toolCallId": "call_BkoNSi8jaazzRTNQxVaizejU",
"type": "apiRequest",
"result": "{\n \"success\": true,\n \"data\": {\n \"dayOfWeek\": \"Wednesday\",\n \"date\": 3,\n \"month\": \"December\",\n \"year\": 2025,\n \"time\": \"12:43 PM\",\n \"timezone\": \"Australia/Brisbane\",\n \"locationName\": \"xxx\",\n \"isOpen\": true\n },\n \"timestamp\": \"2025-12-03T02:43:39.317Z\"\n}",
"metadata": {
"responseBody": {
"success": true,
"data": {
"dayOfWeek": "Wednesday",
"date": 3,
"month": "December",
"year": 2025,
"time": "12:43 PM",
"timezone": "Australia/Brisbane",
"locationName": "xxx",
"isOpen": true
},
"timestamp": "2025-12-03T02:43:39.317Z"
},
"responseHeaders": {
"access-control-allow-credentials": "true",
"access-control-allow-origin": "https://corsproxy.io",
"content-length": "216",
"content-type": "application/json; charset=utf-8",
"date": "Wed, 03 Dec 2025 02:43:39 GMT",
"etag": "W/\"d8-hEUgU1Rhslk80+l5GAw/87Rzs44\"",
"ngrok-agent-ips": "2406:2d40:39e6:b708:799c:e6e2:504b:d3f2",
"vary": "Origin",
"x-powered-by": "Express"
}
}
}
]
}
}
{
"id": "log-43",
"level": 30,
"time": 1764729819473,
"timestamp": 1764729819473000000,
"severityText": "INFO",
"severityNumber": 9,
"body": "Tool calls finished",
"attributes": {
"category": "tool",
"callId": "019ae217-d360-7000-8095-7dd4bc00798d",
"orgId": "87126cb3-1bd3-4e51-b782-1958b6307b99",
"runDurationMs": 433,
"totalResults": 1,
"errorsCount": 0,
"results": [
{
"name": "getCurrentTime",
"toolCallId": "call_BkoNSi8jaazzRTNQxVaizejU",
"type": "apiRequest",
"result": "{\n \"success\": true,\n \"data\": {\n \"dayOfWeek\": \"Wednesday\",\n \"date\": 3,\n \"month\": \"December\",\n \"year\": 2025,\n \"time\": \"12:43 PM\",\n \"timezone\": \"Australia/Brisbane\",\n \"locationName\": \"xxx\",\n \"isOpen\": true\n },\n \"timestamp\": \"2025-12-03T02:43:39.317Z\"\n}",
"metadata": {
"responseBody": {
"success": true,
"data": {
"dayOfWeek": "Wednesday",
"date": 3,
"month": "December",
"year": 2025,
"time": "12:43 PM",
"timezone": "Australia/Brisbane",
"locationName": "xxx",
"isOpen": true
},
"timestamp": "2025-12-03T02:43:39.317Z"
},
"responseHeaders": {
"access-control-allow-credentials": "true",
"access-control-allow-origin": "https://corsproxy.io",
"content-length": "216",
"content-type": "application/json; charset=utf-8",
"date": "Wed, 03 Dec 2025 02:43:39 GMT",
"etag": "W/\"d8-hEUgU1Rhslk80+l5GAw/87Rzs44\"",
"ngrok-agent-ips": "2406:2d40:39e6:b708:799c:e6e2:504b:d3f2",
"vary": "Origin",
"x-powered-by": "Express"
}
}
}
]
}
}
@Vapi Support Bot
Vapi Support Bot
Suggestion:
Double-check that your system prompt references the variable using the exact path, like {{data.dayOfWeek}}, and that the prompt is updated after the tool call completes. For example:
Today is {{data.dayOfWeek}} in {{data.locationName}}.
Today is {{data.dayOfWeek}} in {{data.locationName}}.
If the prompt is set before the tool call, it won't have access to the new variable values—ensure the prompt is refreshed or re-evaluated after the tool call as described in the dynamic variables documentation. Source: - Dynamic Variables documentation
quickest-silver
quickest-silver3d ago
Hi! I can help troubleshoot why your dynamic variables aren’t rendering in the system prompt. Your API call is working, but references like {{data.dayOfWeek}} remain empty, which often happens if variable mappings aren’t properly linked or the system prompt accesses them before the tool call completes. A key check: are you using the variables in the same turn as the tool call or a later one? I can guide you step-by-step to verify mappings, ensure the prompt updates correctly, and make sure your dynamic data populates as expected. Can you confirm whether you’re referencing the variables immediately or in a following turn? @nfs-avn
wise-white
wise-white2d ago
You can also use dynamic variables to get the current date/time. The whole list is right here: https://docs.vapi.ai/assistants/dynamic-variables#default-variables
Variables | Vapi
Personalize assistant messages with dynamic and default variables
frail-apricot
frail-apricotOP2d ago

Did you find this page helpful?