Create a timer to limit time on a call.
# support
b
I'm trying to create a timer using LiquidJS variables. However, the agent is ignoring all steps with variables. I'm trying to test my concept with the prompt below. It should read all the announcements even if they are empty, but it reads nothing. Can you please help get some clarity on the syntax to use to do this? Call recording: https://storage.vapi.ai/454a32a9-b8fb-425a-a2bc-9555f0c7b0e8-1732044135024-9d20dec9-e929-4dd3-a629-03397dc61db0-mono.wav Prompt:
Copy code
[Identity]
You are an examiner with over 20 years of experience administering tests.

[Style]
- Maintain a professional, calm demeanor
- Be succinct. Do not repeat what the candidate said.

[Tasks]
1. Announce that the timer started.
2. Set the {{timerEnd}} variable to {{now | date: "%s" | plus: 60 }}
3. Announce "the time end variable is {{timerEnd}}.
4. Announce: {{now | date: "%s" | minus: timerEnd | times: 1}} seconds left, and {{ assign current = now | date: "%s" }}{{ if current > timerEnd }} time is up {{ else }} you have time{{ endif }}.
5. Announce the following: "Let us begin our exam. We will begin with: Peri-Operative Period Number One, Intra-Operative Management.  This Period contains four sections and will last a total of one minute."
6. Announce the following: "Section Number One: Induction"
7. Announce: {{'now' | date: "%s" | minus: timerEnd | times: 1}} seconds left, and {{ assign current = 'now' | date: "%s" }}{{ if current > timerEnd }} time is up {{ else }} you have time{{ endif }}.
8. Announce: "Let's get a variable check. Now is {{now | date: "%s"}}. Now in quotations is {{now | date: "%s"}}. Timer end is {{timerEnd}}. Assigned current is {{current}}.
v
@Berto Mejia It seems like you're trying to use LiquidJS templating syntax to create a dynamic timer within a prompt. However, LiquidJS is a server-side templating language and cannot be used to create real-time timers in this way. The templating engine would process the variables at the time of rendering the template, not continuously as time passes. To implement a timer, you would typically need to use a programming language that can handle real-time updates, such as JavaScript in a web environment. If you're working within a system that supports LiquidJS, you would need to handle the timing logic on the server side and then render the output to the user. If you're looking to test the concept within the context of VAPI, you would need to use the appropriate API or system features to create a timer. If VAPI supports such functionality, you would need to refer to its documentation or support for the correct syntax and methods to use. If you need further assistance with a specific VAPI feature or if there's a particular function you'd like to call, please provide more details, and I'll be happy to help!
You can continue this conversation by mentioning me in the message.
b
The documentation for Vapi states that they use LiquidJS for dynamic variables. https://docs.vapi.ai/assistants/dynamic-variables#advanced-date-and-time-usage
s
Hey @Berto Mejia this is your prompt used for the call id shared and from it's visible that your not using correct syntax as opposite to shared prompt in the issue description, can you please check your call id again.
Call Id Shared Prompt
Copy code
[Tasks]\n1. Announce that the timer started.\n\n2. Set the  variable to \n\n3. Announce that the timer started.\n\n4. Announce:  seconds left, and  time is up  you have time.\n\n5. Announce the following: \"Let us begin our exam. We will begin with: Peri-Operative Period Number One, Intra-Operative Management.  This Period contains four sections and will last a total of one minute.\"\n\n6. Announce the following: \"Section Number One: Induction\"\n\n7. Announce:  seconds left, and  time is up  you have time.\n\n8. Announce: \"Let's get a variable check. Now is . Now in quotations is . Timer end is . Assigned current is .\n\n
b
@User I think I may have iterated on the exact prompt from that particular recording. However, based on what you posted, It seems that the Liquid JS is not returning anything (see image). It also seems that this is being calculated before the call and is not accessible during the call. So, what is the proper syntax to get something like this working? How can I create a timer? https://cdn.discordapp.com/attachments/1308527036641316934/1308862330431344772/image.png?ex=673f7c89&is=673e2b09&hm=115d268b67f537c6e9f8389dcd3004e78ac8decaf5646a51ab6898e14a261d8e&
s
Hey @Berto Mejia your correct apology for not looking into your prompt using assistantId, allow me some time to try to reproduce this. FYI: timer thing won't work, because these are still static values so, there is no timer during the call. TLDR: timer cannot work because values are static, and I will look into use of liquidJs.
b
OK. What about using a tool? Can a tool reference the response from another tool? For example, if I build a timer and return a timer ID, can I reference a timer ID on a follow-up tool call?
s
@Berto Mejia use this prompting for reusing tool call response.
Copy code
trigger the <insert-tool-name-here> tool and map the result to {{variableName}}
b
I'll try that. Thank you.
9 Views