Digi
10/05/2024, 2:33 PMVapi
10/05/2024, 2:35 PMpython
from datetime import datetime
# Define the business hours
OPEN_HOUR = 9 # 9 AM
CLOSE_HOUR = 17 # 5 PM
def check_business_hours():
# Get the current time
now = datetime.now()
current_hour = now.hour
# Check if the current time is within business hours
if OPEN_HOUR <= current_hour < CLOSE_HOUR:
# Business is open
return True, "Transferring your call now."
else:
# Business is closed
return False, "Our office is currently closed. Our business hours are from 9 AM to 5 PM. Please call back during our business hours."
# In your call handling logic
is_open, message = check_business_hours()
if is_open:
# Proceed with call transfer logic
pass
else:
# Use the VAPI to say the message to the caller
say(message)
This script checks if the current time is within the defined business hours. If it is, it proceeds with the call transfer. If not, it uses the say
function to inform the caller about the business hours and that the office is currently closed.
Remember to adjust the OPEN_HOUR
and CLOSE_HOUR
variables to match the actual business hours you're working with. Also, consider time zones and daylight saving changes if applicable.Vapi
10/05/2024, 2:35 PMVapi
10/05/2024, 2:36 PMDigi
10/05/2024, 2:37 PMDigi
10/05/2024, 2:37 PMDigi
10/05/2024, 5:34 PMDigi
10/07/2024, 12:29 PMVapi
10/07/2024, 12:29 PMsay(message)
function in the example is a placeholder for the actual method you would use to send a message to the voicebot. In practice, you would need to use the appropriate function or method provided by the VAPI to send or return the message to the voicebot.
If VAPI has a specific function to handle text-to-speech or to send messages, you would replace say(message)
with that function call, passing the message string as a parameter. If you're unsure about the exact function to use with VAPI, you can refer to the VAPI documentation or ask their support team for more information on how to interact with the voicebot to deliver messages.
If you need assistance with the specific function call for VAPI, please let me know, and I'll do my best to help you with the information I have. If the information is not available to me, I would recommend reaching out to VAPI support for further clarification.Digi
10/07/2024, 12:29 PMShubham Bajaj
10/07/2024, 3:00 PMDigi
10/18/2024, 7:28 PMShubham Bajaj
10/19/2024, 9:33 PM