Skip to content

Commit d648e50

Browse files
committed
docs: Add documentation for chat window default open and chat history hook
1 parent f686a18 commit d648e50

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

docs/api/hooks.md

+26
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Below is a list of available hooks along with a brief description for each of th
8383
| Name | Description |
8484
| ------------------- | --------------------------------------------------------------------------------------- |
8585
| useAudio | Manages audio functionalities, such as toggling audio on or off. |
86+
| useChatHistory | Handles loading, retrieving and setting of chat history messages. |
8687
| useChatWindow | Manages the state of the chatbot window (open/close). |
8788
| useFirstInteraction | Detects and tracks the user's first interaction with the chatbot. |
8889
| useFlow | Allows getting and restarting chatbot flow and tracks if flow has started. |
@@ -125,6 +126,31 @@ const MyNestedComponent = () => {
125126
};
126127
```
127128

129+
### useChatHistory
130+
131+
#### Description
132+
The `useChatHistory` hook allows you to show, retrieve and set chat history messages.
133+
134+
#### Return Values
135+
| Name | Type | Description |
136+
| ------------------- | ---------- | ------------------------------------------------------------- |
137+
| showChatHistory | `function` | Shows the chat history messages on the chatbot. |
138+
| getHistoryMessages | `function` | Retrieves the chat history messages. |
139+
| setHistoryMessages | `function` | Sets the chat history messages (note that this is permanent). |
140+
141+
#### Code Example
142+
```jsx
143+
import { useChatHistory } from "react-chatbotify";
144+
145+
const MyNestedComponent = () => {
146+
const { showChatHistory } = useChatHistory();
147+
148+
return (
149+
<button onClick={showChatHistory}></button>
150+
)
151+
};
152+
```
153+
128154
### useChatWindow
129155

130156
#### Description

docs/api/settings.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ Properties here handle the UI/UX in the chat window. Note that it is recommended
269269
| showMessagePrompt | `boolean` | true | Specifies whether to show a message prompt when new messages are received while a user is scrolling the window. |
270270
| messagePromptText | `string` | "New Messages ↓" | The text to be displayed on the message prompt shown. |
271271
| messagePromptOffset | `number` | 30 | The offset (in pixels) that the user must be from the bottom of the chat window to be considered scrolling and thus see the message prompt (recommended to keep at `30` or higher). |
272-
| defaultOpen | `boolean` | false | Specifies whether the chat window should be open by default. |
272+
| defaultOpen | `boolean` | false | Specifies whether the chat window should be open by default (ignored if chatbot is embedded). |
273273

274274
### chatHistory
275275

0 commit comments

Comments
 (0)