API node: values returned from API response cannot...
# support
a
I'm running local server that performs some logic I'm using the VAPI workflows api node to send a post request I added all necessary variables in body part of the API node, and also included all output parameters However, after the API request finishes, assistant does not have the access, or cannot access the variables returned For example, i have a condition node after the api request that uses the variable (is_high_demand) which is boolean and is returned from api call. But the call simply ends when reaching that condition or it passes the condition (which means it can access the is_high_demand variable), but it fails to access the other variables returned from the same API request) I also tested by adding the "say" node after the API node, to see if assistant can at least tell me the new variables, but no success there either. Assistant simply is not saving, or cannot access those variables I checked the local server side, it returns the output values normally and has 200 status, which makes me believe that there are no problem from server side. But I might be wrong Providing the details in screenshots callID is 4b15c558-502e-43a8-9cc8-c3419c18797d Please help me resolve this, its a blocker of the whole process Thank you! https://cdn.discordapp.com/attachments/1357262210329608282/1357262210552037496/Screenshot_2025-04-03_at_4.44.44_PM.png?ex=67ef906f&is=67ee3eef&hm=4ea0391ccba1287fe818040f865c70dfb8df99c5d60e752fc1878bf2046c1186& https://cdn.discordapp.com/attachments/1357262210329608282/1357262210883129446/Screenshot_2025-04-03_at_4.44.58_PM.png?ex=67ef906f&is=67ee3eef&hm=c21425f5ecd668cf159a511db09092e72a16f7d1345f05b6932ebea2cb2fc015& https://cdn.discordapp.com/attachments/1357262210329608282/1357262211143307285/Screenshot_2025-04-03_at_4.55.01_PM.png?ex=67ef906f&is=67ee3eef&hm=d9ceb1a5240bf055bdf552188400b7aaff6658857dc1e6bd1074d8e081a8b399&
v
Hi there! I see you're having trouble accessing the API response values in your VAPI workflow. Let me help troubleshoot this issue! 👨‍💻 I'm unable to provide specific information about your particular callID, but I can definitely help with the general issue of accessing API response values in workflow logic. Based on the screenshots you've shared, I can see you've set up the API request correctly with output parameters, but the values aren't accessible in subsequent nodes. Here are several potential solutions to your problem: ### 1. Check API Response Format One common issue is that VAPI expects API responses in a specific format. According to [documentation](https://docs.vapi.ai/workflows/tasks/api-request), the API response must be in string format, not record or object format. The expected JSON format is:
Copy code
json
{
    "results": [
        {
            "toolCallId": "X", 
            "result": "Y"
        }
    ]
}
Your server might be returning a standard JSON response, but VAPI might be expecting this specific format. ### 2. Verify Output Parameter Configuration Make sure your output parameters are correctly configured in the API Request task: - **Key**: The exact path to the value in the JSON response - **Target**: The variable name you want to use in subsequent nodes - **Type**: The correct data type (boolean, number, etc.) According to the [API Request documentation](https://docs.vapi.ai/workflows/tasks/api-request), these must be precisely defined to extract data from the API's JSON response. ### 3. Check Variable Access Syntax When referencing variables in subsequent nodes, ensure you're using the correct syntax. You might need to use one of these formats: -
message.variableValues.variable_name
-
messages.assistantOverrides.variableValues.variable_name
### 4. Troubleshoot Execution Order and Variable Scope Several factors can affect variable access:
- **Execution Order**: Ensure the API request completes before the condition node tries to access the variables - **Variable Scope**: Confirm the variables are in the correct scope for the nodes trying to use them - **Asynchronous Processing**: Try setting the
async
parameter to
true
in your API request configuration ### 5. Check for Special Characters and Formatting Issues Ensure there are no formatting issues in your JSON response and that special characters are properly escaped. The content-type should be set to
application/json
. ### 6. Test with a Simplified Response Try simplifying your API response to just return one variable (like
is_high_demand
) to see if that works. If it does, gradually add back the other variables to identify which one might be causing issues. Would you like me to elaborate on any of these potential solutions? Or do you have any other questions about accessing API response values in VAPI workflows? Sources: - [API Request documentation](https://docs.vapi.ai/workflows/tasks/api-request) - [Discord thread about API response format](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1329542939160084624) - [Discord thread about accessing variable values](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1329772290497318973) - [Discord thread about troubleshooting variable access](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1315677399026765855) - [Discord thread about asynchronous processing](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1333880245681393756)
a
return new Response(JSON.stringify({ is_high_demand:is_high_demand, high_demand_best_case_price: topPrice * 1.2, high_demand_optimal_case_price: topPrice, low_demand_best_case_price: avgPrice * 1.2, low_demand_optimal_case_price: avgPrice, bare_minimum_order_price: (deadhead + trip) * 2.1, }), { status: 200, headers: { "Content-Type": "application/json", }, }); i am sending the response like above where every field except is_high_demand is float are you saying that it must be string??
@User
s
checking if this is resolved/solved for you?
a
yes, thank you!
s
Marking this ticket as Solved ✅
3 Views