How can I get realtime update about LiveKit Agent ...
# ask-ai
b
How can I get realtime update about LiveKit Agent Session during Inbound calls? I need to call webhook to my backend when call started & call ended?
t
Thanks for reaching out, Dhruvil. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You can receive real-time updates about LiveKit Agent Sessions during inbound calls by configuring LiveKit's webhook system to notify your backend when calls start and end. • Ingress Started: Triggered when an inbound call starts. • Ingress Ended: Triggered when an inbound call ends. Set up an HTTP endpoint on your backend to handle these webhook events. For example, your webhook handler can process
ingress_started
and
ingress_ended
events to trigger your backend logic accordingly.
Copy code
from fastapi import FastAPI

app = FastAPI()

@app.post("/webhook")
async def handle_webhook(event: dict):
    event_type = event.get("event")
    
    if event_type == "ingress_started":
        # Call started logic
        print("Inbound call started")
        return {"message": "Call started successfully"}
    elif event_type == "ingress_ended":
        # Call ended logic
        print("Inbound call ended")
        return {"message": "Call ended successfully"}
    return {"message": "Event processed"}
This way, your backend gets notified immediately when an inbound call starts and ends. Additionally, you can also listen to session agent events like
agent_state_changed
to monitor when agents begin or end speaking if you want to handle it within the session. This setup ensures reliable real-time updates about call status to your backend. Sources: Webhooks | LiveKit Docs | Turn detection and interruptions | LiveKit Docs