Preferred method for variable storage?
# support
b
Hi - Inbound calls I would like to capture return values from webhooks and utilize them in the flow. I have had inconsistent results and have tried both comment blocks and an array of results. Without a spoken value, the assistant does not appear to be able to return the value of say an internal ID in analysis or structured data.
v
Hi there! 👋 I understand you're having trouble with variable storage in Vapi flows, particularly when capturing webhook return values. While I don't have specific information about using comment blocks for variable storage, I can definitely help with the other aspects of your question. Based on the information I found, here are some recommendations: ## Current Status of Blocks in Vapi First, it's important to note that Vapi Blocks are currently in beta and not production-ready, which may explain your inconsistent results. According to [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1339365599268311202), "Blocks are not production ready yet" and are "in beta so you can expect few hiccups." ## Recommended Approach Instead of using blocks, it's suggested to use assistants with prompts until blocks become more stable. According to [Discord feedback](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1339094322078814258), this is a more reliable approach. ## Using Dynamic Variables For storing and accessing variables, including internal IDs, the recommended approach is using
assistantOverrides
with
variableValues
. Here's how:
Copy code
json
{
  "assistantId": "your-assistant-id",
  "assistantOverrides": {
    "variableValues": {
      "internalId": "12345",
      "otherVariable": "value"
    }
  },
  "customer": {
    "number": "+1xxxxxxxxxx"
  },
  "phoneNumberId": "your-phone-id"
}
According to the [dynamic variables documentation](https://docs.vapi.ai/assistants/dynamic-variables), you'll need to add
{{variableName}}
in your prompts where you want to use the variable. ## For Inbound Calls Specifically For inbound calls, consider using the
rolling-history
transfer mode to preserve data. According to [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341910696182681613), this approach: - Preserves conversation history
- Eliminates the need to modify variable values mid-call - Keeps information in context - Is more reliable than updating variables during runtime ## Troubleshooting Webhook Issues If you're still experiencing issues with webhooks, ensure: 1. The webhook URL is correctly configured 2. JSON responses are properly formatted 3. The content-type is set to
application/json
4. Variable names in API requests match what the Vapi assistant expects Is there anything specific about these approaches you'd like me to elaborate on? Sources: - [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1339365599268311202) - [Discord feedback](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1339094322078814258) - [dynamic variables documentation](https://docs.vapi.ai/assistants/dynamic-variables) - [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341910696182681613)
b
can I supply a system prompt to return the value of a tool call?
k
Make sure your webhook responses are correctly structured and parsed, like responses should be in JSON format containing a results array with tool call id..
b
comment version:
Copy code
json
    {
  "results": [
    {
      "toolCallId": "call_2QjXTP9nWMxA24SiDvzAVnWU",
      "result": {
        "message": "Your appointment with our expert has been successfully scheduled for: Tuesday, April 15th 2025 at 10:00 AM - 1:00 PM <!--customer_id:cus_ee81504473994fdbbaff7ea36a47cf81; job_id:job_90837ec74de749888d0697ff0d4b357a; is_vip:false; phone_number:+xxxxxxx-->"
      }
    }
  ]
}
without comments:
Copy code
json
{
  "results": [
      {
          "toolCallId": "call_seYBT2eMQPHuQ6dZ445JMjEl",
          "result": {
              "message": "Your appointment with our expert has been successfully scheduled for: Tuesday, April 15th 2025 at 10:00",
              "job_id": "job_90837ec74de749888d0697ff0d4b357a",
              "is_vip": false,
              "customer_id": "cus_ee81504473994fdbbaff7ea36a47cf81",
              "phone_number": "+xxxxxxx"
          }
      }
  ]
}
The webhook works fine. All functionality except for extracting the return value of
customer_id
in
structured data
or
analysis
is this recommended? I have had limited success with it
Copy code
- Return values:
  - job_id: The internal job ID for the created appointment
  - estimate_id: The ID of the estimate if created
  - customer_id: Customer ID in the system
Hi - any update on this?
@Vapi Support Bot any update or further troubleshooting I can do?
s
I see, we don't have any way of it for now. But, can you add it to our roadmap? https://roadmap.vapi.ai/
2 Views