# Events

```javascript
import { Im } from "@relationlabs/im";

myIm.bind(Im.RECEIVE_MSG_OK, (e) => {
    const message = e['im-message']
})
```

|       **Name**      |                                **Description**                               |                     **Callback Params**                    |
| :-----------------: | :--------------------------------------------------------------------------: | :--------------------------------------------------------: |
|    Im.CONNECT\_OK   |                 Triggered by a successful socket connection.                 |                                                            |
|   Im.CONNECT\_ERR   |                    Triggered by a socket connection error.                   |                                                            |
|  Im.CONNECT\_CLOSE  |                   Triggered by closing a socket connection.                  |                       { reason: '' }                       |
| Im.RECEIVE\_MSG\_OK | Triggered by receiving a new message after establishing a socket connection. | { 'im-message': { channelUuid, sendUuid, from, content } } |
|                     |                                                                              |                                                            |
|         ---         |                                                                              |                                                            |


---

# 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://relationlabs.gitbook.io/relation-one-api/js-sdk/im-js-sdk/events.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.
