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
+100-25
Original file line number
Diff line number
Diff line change
@@ -19,28 +19,30 @@ Before adding your own listeners with custom logic for events, it may be helpful
19
19
20
20
Below is a list of available events with a brief description for each one. You can use these events to listen for and respond to key interactions in the chatbot.
| message |`Message`| The message being sent into the chat. |
260
-
| simStreamChunker |`function`\|`null`| A custom function to parse messages for simulated streaming |
261
-
262
-
Note: The `simStreamChunker` function takes in a string and returns an array of strings. By default, this field is null and strings are split per-character. A custom function can be passed in to control how simulated streaming is carried out. For example, in the implementation of the [**HTML Renderer Plugin**](https://www.npmjs.com/package/@rcb-plugins/html-renderer), a custom function is passed in to skip over html tags when simulating message stream.
263
262
264
263
#### Code Example
265
264
```jsx
@@ -358,6 +357,82 @@ const MyComponent = () => {
358
357
};
359
358
```
360
359
360
+
### RcbStartSimulateStreamMessageEvent
361
+
362
+
#### Description
363
+
Emitted when the chatbot starts simulating streaming a message.
364
+
365
+
#### Note
366
+
- Requires `settings.event.rcbStartSimulateStreamMessage` to be set to true.
367
+
- Event is **preventable** with `event.preventDefault()`.
| message |`Message`| The full message that will be used for simulated streaming. |
373
+
| simulateStreamChunker |`function`\|`null`| A custom function to parse messages for simulated streaming. |
374
+
375
+
Note: The `simulateStreamChunker` function takes in a string and returns an array of strings. By default, this field is null and strings are split per-character. A custom function can be passed in to control how simulated streaming is carried out. For example, in the implementation of the [**HTML Renderer Plugin**](https://www.npmjs.com/package/@rcb-plugins/html-renderer), a custom function is passed in to skip over html tags when simulating message stream.
Copy file name to clipboardExpand all lines: docs/api/params.md
+31-6
Original file line number
Diff line number
Diff line change
@@ -20,8 +20,9 @@ The following table provides details about the parameters available for attribut
20
20
| prevPath |`string`| All Attributes | Represents the previous path in the chat (can be null if no previous path exists). |
21
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
-
| 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
-
| endStreamMessage |`async function`| All Attributes | Ends an existing message stream. You can refer to the [**Real-Time Streaming**](/docs/examples/real_time_stream) example. |
23
+
| simulateStreamMessage |`async function`| All Attributes | Simulates streaming a message into the chat. You can refer to the [**Simulated Stream**](/docs/examples/simulated_stream) example. |
24
+
| streamMessage |`async function`| All Attributes | Streams a message into the chat. You can refer to the [**Real-Time Stream**](/docs/examples/real_time_stream) example. |
25
+
| endStreamMessage |`async function`| All Attributes | Ends an existing message stream. You can refer to the [**Real-Time Stream**](/docs/examples/real_time_stream) example. |
25
26
| removeMessage |`async function`| All Attributes | Removes a message from the chat by message id. |
26
27
| setTextAreaValue|`async function`| All Attributes | Sets a value directly within the text area. |
27
28
| showToast |`async function`| All Attributes | Shows a toast that is dismissed after a duration or on user click. |
@@ -135,6 +136,30 @@ start: {
135
136
}
136
137
```
137
138
139
+
### simulateStreamMessage
140
+
141
+
#### Description
142
+
Simulates streaming a message into the chat. This works by taking the entire text string and splitting it up to insert into the chat bubbble. For a detailed example on how to use this parameter, refer to the [**simulated stream**](/docs/examples/simulated_stream) example.
143
+
144
+
#### Type
145
+
`async function`
146
+
147
+
#### Parameters
148
+
-`content` (required): a `string` value containing the text to simulate stream for.
149
+
-`sender` (optional): a `string` value representing the sender of the message (`user` or `bot`). Defaults to `bot`.
150
+
-`simulateStreamChunker` (optional): a `function` containing logic for chunking text content for streaming.
151
+
152
+
#### Code Example
153
+
```jsx
154
+
start: {
155
+
message: (params) => {
156
+
// take for example the text below is streamed in character by character
157
+
consttextToStream="I'm just an example text"
158
+
awaitparams.simulateStreamMessage(textToStream);
159
+
}
160
+
}
161
+
```
162
+
138
163
### streamMessage
139
164
140
165
#### Description
@@ -153,9 +178,9 @@ start: {
153
178
message: (params) => {
154
179
// take for example the text below is streamed in character by character
155
180
consttextToStream="I'm just an example text"
156
-
for (let i =0; i <text.length; i++) {
181
+
for (let i =0; i <textToStream.length; i++) {
157
182
// this call replaces the last message sent by the bot with the new content
158
-
awaitparams.streamMessage(text.slice(0, i +1));
183
+
awaitparams.streamMessage(textToStream.slice(0, i +1));
159
184
}
160
185
// to end the stream once we're done streaming
161
186
awaitparams.endStreamMessage();
@@ -180,9 +205,9 @@ start: {
180
205
message: (params) => {
181
206
// take for example the text below is streamed in character by character
182
207
consttextToStream="I'm just an example text"
183
-
for (let i =0; i <text.length; i++) {
208
+
for (let i =0; i <textToStream.length; i++) {
184
209
// this call replaces the last message sent by the bot with the new content
185
-
awaitparams.streamMessage(text.slice(0, i +1));
210
+
awaitparams.streamMessage(textToStream.slice(0, i +1));
0 commit comments