https://retellai.com/?utm_source=discord&utm_medium=seo logo
Can't use dynamic variable with date-time format i...
# ❓・bug-report
d
Hello everyone, I have been struggling to add custom variables to my GET URL in a custom function. Here is the scenario: - I want to check for available slots in my calendar for the next 2 business days (for the example, I just said to the agent to give me next monday and next tuesday as startTime and endTime). I have told my agent to calcule that, encode the url for HTML url. So far it's good as you can see in the screen captures where I have told my agent to show me the content of the variable: - If I take the values as they are and put them directly in my GET URL, it works fine. - If I now use the variables {{startTime}} and {{endTime}}, it doesn't work anymore. This shows that the variables are fine when being used in prompts but not being used in URLs. Can anyone have an idea or a solution to help me use dynamic variables in URLs? Do you also know how can I see exactly how the URL is being sent? (so I see if there is something I could troublehsoot regarding encoding or something else). This is driving me crazy! Many thanks!
o
The start and end time where you set those variables values?
d
@Omar Ashraf | Community Lead sorry I don't understand your question
{{startTime}} and {{endTime}} are defined through an instruction I give to the AI Agent. The chat screen capture is the proof that the dynamic variable has been correctly calculated as it is showing me the date-time values, encoded for HTML. The screencapture of the function is to show you how I am passing them in the URL.
Maybe I am doing something wrong?
o
you can't assign values to variables using the prompt , you have to use extract dynamic variables node then you can use it inside your function
and you don't have to encode the values at all ..
d
I wasn't assigning during the prompt. I was assigning where I give the global instructions to the agent and it works (as you can see in the chat section). Ok I will try your method Omar, thank you very much. Can you guide me on how to use that please? I thought that "extract dynamic variables" was to receive the result from the API and store it in a variable. If that's the case, that's not what I am trying to accomplish. Sorry if I misundestand some things, I'm knew at Retell.ai Many thanks Omar
o
When you assigning in the global prompt the agent will see it like the "startTime is next Monday" but it won't give the startTime value of next Monday it will be empty, that why you can't use it
you can use this guide, if you need more help let me know.
d
@Omar Ashraf | Community Lead many thanks! It works perfectly as expected.
@Omar Ashraf | Community Lead, is it possible to get the number of the person that is calling without having the person type digits manually? Many thanks
o
You are welcome.
Yes use this variable {{user_number}}
d
Perfect! Because the AI in the documentation told me there is no default variable for that. I wanted to be sure and ask a human as well! Thanks again!
s
Generate clean ISO timestamps in the prompt Tell the model: “Give me the value in strict ISO-8601 format (YYYY-MM-DDTHH:mm:ss±HH:MM). Do not escape or encode the value.” That way {{startTime}} = 2025-08-18T09:00:00+02:00 Let Retell’s function system do the encoding In your Custom Function setup, use the Query Parameters field: Key: startTime → Value: {{startTime}} Key: endTime → Value: {{endTime}} Retell will automatically URL-encode these variables for the GET request.
Your prompt should be simplified to: {{startTime}} = next Monday in ISO 8601 format (YYYY-MM-DDTHH:mm:ss±HH:MM) {{endTime}} = next Tuesday in ISO 8601 format (YYYY-MM-DDTHH:mm:ss±HH:MM) Do not escape, do not encode, no human-readable text.