https://retellai.com/?utm_source=discord&utm_medium=seo logo
we're looking to set up a transfer agent that will...
# ❓・ai-evy-support
b
@AI Evy we're looking to set up a transfer agent that will route to either a daytime agent or afterhours agent depending on the time of day. Is there any documentation on doing this
a
Thanks for tagging me @bohmez. I'll look through relevant sources and get back to you shortly.
### Answer --- You can set up time-based routing using dynamic variables combined with a webhook or external function to determine the current time and route accordingly. Recommended Approach: 1. Use a dynamic function/webhook to check the time of day and return the appropriate transfer destination number. [(1) ]() - For example, using n8n or a custom webhook, your function can evaluate the current time and return either the daytime agent number or the afterhours agent number. 2. Set the transfer number as a dynamic variable that gets substituted at runtime. [(2) ]() - In the Transfer Call tool, you can set the transfer number to a dynamic variable (e.g.,
{{transfer_number}}
) , which your webhook populates based on the time logic. 3. Intent-based routing with lookup logic works well for this. [(1) ]() [(3) ]() - The agent calls a dynamic function, passes the detected intent or time context, your webhook looks up the associated number, and returns it for the transfer. Example Setup: Using n8n with a Google Sheet (or database) as the lookup table—Retell calls a dynamic function, the webhook checks the time and returns the correct number for the transfer. [(1) ]() Relevant Documentation: - [Transfer call]() [(2) ]() There isn't a built-in "time of day" routing feature in Retell
AI, so you'll need to handle this logic via your webhook or function calling setup.
​ To learn more, see the sources I considered: [[1] Discord message from @dennis_71970 on 2026-01-14](https://discord.com/channels/1186424376300679209/1186462578310910112/1461035697686315091) [[2] Transfer call](https://docs.retellai.com/build/single-multi-prompt/transfer-call) [[3] Discord message from @immaculate_cheetah_77268 on 2026-02-13](https://discord.com/channels/1186424376300679209/1186462578310910112/1471809917793996893) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
b
@AI Evy Provide an example of a dynamic function for the current date and time
a
Thanks for the follow-up, @bohmez. I'll get back to you soon.
### Answer --- Retell AI provides built-in system variables for current date and time—no custom function needed for basic time awareness. [(1) ]() Default System Variables Available: -
{{current_time}}
— Current time in
America/Los_Angeles
(e.g., "Thursday, March 28, 2024 at 11:46:04 PM PST") -
{{current_time_[timezone]}}
— Current time in a specified timezone (e.g.,
{{current_time_Australia/Sydney}}
) -
{{current_hour}}
— Current hour in
America/Los_Angeles
(e.g., "3 PM") -
{{current_hour_[timezone]}}
— Current hour in a specified timezone For time-based routing, you can reference these variables directly in your prompt logic. For example, in your agent prompt:
Copy code
If {{current_hour}} is between 9 AM and 5 PM, transfer to {{daytime_agent_number}}.
Otherwise, transfer to {{afterhours_agent_number}}.
Using nested variables: If you want the timezone to be dynamic, you can use nested variable syntax:
Copy code
{{current_time_{{my_timezone}} }}
This evaluates the inner variable first, then resolves the full expression. For more complex logic (like checking if the time falls within business hours) , you'd use a custom function that your webhook handles—the function receives the call context, your server evaluates the time, and returns the appropriate transfer number. [(2) ]()
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Function Calling Overview](https://docs.retellai.com/build/single-multi-prompt/function-calling) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
b
ok so provide the exact steps i would need to create a transfer agent it takes a call, and based on the time of day and day of the week, transfers to 1 of 2 agents if it's between 8am-5pm monday to friday, it transfers to the day time agent if it's outside of 8am-5pm monday to friday, it goes to the afterhours agent @AI Evy
a
Thanks for the follow-up, @bohmez. I'll get back to you soon.
### Answer Here are the exact steps to create a time-based transfer agent: ## Step 1: Create Your Two Destination Agents First, create your daytime agent and afterhours agent in Retell AI. Note their agent IDs or phone numbers depending on whether you'll use Agent Transfer or Transfer Call. ## Step 2: Create the Transfer/Routing Agent Create a new agent that will handle the initial call and route based on time. ## Step 3: Set Up Your Timezone Variable Define a dynamic variable for your timezone. You can use the built-in system variable with your specific timezone: [(1) ]()
Copy code
{{current_time_America/New_York}}
This returns the current time in your specified timezone (e.g., "Thursday, March 28, 2024 at 11:46:04 PM EST") . ## Step 4: Add Transfer Tools Option A - Agent Transfer (recommended for AI-to-AI transfers) : Click "Add" in the tools section and select "Agent Transfer." Configure the transfer agent ID and version for each destination. [(2) ]() Option B - Transfer Call (for phone number transfers) : Click "+ Add" in the tools section and select "Transfer Call." Set the transfer number to either a number in e.164 format or a dynamic variable like
{{transfer_number}}
. [(3) ]() ## Step 5: Update the Prompt with Time Logic Add clear conditional instructions in your agent prompt: [(4) ]()
Copy code
## Transfer Guidelines

Before every response, check the current time using {{current_time_America/New_York}}.

- If the day is Monday through Friday AND the hour is between 8 AM and 5 PM:
  - Say: "Let me transfer you to our daytime team."
  - Immediately call the function: transfer_to_daytime_agent

- If the day is Saturday or Sunday, OR the hour is before 8 AM or after 5 PM:
  - Say: "Let me transfer you to our afterhours team."
  - Immediately call the function: transfer_to_afterhours_agent
## Step 6: Test and Debug Test the agent transfer both in web call and playground to verify the routing logic works correctly. [(2) ]() Important Note: Function calling reliability depends on the LLM model. GPT-4.1 and GPT-4o tend to perform better for function calling. Using a lower temperature value (closer to 0) improves reliability for function calling use cases. [(4) ]()
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Agent Transfer](https://docs.retellai.com/build/single-multi-prompt/transfer-agent) [[3] Transfer call](https://docs.retellai.com/build/single-multi-prompt/transfer-call) [[4] How to get a desired call duration to control costs](https://community.retellai.com/t/how-to-get-a-desired-call-duration-to-control-costs/293) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
b
i set up a function that checks the time on n8n to determine which agent to transfer to. the transfer time was 12 seconds - what's a faster way to do this
a
Thanks for the follow-up, @bohmez. I'll get back to you soon.
### Answer --- A 12-second transfer time is slow because you're making an external HTTP call to n8n for time logic. The faster approach is to eliminate the external function call entirely and use Retell's built-in system variables directly in your prompt. [(1) ]() Use built-in time variables instead: Retell automatically provides these system variables—no external call required: -
{{current_time_[timezone]}}
— Current time in your specified timezone (e.g.,
{{current_time_America/New_York}}
) -
{{current_hour_[timezone]}}
— Current hour in your specified timezone (e.g., "3 PM EST") Faster implementation: Instead of calling n8n, put the time-checking logic directly in your agent's prompt using these variables:
Copy code
Check {{current_time_America/New_York}} before transferring.

If Monday-Friday between 8 AM and 5 PM:
  - Transfer to [daytime number]

Otherwise:
  - Transfer to [afterhours number]
This removes the external HTTP round-trip to n8n, which is likely adding most of that 12-second delay. The LLM evaluates the time logic locally using the pre-populated system variable. Additional latency tips: - Use a lower temperature value (closer to 0) for more reliable function calling. [(2) ]() - Consider using GPT-4o or GPT-4.1 for better function calling consistency.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] How to get a desired call duration to control costs](https://community.retellai.com/t/how-to-get-a-desired-call-duration-to-control-costs/293) ​
b
@AI Evy i want to retrieve the user's phone number into a post call data extraction tool i don't want to explictly ask the user for it, i want the tool to get the number from the call metadata
a
Thanks for the follow-up, @bohmez. I'll get back to you soon.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
### Answer Post-call analysis extracts data from the conversation content (what was spoken) , not from call metadata like phone numbers. [(1) ]() To get the caller's phone number without asking the user, you have two options: Option 1: Use the Get Call API After the call ends, retrieve the call details via the [Get Call API]() . The response includes telephony metadata alongside the
call_analysis
object. [(2) ]() Option 2: Capture from webhooks The
call_analyzed
webhook only contains extracted/spoken data, not telephony metadata. The caller number lives at the call level (e.g.,
from_number
) and is sent in
call_started
or
call_completed
webhooks, or available via Get Call by ID. [(3) ]() Recommended approach: Capture the caller number from the initial
call_started
webhook, store it, then merge it with the
call_analyzed
data before sending to your destination (like Google Sheets) . This way you get both the phone number from call metadata and the post-call analysis insights in one combined record.
​ To learn more, see the sources I considered: [[1] Post Call Analysis Overview](https://docs.retellai.com/features/post-call-analysis-overview) [[2] Get Call](https://docs.retellai.com/api-references/get-call) [[3] Discord message from @olyn_38804 on 2026-01-05](https://discord.com/channels/1186424376300679209/1186462578310910112/1457733982031450123) ​