Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Add livechat events #224

Merged
merged 1 commit into from
Feb 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions 6. Developer Guides/Livechat API/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,87 @@ RocketChat(function() {
});
```

### Events

#### _onChatMaximized_
Fired when the chat widget is maximized.

```javascript
RocketChat(function() {
this.onChatMaximized(function() {
// do whatever you want
console.log('chat widget maximized');
});
});
```

#### _onChatMinimized_
Fired when the chat widget is minimized.

```javascript
RocketChat(function() {
this.onChatMinimized(function() {
// do whatever you want
console.log('chat widget minimized');
});
});
```

#### _onChatStarted_
Fired when the chat is started (the first message was sent).

```javascript
RocketChat(function() {
this.onChatStarted(function() {
// do whatever you want
console.log('chat started');
});
});
```

#### _onChatEnded_
Fired when the chat is ended either by the agent or the visitor.

```javascript
RocketChat(function() {
this.onChatEnded(function() {
// do whatever you want
console.log('chat ended');
});
});
```

#### _onPrechatFormSubmit_
Fired when the pre-chat form is submitted.

```javascript
RocketChat(function() {
this.onPrechatFormSubmit(function(data) {
// data is an object containing the following fields: name, email and deparment (the department _id)

// do whatever you want
console.log('pre-chat form submitted');
});
});
```

#### _onOfflineFormSubmit_
Fired when the offline form is submitted.

```javascript
RocketChat(function() {
this.onOfflineFormSubmit(function(data) {
// data is an object containing the following fields: name, email and message

// do whatever you want
console.log('offline form submitted');
});
});
```

## Change Log
| Version | Description |
| :--- | :--- |
| 0.53.0 | Added callback events and the ability to pass a flag to `setCustomField` so the value passed does not get wrote if there is already an existing value. |
| 0.36.0 | Added `setTheme` method |
| 0.26.0 | Added `setCustomField` method |