How do I deliver voicemail to the participant afte...
# ask-ai
f
How do I deliver voicemail to the participant after he didn't answer?
t
Thanks for reaching out, Taras. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm here to help you deliver voicemail to a participant who doesn't answer. Here's a simple way to do it: 1. Initiate an Outbound SIP Call: You can start by using the
create_sip_participant()
method to place the call. Keep an eye on the
sip.callStatus
attribute to see if the call connects successfully. 2. Detect Voicemail: To know when the call reaches voicemail, you can use voicemail detection with LLM-based tools. This usually works by recognizing the voicemail greeting. 3. Deliver the Voicemail Message: Next, use
generate_reply()
to create and play a verbal message. Feel free to customize the message so it fits your needs perfectly. 4. End the Call: Once the message is delivered, simply disconnect the call and tidy up by deleting the room or disconnecting the participant. If you'd like, I’d be happy to provide more detailed guidance, including code examples and best practices. Just let me know, and I’ll gladly assist you with a complete working template! Sources: examples/warm-transfer/warm_transfer.py | SIP Integration | livekit/livekit_composite | DeepWiki | Agent Testing & Evaluation | livekit/livekit_composite | DeepWiki | Making calls using SIP | LiveKit Docs | agent.py
f
How to use
sip.callStatus
attribute to see if the call connects successfully?
t
To check if a SIP call connects successfully, you can keep an eye on the
sip.callStatus
attribute of the SIP participant. When the
sip.callStatus
changes to "active", it means the call is connected — pretty straightforward! Here’s a simple way to do it: 1. Retrieve the Attribute: Start by accessing the participant’s attributes to get the current
sip.callStatus
. For example:
Copy code
const sipParticipant = remoteParticipants.find((p) => p.identity.startsWith('sip_'));
const sipCallStatus = sipParticipant?.attributes?.['sip.callStatus'];
2. Monitor for Changes: You can use a loop or an event listener to watch for when the status updates to "active". Here’s a Python example:
Copy code
while perf_counter() - start_time < 30:
    call_status = participant.attributes.get("sip.callStatus")
    if call_status == "active":
        print("Call connected successfully")
        break
    elif call_status == "hangup":
        print("Call failed or was rejected")
        break
    await asyncio.sleep(0.1)
3. React to Events: Another helpful approach is to listen for the
participant_attributes_changed
event to handle updates as they happen:
Copy code
def on_participant_attributes_changed(changed_attributes, participant):
    if 'sip.callStatus' in changed_attributes:
        if changed_attributes['sip.callStatus'] == 'active':
            print("Call is now active and connected")
If you’d like, I’m here to help with more examples or to walk you through this step-by-step. Just let me know! Sources: SIP participant | LiveKit Docs | SIP Integration | livekit/livekit_composite | DeepWiki | Making calls using SIP | LiveKit Docs | telephony/sip_lifecycle.py | Make outbound calls | LiveKit Docs