# roleChanged

Emitted when a role of a user changes. This can be useful if you have a custom participants panel and want to display up-to-date roles or you just want to react to a role change.

#### Sample payload

```json
{
  "type": "roleChanged",
  "data": {
      "userId": "2775f882-845e-4416-82c9-04cc25669c0b",
      "from": "attendee",
      "to": "moderator"
    }
  }
}
```

#### Sample subscription code

```javascript
sambaFrame.on('roleChanged', (event) => {
  const data = event.data;
  console.log('User', data.userId, 'role changed from', data.from, 'to', data.to);
});
```

{% hint style="info" %}
This event is often used with the [changeRole](/reference/sdk/methods/changerole.md) method.
{% endhint %}


---

# 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/rolechanged.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.
