here's a prompt i am using for livekit call dispat...
# ask-ai
n
here's a prompt i am using for livekit call dispatch with openai_realtime. the voicemail tool call is not working properly. it leaves voicemail like this: { "items": [ { "id": "dasdas", "role": "assistant", "type": "message", "content": [ "Hello? Am I speaking with Luis Maldonado?" ], "interrupted": false }, { "id": "adasdsa", "role": "user", "type": "message", "content": [ "Please leave your message for" ], "interrupted": false }, { "id": "dasdas", "role": "assistant", "type": "message", "content": [ "This is an automated call from COMPANY for POSA. We are calling to remind you that you have an appointment with ABCD on Monday, August 25, 2025 from 07:30 pm. If you need to cancel or reschedule, call back . Thank you." ], "interrupted": false }, { "id": "adsasd", "role": "assistant", "type": "message", "content": [ "It seems like I reached your voicemail. I’ll leave a message with the appointment reminder. Thanks and have a great day!" ], "interrupted": false } ] } CODE : @function_tool() async def leave_voicemail(self, ctx: RunContext): """ Leave an automated voicemail message when the call is forwarded to voicemail. This function detects when a call has been forwarded to voicemail and leaves an appropriate appointment reminder message. Note: - Call this immediately when voicemail is detected - Wait for function completion before proceeding - The voicemail message is pre-formatted and appropriate for appointment reminders """ logger.info("Leaving voicemail for patient") voicemail_message = f"This is an automated call from COMPANY for {self.patient_name}. We are calling to remind you that you have an appointment with {self.provider_name} on {self.appointment_start_date_time | date: '%A, %B %d, %Y from %I:%M %P', self.patient_timezone}. If you need to cancel or reschedule, call back {self.organization_phone}. Thank you." # Send alert for voicemail detection await self.send_call_alert( organization=self.organization, operation="VOICEMAIL_DETECTED", error_details="Call was forwarded to patient's voicemail system", ) await ctx.session.say( text=voicemail_message, ) process_message( self.recording_id, self.organization, "UPDATE_RECORDING", { "outcome": "VOICEMAIL", "missedAt": datetime.now(timezone.utc).isoformat(), }, ) await self.end_call(ctx=ctx) MAIN PROMPT- voicemail section: ### 5. WHEN CALL IS FORWARDED TO VOICEMAIL If the call is forwarded to voicemail: ***IMMEDIATE ACTION REQUIRED:* - DO NOT SPEAK when you detect voicemail - IMMEDIATELY call:
leave_voicemail()
- DO NOT treat voicemail prompts as patient responses - DO NOT continue with normal conversation flow - DO NOT say anything before calling the function - Wait for completion Remember: The leave_voicemail() function will handle the entire voicemail message and end the call automatically. Do not speak anything else once you detect voicemail and after the function call has been completed. ---
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.
Hey there! Could you help me understand a bit more about the issue you're having with the voicemail tool? For example: • Are calls not being recognized as voicemail when they should be? • Is the agent having trouble leaving the right voicemail messages? • Are you noticing any connection or audio quality problems during voicemail? • Are there any error messages or logs popping up? Knowing these details will really help us figure out if the problem is with voicemail detection, message delivery, or something else in the system. Thanks so much for sharing! Sources: SIP Integration | livekit/livekit_composite | DeepWiki | Community & Support | livekit/livekit_composite | DeepWiki | Getting Help | livekit/livekit_composite | DeepWiki | Agents telephony integration | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs
n
so if you take a look at the last object in transcription array.. the prompt leaves irrelevant line in the voicemail: "It seems like I reached your voicemail. I’ll leave a message with the appointment reminder. Thanks and have a great day"
t
Hey there! To get rid of that irrelevant line from your voicemail transcription, you can use the
transcription_node
feature to filter out any unwanted bits. This way, you can easily specify the exact phrases or patterns you want to remove or replace while the transcription is happening. Here’s a simple example to show you how it works:
Copy code
async def transcription_node(self, text: AsyncIterable[str], model_settings: ModelSettings):
    """Filter voicemail transcription content."""
    filters = {
        "It seems like I reached your voicemail. I’ll leave a message with the appointment reminder. Thanks and have a great day": "",
        # Add other unwanted phrases here
    }

    async def process_text():
        async for chunk in text:
            processed = chunk
            for unwanted, replacement in filters.items():
                processed = processed.replace(unwanted, replacement)
            yield processed

    return process_text()
Just pop the exact line you want to remove into the
filters
dictionary, and it’ll be taken out of the transcription output. If you want a hand setting this up or have any questions, feel free to reach out—I’m here to help! Sources: Pipeline nodes and hooks | LiveKit Docs | livekit-agents/livekit/agents/voice/agent.py | pipeline-llm/transcription_node.py | Voice pipeline nodes | LiveKit Docs
n
is there other way? Because i cant go on filtering each word i find new everytime
t
If going through each word manually feels a bit overwhelming, no worries! Here are some other ways you can handle those irrelevant lines in voicemail transcriptions more smoothly: 1. Pattern-Based Filtering: Try using regular expressions to spot and remove common voicemail bits like system prompts or repeated characters. It’s a lot more flexible than checking every single word. 2. LLM-Based Content Analysis: You can have your language model take a look at the transcription and figure out if it’s got the important stuff or just system prompts. This way, it adapts nicely to different situations. 3. Stream-Based Message Processing: Filter the transcription as it comes in by setting rules for what’s relevant—like skipping phrases such as "please leave a message" or "after the tone." 4. Event-Based Filtering: Tweak how transcripts are handled by cleaning them up right at the event level before everything’s finalized. These options give you a more dynamic and scalable way to manage those irrelevant parts. If you want, I’m happy to walk you through how to set any of these up! Sources: SIP Integration | livekit/livekit_composite | DeepWiki | VoiceAgent/Chat/Receive/TranscriptionStreamReceiver.swift | Agent Testing & Evaluation | livekit/livekit_composite | DeepWiki | Pipeline nodes and hooks | LiveKit Docs | livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime...