# userLeft

Emitted when a user has left the room.&#x20;

You can discriminate between the **local** user and **remote** users by the `type` field inside the event `data`. The `reason` field tells if user was kicked, the session has ended, or it was just a normal (generic) leave.

#### Sample payload

```json
{
  "type": "userLeft",
  "data": {
    "type": "local",
    "reason": "generic/kicked/sessionEnded",
    "user": {
      "id": "d31ddb8a-07f7-44d0-ba4b-31b5a8e28f68",
      "name": "John Smith",
      ....................
    }   
  }
}
```

#### Sample subscription code

```javascript
sambaFrame.on('userLeft', (event) => {
  const data = event.data;
  if (data.type === 'local') {
     console.log('You have left the room');
  } else {
     console.log(data.user.name, 'has left the room');
  }
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digitalsamba.com/reference/sdk/events/userleft.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
