Ramy
04/12/2025, 11:51 PMVapi Support Bot
04/12/2025, 11:54 PM{{Name}}
variable not being fetched in your workflow.
I noticed that while you're trying to access the variable, I can't help with the exact runtime behavior without logs, but I can definitely help with the configuration issue I spotted in your workflow JSON!
Looking at your workflow configuration, I found the issue! In your apiRequest_1744499802069
node, the target
field is empty in the output properties. This is critical because the target field specifies the name of the output variable that will store the extracted value.
According to the [API Request Task documentation](https://docs.vapi.ai/workflows/tasks/api-request), when defining output values to extract data from an API's JSON response, you need to configure three properties:
- **Key**: The key within the JSON payload to extract (which you have as "Name")
- **Target**: The name of the output variable for the extracted value (which is currently empty)
- **Type**: The data type of the extracted value (which you have as "string")
To fix this issue, you should update your workflow JSON by adding a value to the target
field. For example:
json
"output": {
"type": "object",
"properties": {
"Name": {
"type": "string",
"description": "name of the customer",
"target": "Name" // Add this value
}
}
}
The target
field should match the variable name you want to use in subsequent nodes, which in your case is "Name" since you're trying to use {{ Name }}
in your say node.
Additionally, make sure that:
1. The API is actually returning the expected JSON structure with the "Name" field
2. The variable name in your say node matches exactly (including case sensitivity) with the target variable name
Is there anything else you'd like me to help with regarding your Vapi workflow?
Source:
- [API Request Task](https://docs.vapi.ai/workflows/tasks/api-request)Ramy
04/12/2025, 11:58 PMVapi Support Bot
04/13/2025, 12:00 AMjson
"output": {
"type": "object",
"properties": {
"Name": {
"type": "string",
"description": "name of the customer",
"target": "Name" // This is what was missing in your configuration
}
}
}
## Expected JSON Format
The expected JSON structure for API responses in Vapi should follow this format:
json
{
"results": [
{
"toolCallId": "X",
"result": "Y"
}
]
}
Where:
- The result
field should be a valid JSON string without line breaks
- If you need to include line breaks in your response, use the escape sequence \\n
For example:
json
{
"results": [
{
"toolCallId": "call_EPeJcpGomST5L4XEwR85tCy4",
"result": "Unfortunately, that time isn't available. How about one of these instead?\\n9:00 AM\\n12:30 PM\\n2:30 PM"
}
]
}
## Using JSON Schema Validation
For more complex structures, you can use JSON schema validation to define the expected structure:
1. Use the structuredDataSchema
property within the analysisPlan
of the assistantOverrides
object:
```json
"assistantOverrides": {
"analysisPlan": {
"structuredDataSchema": {
"type": "object",
"properties": {Vapi Support Bot
04/13/2025, 12:00 AMfield1
(a string) and field2
(a number), both of which are required.
## Important Formatting Notes
- JSON responses need to be stringified
- The response should be a string without line breaks
- Line breaks within strings should be represented by the escape sequence \\n
- Avoid nested JSON in the result
field
Would you like me to explain any specific aspect of defining the expected JSON structure in more detail?
Sources:
- [API Request Task](https://docs.vapi.ai/workflows/tasks/api-request)
- [Discord Thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1334658296291921920)
- [Discord Thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1329542939160084624)
- [Discord Thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336548894896816222)Ramy
04/13/2025, 12:20 AMVapi Support Bot
04/13/2025, 12:20 AMjson
{
"results": [
{
"toolCallId": "X",
"result": "Y"
}
]
}
Where:
- The result
field should be a valid JSON string without line breaks
- If you need to include line breaks, use the escape sequence \\n
This format is mentioned in several sources, including [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1329542939160084624) where it's specified that "the expected JSON structure should be a string format, such as `{\"results\": [{\"toolCallId\": \"X\", \"result\": \"Y\"}]}`" and that "the result
field should be a valid JSON string without line breaks."
Would you like me to provide more details about any specific aspect of the API response format?
Source:
- [Discord Thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1329542939160084624)Ramy
04/13/2025, 12:33 AMVapi Support Bot
04/13/2025, 12:34 AMresult
field should specifically contain the variable from your workflow API request.
What I can tell you is that according to the documentation, the expected JSON structure for API responses in Vapi workflows should follow this format:
json
{
"results": [
{
"toolCallId": "X",
"result": "Y"
}
]
}
Where the result
field should be a valid JSON string without line breaks. This is mentioned in [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1329542939160084624) where it's specified that "the expected JSON structure should be a string format" and "the result
field should be a valid JSON string without line breaks."
The documentation doesn't explicitly state that the variable from your workflow API request must be placed in the result
field, but this is the standard format for returning data from API calls in Vapi workflows.
Is there something specific about your use case that you're trying to implement with the API request variable?
Source:
- [Discord Thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1329542939160084624)Ramy
04/13/2025, 12:34 AMKyle Brunker
04/14/2025, 1:06 PM