@function_tool() async def leave_voicemail(sel...
# ask-ai
n
@function_tool() async def leave_voicemail(self, ctx: RunContext): """ TERMINAL FUNCTION. Leave an automated voicemail message when the call is forwarded to voicemail. Rules: - Do not append any ADDITIONAL instructions, commentary, or acknowledgements. """ logger.info("Leaving voicemail for patient") voicemail_message = self.voicemail_template or self.get_default_voicemail() logger.info(f"Voicemail message: {voicemail_message[:100]}...") await ctx.session.say( text=voicemail_message, ) await self.end_call(ctx=ctx) I am using this function for leaving voicemail. it works fine with realtime model but with non realtime it ends call as soon as user voicemail is over
t
Thanks for reaching out, Nikhil. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks for reaching out! Could you please help me understand a bit more about what you mean by "non-realtime" model? Are you talking about a particular setting or mode in your LiveKit setup? Also, it would be great if you could share some details about how the voicemail function is set up in your system. I'm here to help you through this!
n
openai_realtime is realtime model openai gpt-4o is non realtime
t
Thank you so much for clarifying the models! To better assist you, could you please let me know if the issue with the call ending immediately after the voicemail plays in the GPT-4o model might be connected to how the function handles asynchronous processing, or if it could be related to a specific setting in your setup? Understanding this will really help us get to the root of the problem and find the best solution for you. Sources: OpenAI and LiveKit partner to turn Advanced Voice into an API | OpenAI and LiveKit | LiveKit Docs | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/models.py
n
this is section in prompt : ### 5. WHEN CALL IS FORWARDED TO VOICEMAIL If the call is forwarded to voicemail: ***IMMEDIATE ACTION REQUIRED:* - IMMEDIATELY use:
leave_voicemail()
- ***CRITICAL: This function will automatically:* - Deliver the complete voicemail message - Wait for message delivery to complete - Update call records appropriately - End the call automatically - ***DO NOT take any other actions after calling this function*** - ***DO NOT continue conversation or use
end_call()
separately*** ***Technical Notes:* - The
leave_voicemail()
function handles timing automatically - No additional delays or actions needed - Function includes built-in message delivery verification
my voicemail message ends with this line: "When you have finished recording, you may hangup. " can this be the reason agent cuts the call taking hangup as instruction?
t
Thank you for sharing your voicemail message with us. It’s quite possible that the phrase "you may hangup" is being picked up by the agent as an instruction to end the call. Could you please let me know if the agent uses any natural language processing (NLP) or specific logic to interpret the voicemail content? Understanding this will really help us figure out if the message itself is causing the call to end unexpectedly. I’m here to help you get to the bottom of this!
n
no nothing like that is being used
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!