Skip to content

Commit 1fa83dd

Browse files
committed
docs: Minor updates
1 parent 89b1183 commit 1fa83dd

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

docs/api/events.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Below is a list of available events with a brief description for each one. You c
2222
| RcbChangePathEvent | Emitted when the chatbot changes its conversation path. |
2323
| RcbChunkStreamMessageEvent | Emitted when a chunk of a streamed message is received. |
2424
| RcbDismissToastEvent | Emitted when a toast message is dismissed. |
25+
| RcbSaveChatHistoryEvent | Emitted when chat messages are saved to history. |
2526
| RcbLoadChatHistoryEvent | Emitted when the chat history is loaded. |
2627
| RcbPostInjectMessageEvent | Emitted after a message is injected into the chat. |
2728
| RcbPreInjectMessageEvent | Emitted before a message is injected into the chat. |
@@ -175,6 +176,43 @@ const MyComponent = () => {
175176
};
176177
```
177178

179+
### RcbSaveChatHistoryEvent
180+
181+
#### Description
182+
Emitted when chat messages are saved to history.
183+
184+
#### Note
185+
- Requires `settings.event.rcbSaveChatHistory` to be set to true.
186+
- Event is **preventable** with `event.preventDefault()`.
187+
188+
#### Data
189+
| Name | Type | Description |
190+
|-----------|--------------|-----------------------------------------------------------------|
191+
| messages | `Message[]` | The chat messages being saved to history. |
192+
193+
#### Code Example
194+
```jsx
195+
import { useEffect } from "react";
196+
import { RcbSaveChatHistoryEvent } from "react-chatbotify";
197+
198+
const MyComponent = () => {
199+
useEffect(() => {
200+
const handleSaveChatHistory = (event: RcbSaveChatHistoryEvent) => {
201+
// handle the save chat history event
202+
};
203+
204+
window.addEventListener("rcb-save-chat-history", handleSaveChatHistory);
205+
return () => {
206+
window.removeEventListener("rcb-save-chat-history", handleSaveChatHistory);
207+
};
208+
}, []);
209+
210+
return (
211+
<ExampleComponent/>
212+
);
213+
};
214+
```
215+
178216
### RcbLoadChatHistoryEvent
179217

180218
#### Description

docs/api/settings.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ const DefaultSettings: Settings = {
183183
rcbChunkStreamMessage: false,
184184
rcbStopStreamMessage: false,
185185
rcbRemoveMessage: false,
186+
rcbSaveChatHistory: false,
186187
rcbLoadChatHistory: false,
187188
rcbToggleChatWindow: false,
188189
rcbToggleAudio: false,
@@ -384,6 +385,7 @@ Properties here handle the events emitted by the chatbot. All events have a defa
384385
| RcbChangePath | `boolean` | false | Specifies whether the `RcbChangePathEvent` will be emitted. |
385386
| RcbChunkStreamMessage | `boolean` | false | Specifies whether the `RcbChunkStreamMessageEvent` will be emitted. |
386387
| RcbDismissToast | `boolean` | false | Specifies whether the `RcbDismissToastEvent` will be emitted. |
388+
| RcbSaveChatHistory | `boolean` | false | Specifies whether the `RcbSaveChatHistoryEvent` will be emitted. |
387389
| RcbLoadChatHistory | `boolean` | false | Specifies whether the `RcbLoadChatHistoryEvent` will be emitted. |
388390
| RcbPostInjectMessage | `boolean` | false | Specifies whether the `RcbPostInjectMessageEvent` will be emitted. |
389391
| RcbPreInjectMessage | `boolean` | false | Specifies whether the `RcbPreInjectMessageEvent` will be emitted. |

0 commit comments

Comments
 (0)