Transfer only between specific time #3
# support
d
Again from this conversation. Would creating a python code around it would work? So that before transfering the call is check if it is withing the their open time? If it's not it would return a message to send to the voicebot to say? Would that be doable?
v
@Digi Absolutely, that's a great idea! You can create a Python script that checks the current time against the business hours before transferring the call. If it's outside of the open hours, the script can return a message that the voicebot can say to inform the caller. Here's a simplified example of how you might implement this:
Copy code
python
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.
You can continue this conversation by mentioning me in the message.
Got it. Tagging @User for additional help.
d
I just wonder if the "say(message)" will work
Because I had the same idea but I am unsure if vapi work like this since it's a third party and not a 100% custom voicebot
@Shubham Bajaj
@Vapi
v
@Digi I understand your concern. The
say(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.
d
@User
s
yes it is doable check vapi server request type of request-assistant and you can return assistant on run time based on business hours.
d
@Shubham Bajaj Do you have any content or documentation about this?
s
No i don't have any documentation.