Best Way To Change Response Based on Current Time/...
# support
m
I am building a Vapi agent that handles inbound calls for a locksmith company. The way the agent deals with calls must vary depending on the date and time. Currently, we have an Australian Twilio number linked to the agent. What's the best way for the agent to know what the date/time is and for it to alter its response to the user accordingly?
v
@mattfong To enable your Vapi agent to handle calls based on the date and time, you can implement a time-based logic within your agent's code. Here's how you can achieve this: 1. Retrieve the Current Date and Time: - Your agent can access the current date and time by querying the system clock or by using a time API that provides the current time based on a timezone. 2. Timezone Consideration: - Since you mentioned the service is for a locksmith company in Australia, ensure that the timezone is set correctly to Australian time zones (e.g., AEST, AEDT, etc.). 3. Implement Time-based Logic: - Within your agent's code, create decision-making logic that checks the current time and alters the agent's response based on predefined rules. For example, you might have different responses or call flows for business hours, after-hours, weekends, and public holidays. 4. Store Time-based Rules: - It's a good practice to store your time-based rules in a configuration file or database, so they can be easily updated without changing the agent's code. 5. Test the Time-based Responses: - Ensure you thoroughly test the time-based logic under various scenarios to confirm that the agent responds correctly at different times. If you need to handle daylight saving time changes or support multiple regions with different time zones, you may need to implement additional logic to account for these variations. Remember to keep your agent's responses and call flows user-friendly and informative, regardless of the time of day, to provide the best customer experience. If you need further assistance with setting up the time-based logic or have any specific questions about implementing this in your Vapi agent, please feel free to ask for more info.
You can continue this conversation by mentioning me in the message.
s
@mattfong To pass the date/time you have to pass the values right before the call, and then these values will be made available to your assistant. checkout this document on assistant overrides and dynamic variables. The variables here as variableValues under assistantOverrides. https://vapi.notion.site/Setting-Up-Dynamic-Variables-for-Your-Vapi-Calls-A-Quick-Guide-140008c8393f8057ac24db4089edc466?pvs=4
14 Views