<@U07FRRZH2GN> I want to delte the room 5 seconds ...
# ask-ai
f
@icy-policeman-64898 I want to delte the room 5 seconds after executing a task how can i do that woth livekit v1
t
Thanks for reaching out, Abhishek. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To delete a room 5 seconds after executing a task in LiveKit v1, you can use the following Python code:
Copy code
import asyncio
from livekit import api
import os

async def entrypoint(ctx: JobContext):
    # do some work
    # ...
    
    # Wait for 5 seconds
    await asyncio.sleep(5)
    
    # Delete the room
    api_client = api.LiveKitAPI(
        os.getenv("LIVEKIT_URL"),
        os.getenv("LIVEKIT_API_KEY"),
        os.getenv("LIVEKIT_API_SECRET"),
    )
    await api_client.room.delete_room(api.DeleteRoomRequest(
        room=ctx.job.room.name,
    ))
This code will execute your task, wait for 5 seconds, and then delete the room using the LiveKit server API. When the room is deleted, all participants will be disconnected, and the
Disconnected
room event will be sent to all clients. The room will also be removed from the server. Sources: Inside a session | LiveKit Docs | Inside a session | LiveKit Docs