# Reference

| Callback name                                       | Description                                                                                             |
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| [onChatDisplayed](#onchatdisplayed)                 | Triggered when the chatbox is displayed on the visitor screen **(either opened or reduced)**.           |
| [onChatHidden](#onchathidden)                       | Triggered when the visitor closes the chatbox (after the conversation has been closed by the operator). |
| [onChatButtonDisplayed](#onchatbuttondisplayed)     | Triggered when a “click to chat” button is displayed on the visitor screen.                             |
| [onChatStarted](#onchatstarted)                     | Triggered when a chat conversation has started.                                                         |
| [onChatEnded](#onchatended)                         | Triggered when a chat conversation has ended.                                                           |
| [onCallButtonDisplayed](#oncallbuttondisplayed)     | Triggered when a “click to call” button is displayed on the visitor screen.                             |
| [onMessageReceived](#onmessagereceived)             | Triggered when an operator message is received by the visitor.                                          |
| [onMessageSent](#onmessagesent)                     | Triggered when the visitor sends a message.                                                             |
| [onSatisfactionDisplayed](#onsatisfactiondisplayed) | Triggered when the satisfaction survey is displayed to the visitor.                                     |
| [onSatisfactionAnswered](#onsatisfactionanswered)   | Triggered when the visitor has answered all the questions in the satisfaction survey.                   |

## onChatDisplayed <a href="#onchatdisplayed" id="onchatdisplayed"></a>

Triggered when the chat window is displayed on the visitor screen **(either opened or reduced)**.

**Example:**

```javascript
window.iAdvizeCallbacks = {
  ...window.iAdvizeCallbacks,
  
  onChatDisplayed() {
    // Chat window is displayed
    ...
  }
  
};
```

## onChatHidden <a href="#onchathidden" id="onchathidden"></a>

Triggered when the visitor closes the chatbox (after the conversation has been closed by the operator).

**Example:**

```javascript
window.iAdvizeCallbacks = {
  ...window.iAdvizeCallbacks,
  
  onChatHidden() {
    // Chat window is hidden
    ...
  }
  
};
```

## onChatButtonDisplayed <a href="#onchatbuttondisplayed" id="onchatbuttondisplayed"></a>

Triggered when a “click to chat” button is displayed on the visitor screen.

**Example:**

```javascript
window.iAdvizeCallbacks = {
  ...window.iAdvizeCallbacks,
  
  onChatButtonDisplayed() {
    // Chat button is displayed
    ...
  }
  
};
```

## onChatStarted <a href="#onchatstarted" id="onchatstarted"></a>

Triggered when a chat conversation has started.

#### **Context parameter:**

| Property                 | Description                                                                   |
| ------------------------ | ----------------------------------------------------------------------------- |
| `context.id`             | Legacy conversation ID (integer ID)                                           |
| `context.conversationId` | New conversation ID in UUID format that you can use in our GraphQL API        |
| `context.vuid`           | Visitor Unique Id is a random string which can be used for analytics purposes |

#### **Example:**

```javascript
window.iAdvizeCallbacks = {
  ...window.iAdvizeCallbacks,
  
  onChatStarted(context) {
    // Chat conversation has started
    ...
  }
  
};
```

## onChatEnded <a href="#onchatended" id="onchatended"></a>

Triggered when a chat conversation has ended.

#### **Context parameter:**

| Property                 | Description                                                                   |
| ------------------------ | ----------------------------------------------------------------------------- |
| `context.id`             | Legacy conversation ID (integer ID)                                           |
| `context.endedBy`        | **⚠️ DEPRECATED.** The conversation can only be ended by an operator          |
| `context.conversationId` | New conversation ID in UUID format that you can use in our GraphQL API        |
| `context.vuid`           | Visitor Unique Id is a random string which can be used for analytics purposes |

#### **Example:**

```javascript
window.iAdvizeCallbacks = {
  ...window.iAdvizeCallbacks,
  
  onChatEnded(context) {
    // Chat conversation is closed
    ...
  }
  
};
```

## onCallButtonDisplayed <a href="#oncallbuttondisplayed" id="oncallbuttondisplayed"></a>

Triggered when a “click to call” button is displayed on the visitor screen.

#### **Example:**

```javascript
window.iAdvizeCallbacks = {
  ...window.iAdvizeCallbacks,
  
  onCallButtonDisplayed() {
    // Call button is displayed
    ...
  }
  
};
```

## onMessageReceived <a href="#onmessagereceived" id="onmessagereceived"></a>

Triggered when an operator message is received by the visitor.

#### **Context parameter:**

| Property                      | Description                                                                     |
| ----------------------------- | ------------------------------------------------------------------------------- |
| `context.time`                | Local time of the message (visitor time)                                        |
| `context.msg`                 | The text message received                                                       |
| `context.date`                | Local DateTime of the message ([ISO 8601](https://www.w3.org/TR/NOTE-datetime)) |
| `context.operator.id`         | Internal iAdvize operator id                                                    |
| `context.operator.externalId` | The operator external id provided by the customer                               |

#### **Example:**

```javascript
window.iAdvizeCallbacks = {
  ...window.iAdvizeCallbacks,
  
  onMessageReceived(context) {
    // Operator message received
    ...
  }
  
};
```

## onMessageSent <a href="#onmessagesent" id="onmessagesent"></a>

Triggered when the visitor sends a message.

#### **Context parameter:**

| Property       | Description                              |
| -------------- | ---------------------------------------- |
| `context.time` | Local time of the message (visitor time) |
| `context.msg`  | The text message received                |

#### **Example:**

```javascript
window.iAdvizeCallbacks = {
  ...window.iAdvizeCallbacks,
  
  onMessageSent(context) {
    // Visitor message sent
    ...
  }
  
};
```

## onSatisfactionDisplayed <a href="#onsatisfactiondisplayed" id="onsatisfactiondisplayed"></a>

Triggered when the satisfaction survey is displayed to the visitor.

#### **Example:**

```javascript
window.iAdvizeCallbacks = {
  ...window.iAdvizeCallbacks,
  
  onSatisfactionDisplayed() {
    // Satisfaction survey displayed to the visitor
    ...
  }
  
};
```

## onSatisfactionAnswered <a href="#onsatisfactionanswered" id="onsatisfactionanswered"></a>

Triggered when the visitor has answered **all** the questions in the satisfaction survey.

#### **Example:**

```javascript
window.iAdvizeCallbacks = {
  ...window.iAdvizeCallbacks,
  
  onSatisfactionAnswered() {
    // Satisfaction survey answered by the visitor
    ...
  }
  
};
```


---

# 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.iadvize.dev/technologies/web-and-mobile-sdk/javascript-callbacks/reference.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.
