narrow-answer-89593
06/06/2025, 2:46 AMtall-airline-16756
06/06/2025, 2:46 AMtall-airline-16756
06/06/2025, 2:46 AMhangup method: This method removes a specific participant from the room. Example code:
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:
# It's possible that the user has already hung up, this error can be ignored
<http://logger.info|logger.info>(f"received error while ending call: {e}")
• Using the end_call function: This function can also be used to end the call for a specific participant. Example code:
@llm.ai_callable()
async def end_call(self):
"""Called when the user wants to end the call"""
<http://logger.info|logger.info>(f"ending the call for {self.participant.identity}")
await self.hangup()
These methods effectively kick the participant from the call. Let me know if you need further assistance!
Sources: Making calls using SIP | LiveKit Docs | Making calls using SIP | LiveKit Docsnarrow-answer-89593
06/06/2025, 2:52 AMtall-airline-16756
06/06/2025, 2:52 AMValueError: Protocol message RemoveParticipantResponse has no 'room' field, occurs because the RemoveParticipantResponse object returned by the remove_participant method is an empty response object and does not contain a room field.
To resolve this issue, ensure that you are not trying to access a room field on the response object. The remove_participant method takes a RoomParticipantIdentity object as input (which does have a room field), but the response itself is empty and does not include any fields.
If you need further clarification or assistance, feel free to ask!
Sources: livekit.api.room_service API documentationnarrow-answer-89593
06/06/2025, 2:54 AMtall-airline-16756
06/06/2025, 2:54 AMremove_participant method. Here's an example of how to correctly use it:
# Create a RoomParticipantIdentity object with room name and participant identity
remove_request = RoomParticipantIdentity(
room="room_name",
identity="participant_identity"
)
# Call the remove_participant method
response = await room_client.remove_participant(remove_request)
This method forcibly disconnects the participant from the room. However, note that this action does not invalidate the participant's token. To prevent them from rejoining, you should either generate access tokens with a short TTL or ensure your backend does not provide a new token to the same participant.
In your code, ensure that the ctx.api.room.remove_participant call is correctly structured and that you are not attempting to access fields on the response object, as it is empty. Let me know if you need further clarification!
Sources: Managing participants | LiveKit Docs | livekit.api.room_service API documentation