How to pass default dynamic variable as part of bo...
# support
v
Hi there! 👋 I understand you're having trouble passing the
{{customer.number}}
variable in your API node body. While I can't pinpoint the exact cause of the empty string you're receiving, I can definitely help with how to correctly pass this variable. Here's how to correctly pass the
{{customer.number}}
variable in the API node body: ## Correct Format and Syntax The
{{customer.number}}
is indeed a default dynamic variable in Vapi that represents the customer's phone number. It should be in E.164 format (e.g., +14155551234) with the + prefix [Source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342514332604432424). ## Passing the Variable Correctly There are a few approaches to ensure the variable is passed correctly: 1. **Using
assistantOverrides
with `variableValues`**:
Copy code
json
   {
     "assistantId": "your-assistant-id",
     "assistantOverrides": {
       "variableValues": {
         "customer.number": "+1xxxxxxxxxx"
       }
     },
     "customer": {
       "number": "+1xxxxxxxxxx"
     },
     "phoneNumberId": "your-phone-id"
   }
[Source](https://docs.vapi.ai/assistants/dynamic-variables) 2. **Setting the customer field when creating a call**:
Copy code
javascript
   const call = await vapiClient.calls.create({
     phoneNumberId: "your-phone-number-id",
     customer: {
       number: "+1234567890", // Customer's phone number
       name: "John Doe",      // Optional customer name
       metadata: {}           // Optional metadata about the customer
     },
     assistant: {
       // Your assistant configuration
     }
   });
[Source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341835905656291369) ## Troubleshooting Steps If you're still receiving an empty string, try these troubleshooting steps:
1. **Check variable availability**: Ensure the
customer.number
variable is available at the time the prompt is being generated [Source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336772166330351646). 2. **Verify syntax**: Double-check that the dynamic variable is correctly named and that the syntax matches the documentation [Source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336772166330351646). 3. **Check execution order**: Make sure that the block which sets the variable is executed before the block that needs to use it [Source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1315677399026765855). 4. **Verify format**: Confirm that the format of
{{customer.number}}
matches what VAPI expects (E.164 format) [Source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1325856450391834817). Is there any additional information you can share about your setup that might help me provide more specific guidance? Sources: - [Discord Thread about customer.number format](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342514332604432424) - [Vapi Documentation on Dynamic Variables](https://docs.vapi.ai/assistants/dynamic-variables) - [Discord Thread about creating calls with customer information](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341835905656291369) - [Discord Thread about variable availability](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336772166330351646) - [Discord Thread about execution order](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1315677399026765855) - [Discord Thread about troubleshooting variable passing](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1325856450391834817)
g
I have the same problem with any default variable. I just tried out sending {{now}} variable and received empty string on my back-end as well. Just so you know, I make tests making web-calls in dashboard.
@Vapi I have the same problem with any default variable. I just tried out sending {{now}} variable and received empty string on my back-end as well. Just so you know, I make tests making web-calls in dashboard.
a
Hey! To help track down this issue, could you share: - The call ID - What response you expected to get - What response you actually got instead This would really help us figure out what went wrong!
g
There is no call ID, it's a general question on how to use default dynamic variables. It's not a report, it's a question.
@User any help would be much appreciated
a
Hey, can you share the call ID where you are getting it empty on your back end because by default, it must include the customer number.
You are using it correctly, what I want to confirm is if we are sending those variables correctly even when you use them directly inside the request node.
g
4f15a777-0885-4b89-b752-5eb53b89bdda
a
Hey Gorgeous Puree, allow me some time to get back to you with an investigation and resolution.
g
Thank you! It's a major blocker which does not allow allow us to use the platform.
a
Vapi DOES convert dynamic variables like {{customer.number}} to their actual values when used in API request nodes. The empty values you're seeing are due to an API error response preventing successful data transmission. 1\. The API request node is correctly interpolating the dynamic variables (\`{{customer.number}}\` and
{{now}}
) 2\. The request is sent to your endpoint (\`) 3\. However, the response from the endpoint is a plain text error ("Error in workflow") rather than valid JSON 4\. The workflow expects a JSON response and fails when trying to parse the text response The error occurs in the
ApiRequestStream
class when trying to parse the response with
response.json()
, which expects valid JSON but receives text instead. To fix this: 1\. Make sure your API endpoint returns valid JSON responses, even for errors 2\. Alternatively, configure your API endpoint to handle the format being sent correctly 3\. Check your pipedream webhook configuration to ensure it's expecting the correct format If you want to test if variables are being correctly substituted: 1\. Set up a simple echo API endpoint that returns the received request body as JSON 2\. This will let you confirm the variables are being correctly interpolated
Gorgeous Puree, let me know if you require further help or have more questions. I'm happy to help and contribute on using Workflows.
g
Wow that's a huge response, thank you. I will check and get back to you.
a
Hi, checking if this is resolved/solved for you?
g
Hi @Shubham Bajaj Didn't have to check it out yet. I'll get back to it
k
Alright
g
Sorry guys, please don't close this ticket. I will come back to this, just have other urgent tasks
k
No problem
g
Hi! @Kings_big💫 Even though the backend responded with "Error in workflow", I don't see how it's connected to Vapi sending empty parameters in body? How does API error response prevent receiving parameters in the request? I tried another backend and still received empty strings. Could you clarify the way I am sending params in API node is correct? https://cdn.discordapp.com/attachments/1355981001930576142/1362293666085077166/image.png?ex=6801de58&is=68008cd8&hm=312bf3a1bbed83b150114e36a3acd793f92fa5180da1e69202ed45b203b76107& https://cdn.discordapp.com/attachments/1355981001930576142/1362293666361638942/image.png?ex=6801de58&is=68008cd8&hm=34422da8a795a2e69371a85f66a80c2e2f00738f941436617e8cfd713a87bd15&
any ideas?
k
Your API parameters might be empty because the template variables (
{{now}}
,
{{customer.number}}
) aren't resolving, verify the correct variable names, test with hardcoded values first, and ensure the API node is placed after the data is generated in your workflow. The backend error is likely separate from the empty parameter issue.
4 Views