How to debug dynamic variables working?
# support
t
Hi, I'm trying to use dynamic variables in an agent's prompt but am running in to some issues. I am trying to debug what the system is actually translating the dynamic variables to, but inspecting the message sent to the server in the call logs seems to show that the dynamic variables are just skipped. In my prompt I have
- The current date time is {{"now" | date: "%b %d, %Y, %I:%M %p", "America/New_York"}}.
which is taken almost directly from the Dynamic Variables docs: https://docs.vapi.ai/assistants/dynamic-variables However, you can see in the screenshot that the message is just
- The current date time is .
I'm running into the same issue trying to transform
customer.number
to make it be spoken more naturally, since the agent frequently starts garbling and saying nonsense or switching to a strange robotic backup voice if it tries to read a phone number straight up. This is the template I'm trying to use for that:
{{customer.number | remove_first: "+1" | split "" | join: ", "}},
. When I tried asking the agent for my number, it made one up entirely, and when I checked the message logs it had the same issue where it appeared no phone number was there. Call ID (immediately hung up, just for seeing the message with missing interpolation):
4cbafbaa-d072-4c13-b9f3-47c51a7890e4
Thank you!
v
@toadilywasted Hello! I'm sorry to hear you're experiencing issues with dynamic variables in your prompts. It seems like there might be a problem with the syntax or the way the system is processing these variables. Let's try to troubleshoot this together. Firstly, for the date and time dynamic variable, the syntax you've used looks correct according to the documentation. However, if it's not being translated properly, there might be an issue with the system's template engine or the way the variable is being passed. For the phone number transformation, the template you're using should theoretically work to format the number in a more natural way for the agent to read. If the agent is making up a number entirely, it could be a sign that the
customer.number
variable isn't being passed correctly or there's a parsing issue. To address these issues, I would recommend the following steps: 1. Double-check that the dynamic variables are correctly named and that the syntax matches the documentation. 2. Ensure that the variables you're trying to use (
now
and
customer.number
) are being passed to the system correctly and are available at the time the prompt is being generated. 3. If the above steps are correct, there might be a need for further investigation by the support team. Since you've provided the Call ID, I can forward this information to the support team for a more in-depth analysis. Would you like me to do that for you?
You can continue this conversation by mentioning me in the message.
Got it. Tagging @User for additional help.
s
@toadilywasted I have looked into your both of variable values to be populated give me some time to check what could have gone wrong, I will get back to you on this with proper RCA.
t
Thank you
s
@toadilywasted Ah, I see what's happening with your dynamic variables! Looking at your prompt, you're trying to use some pretty complex Liquid template expressions for the date and phone number formatting. While these would work great in other contexts, they might be a bit too for what we need here. Let me break down what I think is going on - when you're seeing empty outputs in your logs, it's likely because either the template engine is getting confused by the complex syntax, or the variables aren't making it through the pipeline properly. Here's what I'd suggest to simplify things: For the date/time, instead of:
Copy code
{{"now" | date: "%b %d, %Y, %I:%M %p", "America/New_York"}}
Try the more straightforward:
Copy code
{{now | date: "MMMM D, YYYY h:mm A"}}
And for the phone number, rather than:
Copy code
{{customer.number | remove_first: "+1" | split "" | join: ", "}}
Just use:
Copy code
{{customer.number}}
The reason this should work better is that I can see in our codebase that there are already built-in utilities that handle formatting numbers and dates in a voice-friendly way. You don't need to do the formatting in the template itself - the system will take care of that for you! Give these simpler versions a try and let me know if you're still seeing any issues. We can always dig deeper if needed!
t
I was hoping for the date time that it would be using NY time as that's where the office is located. And for the customer number, unfortunately I noticed that the TTS would start garbling and go crazy spouting weird output if I just had the customer number like that -- or any long number that was spoken. I tried putting stuff in the prompt to make it work better but it was hit or miss. I recognize there are a lot of things going on behind the scenes that us customers can't see so I'm not sure if there are improvements here that I might be unaware of -- is there any public changelogs of tweaks we can keep an eye on?
s
> nd for the customer number, unfortunately I noticed that the TTS would start garbling and go crazy spouting weird output if I just had the customer number like that -- or any long number that was spoken. To help track down this issue, could you share: - The call ID - When exactly this happened (the timestamp) - What response you expected to get - What response you actually got instead This would really help me figure out what went wrong!
> I was hoping for the date time that it would be using NY time as that's where the office is located. @toadilywasted try using this again.
Copy code
{{"now" | date: "%b %d, %Y, %I:%M %p", "America/New_York"}}
t
Call ID 8789f08b-1a36-487f-9112-a81048faac0e @ 8:54 and 9:07 You can hear at those timestamps where it gets strange on the numbers. The first instance is similar to what I heard with some phone numbers
Has been pretty good lately but the phone number repeating back hasn't been working with the template
Didn't work Call ID
c90c04cb-ad66-42fa-a78c-9a327c26a8a1
The current date time is .\n\n
k
Hey toadily, do you have another call ID for date-time variables not working for you? I wanted to debug what's going wrong for you and with one call ID is not possible to reproduce.
8 Views