blue-account-81612
07/08/2025, 5:27 PMtall-airline-16756
07/08/2025, 5:27 PMtall-airline-16756
07/08/2025, 5:28 PMclass CallActions(llm.FunctionContext):
async def hangup(self):
try:
await self.api.room.remove_participant(api.RoomParticipantIdentity(
room=self.room.name,
identity=self.participant.identity,
))
except Exception as e:
<http://logger.info|logger.info>(f"received error while ending call: {e}")
@llm.ai_callable()
async def end_call(self):
<http://logger.info|logger.info>(f"ending the call for {self.participant.identity}")
await self.hangup()
For calling a webhook once the call is hung up, LiveKit does not have a specific event webhook for call hang-up, but you can monitor the sip.callStatus
attribute of participants. When it changes to "hangup", you can trigger your webhook call.
Example of monitoring the call status and triggering a webhook:
import requests
participant = ... # obtain participant instance
if participant.attributes.get("sip.callStatus") == "hangup":
<http://requests.post|requests.post>("<https://your-webhook-url.com/call-ended>", data={"caller": participant.identity})
This approach allows you to integrate webhook notification for call hang-up events.
Note the limitation that LiveKit needs external services for phrase detection and you must implement monitoring and webhook calling logic yourself.
Sources: Making calls using SIP | LiveKit Docs | Making calls using SIP | LiveKit Docs | Agents telephony integration | LiveKit Docs