You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/events.md
+3-1
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,9 @@ Events emitted by the chatbot provide the following **details** accessible via `
51
51
| currPath |`string`| Represents the current path of the user. |
52
52
| prevPath |`string`| Represents the previous path of the user. |
53
53
54
-
In addition, all events also contain **event-specific data** that are accessible via `event.data`. You may manipulate the data directly which will be reflected in the result of the event (e.g. modifying the content of a `RcbPreMessageInjectEvent` will modify the message sent).
54
+
In addition, chatbot events are also initialized with **an empty promises array**, accessible via `event.promises`. This caters for use cases where event handlers are **async and require promises to be resolved before proceeding** with the chatbot logic. Push promises into `event.promises` to preserve the chatbot flow logic.
55
+
56
+
Lastly, all events also contain **event-specific data** that are accessible via `event.data`. You may manipulate the data directly which will be reflected in the result of the event (e.g. modifying the content of a `RcbPreMessageInjectEvent` will modify the message sent). For an example on how to use events, you may take a look at the [**custom events**](/docs/examples/custom_events) example.
55
57
56
58
Below is a detailed description of each event and how to use them.
| notificationsToggledOn |`boolean `| Indicates if the chatbot notifications is currently on or off. |
303
-
| toggleNotifications |`function`| Toggles the chatbot notifications on or off. |
303
+
| toggleNotifications |`async function`| Toggles the chatbot notifications on or off. |
304
304
| playNotificationSound |`function`| Plays the notification sound. |
305
305
306
306
#### Code Example
@@ -426,7 +426,7 @@ The `useTextArea` hook allows you to track and manage the chatbot's text area fi
426
426
| textAreaSensitiveMode | `boolean` | Indicates if the text area is in sensitive mode. |
427
427
| toggleTextAreaSensitiveMode | `function` | Toggles the text area sensitive mode. |
428
428
| getTextAreaValue | `function` | Retrieves the string value inside the text area. |
429
-
| setTextAreaValue | `function` | Sets the value inside the text area, identical to `params.setTextAreaValue` detailed [**here**](/docs/api/params#settextareavalue). |
429
+
| setTextAreaValue | `asyncfunction` | Sets the value inside the text area, identical to `params.setTextAreaValue` detailed [**here**](/docs/api/params#settextareavalue). |
430
430
| focusTextArea | `function` | Focuses on the text area. |
431
431
432
432
#### Code Example
@@ -456,8 +456,8 @@ The `useToasts` hook allows you to track and manage the chatbot's toasts.
Copy file name to clipboardExpand all lines: docs/api/params.md
+20-20
Original file line number
Diff line number
Diff line change
@@ -18,20 +18,20 @@ The following table provides details about the parameters available for attribut
18
18
| userInput |`string`| All Attributes | Represents the user's input in the chat. |
19
19
| currPath |`string`| All Attributes | Represents the current path in the chat (can be null if conversation flow has not started). |
20
20
| prevPath |`string`| All Attributes | Represents the previous path in the chat (can be null if no previous path exists). |
21
-
| goToPath |`function`| All Attributes | A utility function for navigating to another block. |
21
+
| goToPath |`async function`| All Attributes | A utility function for navigating to another block. |
22
22
| injectMessage |`async function`| All Attributes | A utility function to inject a message into the chat. |
23
23
| streamMessage |`async function`| All Attributes | Streams a message into the chat. You can refer to the [**Real-Time Streaming**](/docs/examples/real_time_stream) example. |
24
24
| endStreamMessage |`async function`| All Attributes | Ends an existing message stream. You can refer to the [**Real-Time Streaming**](/docs/examples/real_time_stream) example. |
25
25
| removeMessage |`async function`| All Attributes | Removes a message from the chat by message id. |
26
-
| setTextAreaValue|`function`| All Attributes | Sets a value directly within the text area. |
27
-
| showToast |`function`| All Attributes | Shows a toast that is dismissed after a duration or on user click. |
28
-
| dismissToast |`function`| All Attributes | Dismisses a toast by toast id. |
29
-
| openChat |`function`| All Attributes | Opens or closes the chat component. |
26
+
| setTextAreaValue|`async function`| All Attributes | Sets a value directly within the text area. |
27
+
| showToast |`async function`| All Attributes | Shows a toast that is dismissed after a duration or on user click. |
28
+
| dismissToast |`async function`| All Attributes | Dismisses a toast by toast id. |
29
+
| openChat |`async function`| All Attributes | Opens or closes the chat component. |
30
30
| files |`FileList`| Only `file` Attribute | Represents the files uploaded by the user. |
31
31
32
32
:::caution Caution
33
33
34
-
If you are using `params.injectMessage`, `params.streamMessage`,`params.endStreamMessage` or `params.removeMessage`, do remember that they are `async` and that without using `await`, behavior may be unexpected (e.g. multiple messages sent at once). This is a common pitfall!
34
+
If you are using functions from`params`, do remember that they are `async` and that without using `await`, behaviors may be unexpected (e.g. multiple messages sent at once). This is a common pitfall!
35
35
36
36
:::
37
37
@@ -216,16 +216,16 @@ start: {
216
216
Sets a value inside the input text area.
217
217
218
218
#### Type
219
-
`function`
219
+
`async function`
220
220
221
221
#### Parameters
222
222
-`value` (required): a `string` value to set inside the input text area.
223
223
224
224
#### Code Example
225
225
```jsx
226
226
start: {
227
-
message: (params) => {
228
-
params.setTextAreaValue("This is the new input text area value!");
227
+
message:async(params) => {
228
+
awaitparams.setTextAreaValue("This is the new input text area value!");
229
229
}
230
230
}
231
231
```
@@ -236,7 +236,7 @@ start: {
236
236
Shows a toast that lasts for a duration (if specified).
237
237
238
238
#### Type
239
-
`function`
239
+
`async function`
240
240
241
241
#### Parameters
242
242
-`content` (required): a `string` value representing the toast content to show.
@@ -245,8 +245,8 @@ Shows a toast that lasts for a duration (if specified).
245
245
#### Code Example
246
246
```jsx
247
247
start: {
248
-
message: (params) => {
249
-
params.showToast("Hello there, I last for 3 seconds!", 3000);
248
+
message:async(params) => {
249
+
awaitparams.showToast("Hello there, I last for 3 seconds!", 3000);
250
250
}
251
251
}
252
252
```
@@ -257,16 +257,16 @@ start: {
257
257
Dismisses a toast with the given toast id.
258
258
259
259
#### Type
260
-
`function`
260
+
`async function`
261
261
262
262
#### Parameters
263
263
-`id` (required): a `string` value representing the id of the toast to remove.
0 commit comments