@telia-ace/widget-conversation 1.0.15 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +5 -5
- package/README.md +273 -256
- package/dist/agent.d.ts +17 -17
- package/dist/{ui → components}/conversation/conversation.d.ts +6 -6
- package/dist/{ui/conversation/conversation-component.d.ts → components/conversation/plugin.d.ts} +43 -37
- package/dist/components/conversation/ui/content.d.ts +2 -0
- package/dist/{ui/conversation/conversation-input.d.ts → components/conversation/ui/input.d.ts} +6 -6
- package/dist/{ui/conversation/conversation-loader.d.ts → components/conversation/ui/loader.d.ts} +8 -8
- package/dist/components/conversation/ui/message-list-items/button-list.d.ts +8 -0
- package/dist/{ui/conversation/message-types/custom-message-list-item.d.ts → components/conversation/ui/message-list-items/custom.d.ts} +9 -9
- package/dist/components/conversation/ui/message-list-items/html.d.ts +5 -0
- package/dist/components/conversation/ui/message-list-items/link-list.d.ts +8 -0
- package/dist/components/conversation/ui/message-list-items/separator.d.ts +2 -0
- package/dist/components/conversation/ui/message-list-items/text.d.ts +6 -0
- package/dist/{ui/conversation → components/conversation/ui}/message-types/agent.d.ts +11 -11
- package/dist/{ui/conversation → components/conversation/ui}/message-types/index.d.ts +4 -5
- package/dist/components/conversation/ui/message-types/message-list.d.ts +9 -0
- package/dist/{ui/conversation → components/conversation/ui}/message-types/system.d.ts +12 -12
- package/dist/{ui/conversation → components/conversation/ui}/message-types/timestamp.d.ts +8 -8
- package/dist/{ui/conversation → components/conversation/ui}/message-types/user.d.ts +8 -8
- package/dist/components/conversation/ui/message.d.ts +7 -0
- package/dist/components/conversation/ui/overlay-outlets.d.ts +13 -0
- package/dist/components/conversation/ui/styles.d.ts +27 -0
- package/dist/{ui/return-button/return-button-component.d.ts → components/return-button/plugin.d.ts} +18 -19
- package/dist/{ui → components}/return-button/return-button.d.ts +6 -6
- package/dist/conversation-controller.d.ts +88 -88
- package/dist/conversation-form-adapter.d.ts +7 -7
- package/dist/conversation-platform.d.ts +49 -50
- package/dist/conversation-provider.d.ts +22 -22
- package/dist/conversation.js +862 -118
- package/dist/conversation.js.map +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.js +885 -9
- package/dist/index.js.map +1 -1
- package/dist/resolve-entity-value.d.ts +10 -10
- package/dist/return-button.js.map +1 -1
- package/dist/types.d.ts +96 -110
- package/dist/user.d.ts +7 -7
- package/dist/utils/custom-message.d.ts +3 -3
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/map-actions.d.ts +1 -0
- package/dist/utils/open-chat-widget.d.ts +4 -4
- package/package.json +8 -8
- package/dist/index2.js +0 -1678
- package/dist/index2.js.map +0 -1
- package/dist/ui/conversation/conversation-content.d.ts +0 -12
- package/dist/ui/conversation/conversation-message.d.ts +0 -7
- package/dist/ui/conversation/conversation-styles.d.ts +0 -11
- package/dist/ui/conversation/index.d.ts +0 -3
- package/dist/ui/conversation/message-types/custom.d.ts +0 -9
- package/dist/ui/index.d.ts +0 -2
- package/dist/ui/return-button/index.d.ts +0 -2
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Copyright © 2021, Telia Company AB. All rights reserved.
|
|
2
|
-
|
|
3
|
-
THIS PACKAGE AND CONTAINING SOFTWARE IS PART OF
|
|
4
|
-
THE HUMANY SERVICE. BY USING THIS SOFTWARE YOU
|
|
5
|
-
AGREE TO THE FOLLOWING TERMS AND CONDITIONS:
|
|
1
|
+
Copyright © 2021, Telia Company AB. All rights reserved.
|
|
2
|
+
|
|
3
|
+
THIS PACKAGE AND CONTAINING SOFTWARE IS PART OF
|
|
4
|
+
THE HUMANY SERVICE. BY USING THIS SOFTWARE YOU
|
|
5
|
+
AGREE TO THE FOLLOWING TERMS AND CONDITIONS:
|
|
6
6
|
http://www.humany.com/legal
|
package/README.md
CHANGED
|
@@ -1,256 +1,273 @@
|
|
|
1
|
-
# Widget Conversation API
|
|
2
|
-
|
|
3
|
-
The Widget Conversation API provides support for reading and writing to a conversational component inside a widget.
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
We do not recommend binding functions to the `
|
|
10
|
-
|
|
11
|
-
[](https://codesandbox.io/s/elegant-jones-rnyrd?fontsize=14&hidenavigation=1&theme=dark)
|
|
12
|
-
|
|
13
|
-
## Accessing the API
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
platform.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
#### Example
|
|
162
|
-
|
|
163
|
-
```ts
|
|
164
|
-
conversation.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
The
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
1
|
+
# Widget Conversation API
|
|
2
|
+
|
|
3
|
+
The Widget Conversation API provides support for reading and writing to a conversational component inside a widget.
|
|
4
|
+
|
|
5
|
+
## Sandbox
|
|
6
|
+
|
|
7
|
+
For demonstration purposes, we've set up a sandbox for the Widget Conversational API so that you can see it in action. Keep in mind that this is for demonstration purposes only and may not reflect best practice.
|
|
8
|
+
|
|
9
|
+
> We do not recommend binding functions to the `window` object.
|
|
10
|
+
|
|
11
|
+
[](https://codesandbox.io/s/elegant-jones-rnyrd?fontsize=14&hidenavigation=1&theme=dark)
|
|
12
|
+
|
|
13
|
+
## Accessing the API
|
|
14
|
+
|
|
15
|
+
In order to access the API you need to have a widget with a conversational component.
|
|
16
|
+
|
|
17
|
+
### Creating the plugin
|
|
18
|
+
|
|
19
|
+
You need to register the conversational provider in the `providers`-property in the component. To access the global instance of `ConversationPlatform`, you pass in the current `Container` to the `getInstance()` method. It will return a `Promise` that is resolved to the `ConversationPlatform` instance. In the instance, register a provider and pass in name and handler by calling the `registerProvider()` function as shown below.
|
|
20
|
+
|
|
21
|
+
The handler function will be called once a conversational component for the specified provider is activated in the widget. Use the provider to interact with the conversation.
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { ConversationPlatform } from '@telia-ace/widget-conversation';
|
|
25
|
+
|
|
26
|
+
const MyPlugin = async (container) => {
|
|
27
|
+
const platform = await ConversationPlatform.getInstance(container);
|
|
28
|
+
|
|
29
|
+
platform.registerProvider('my-chat', (conversation, component) => {
|
|
30
|
+
// start interacting with the conversation here
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
You also need to register the provider inside the widget configuration:
|
|
36
|
+
|
|
37
|
+
```JSON
|
|
38
|
+
"my-conversation-component": {
|
|
39
|
+
"type": "conversation",
|
|
40
|
+
"properties": {
|
|
41
|
+
"providers": ["my-chat"],
|
|
42
|
+
// ...
|
|
43
|
+
},
|
|
44
|
+
"context": {}
|
|
45
|
+
},
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Creating an agent in the conversation
|
|
49
|
+
|
|
50
|
+
When using `createAgent` you can specify both a name and an avatar. These will then be displayed in the conversation alongside that agent's entries.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
const agent = conversation.createAgent({
|
|
54
|
+
name: 'Agent Smith',
|
|
55
|
+
avatar: 'https://www.site.com/avatar.jpg',
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Writing to the conversation
|
|
60
|
+
|
|
61
|
+
### Posting, updating and removing content
|
|
62
|
+
|
|
63
|
+
When managing content in the conversation you'll first need to create an `Agent`-object and then use its `print()` function. There are serveral types of entries in order to accommedate different types of content.
|
|
64
|
+
|
|
65
|
+
The `print(content: object)` function let's you return a `ConversationEntry` message that can be used to update and/or remove the content from the conversation.
|
|
66
|
+
|
|
67
|
+
##### Example of simple text message
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
// print user message
|
|
71
|
+
conversation.user.print('Lorem ipsum');
|
|
72
|
+
|
|
73
|
+
// print agent message
|
|
74
|
+
const agent = conversation.createAgent();
|
|
75
|
+
agent.print('Lorem ipsum');
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
##### Example of updating or removing content
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
const agent = conversation.createAgent();
|
|
82
|
+
const entry = agent.print('Hello world!');
|
|
83
|
+
|
|
84
|
+
entry.update({
|
|
85
|
+
// ...
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
entry.remove();
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Entry with list of actions
|
|
92
|
+
|
|
93
|
+
You can post an entry into the conversation with actions. You can specify a title, body and available actions. This is only supported for the `Agent` and will be displayed as a system message.
|
|
94
|
+
|
|
95
|
+
| Name | Type | Description |
|
|
96
|
+
| --------- | -------- | ------------------------------------------------------------- |
|
|
97
|
+
| `title` | `string` | Title for the entry. |
|
|
98
|
+
| `body` | `string` | Body content for the entry. Supports HTML. |
|
|
99
|
+
| `actions` | `object` | Key-value-pairs representing available actions for the entry. |
|
|
100
|
+
|
|
101
|
+
##### Example of a list of actions
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
agent.print({
|
|
105
|
+
title: 'Download invoices',
|
|
106
|
+
body: 'Click an invoice below to download a copy.',
|
|
107
|
+
actions: {
|
|
108
|
+
invoice_190201: 'Invoice 190201',
|
|
109
|
+
invoice_190301: 'Invoice 190301',
|
|
110
|
+
invoice_190401: 'Invoice 190401',
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Entry with a form
|
|
116
|
+
|
|
117
|
+
You can also post a message with a form attached. This uses the `FormBuilder`-method. This is handled by the `conversation.form` event. It is only supported for `Agent` and will be displayed as a system message.
|
|
118
|
+
|
|
119
|
+
| Name | Type | Description |
|
|
120
|
+
| ------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
121
|
+
| `title` | `string` | Title for the entry. |
|
|
122
|
+
| `body` | `string` | Body content for the entry. Supports HTML. |
|
|
123
|
+
| `form` | `(FormBuilder) => void` | A callback function for building the form. Refer to the [`@telia-ace/widget-forms`](https://www.npmjs.com/package/@telia-ace/widget-forms) package for more information about `FormBuilder`. |
|
|
124
|
+
| `key` | `string` | The key used to refer to the form when validating and submitting the form. |
|
|
125
|
+
|
|
126
|
+
##### Example of an entry with a form
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
agent.print({
|
|
130
|
+
title: 'Log in',
|
|
131
|
+
body: 'Enter your ID to login',
|
|
132
|
+
key: 'my-login-form',
|
|
133
|
+
form: (builder) => {
|
|
134
|
+
builder
|
|
135
|
+
.createComponent({
|
|
136
|
+
component: 'Text',
|
|
137
|
+
type: 'number',
|
|
138
|
+
name: 'id',
|
|
139
|
+
title: 'ID',
|
|
140
|
+
required: true,
|
|
141
|
+
})
|
|
142
|
+
.createComponent({
|
|
143
|
+
title: 'Log in',
|
|
144
|
+
actionKey: 'submit',
|
|
145
|
+
name: 'submit',
|
|
146
|
+
component: 'Submit',
|
|
147
|
+
type: 'submit',
|
|
148
|
+
evaluate: true,
|
|
149
|
+
value: 'Log in',
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### The loading and typing indicators
|
|
156
|
+
|
|
157
|
+
When you need to fetch data from external resource you should use the `loading()` function on the `ConversationProvider` to inform the user that something is about to happen. Even in cases when the response is available immediately it gives a better user experience to present a loading indicator for a short while.
|
|
158
|
+
|
|
159
|
+
When you need to make the user aware that your agent is currently typing, you should use the `typing` function on `Agent`.
|
|
160
|
+
|
|
161
|
+
#### Example of `loading`
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
const done = conversation.loading();
|
|
165
|
+
// ...
|
|
166
|
+
done(); // remove loader
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### Example of `typing`
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
const done = agent.typing();
|
|
173
|
+
// ...
|
|
174
|
+
done(); // remove loader
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Writing system messages
|
|
178
|
+
|
|
179
|
+
System message in the conversation are sent by using the `print` method on the `conversation`. The `print` method accepts the same arguments as on the `Agent`.
|
|
180
|
+
|
|
181
|
+
#### Example
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
conversation.print('Hello world!');
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Reading from the conversation
|
|
188
|
+
|
|
189
|
+
The second parameter to your provider handler is a `ComponentNode` instance representing the conversational component. From it you can read the component's properties and react to action emitted by the component.
|
|
190
|
+
|
|
191
|
+
The following actions are emitted from the conversational component:
|
|
192
|
+
|
|
193
|
+
> For default actions it is necessary to call `next()` unless you want to completely stop the execution flow for the particular action. Not doing so will stop any succeeding handlers and may unintentionally break functionality.
|
|
194
|
+
|
|
195
|
+
| Action | Name | Type | Description |
|
|
196
|
+
| -------------------------- | ------------ | ---------- | --------------------------------------------------------- |
|
|
197
|
+
| `conversation.user-typing` | `textLength` | `number` | The current text length of the user's message. |
|
|
198
|
+
| `conversation.user-submit` | `text` | `string` | The submitted text. |
|
|
199
|
+
| `conversation.action` | `text` | `string` | Key of the submitted action. |
|
|
200
|
+
| `conversation.form` | `data` | `FormData` | The form data. |
|
|
201
|
+
| `conversation.form` | `formKey` | `string` | The unique key for the form. |
|
|
202
|
+
| `conversation.form` | `actionKey` | `string` | The key of the form component responsible for the change. |
|
|
203
|
+
|
|
204
|
+
If you want to subscribe to any of the `conversation.form`-actions you have access to the `ComponentNodeController`. Example below:
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
component.actions.watch('conversation.form', (input, next) => {
|
|
208
|
+
return next(input);
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Submitting forms
|
|
213
|
+
|
|
214
|
+
If you want to listen for form events you should subscribe to the `conversation.form` event. By passing a `key` to the form, you are able to target the form in this listener.
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
component.actions.watch('conversation.form', (input, next) => {
|
|
218
|
+
if (input.formKey === 'my-login-form' && input.actionKey === 'submit') {
|
|
219
|
+
const username = input.data.username;
|
|
220
|
+
const password = input.data.password;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return next(input);
|
|
224
|
+
});
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Adding custom list items
|
|
228
|
+
|
|
229
|
+
You can add custom list items to the conversation. To do so you have to register your own custom React component, which will be mapped to a key also provided by you.
|
|
230
|
+
|
|
231
|
+
#### Example of custom list items
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
import { registerCustomMessageComponent } from '@telia-ace/widget-conversation';
|
|
235
|
+
|
|
236
|
+
registerCustomMessageComponent(container, 'my-custom-list-item', import('./my-custom-list-item'));
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Once the component has been registered it will be available to be used as any other item in the `print` method on the Conversation API.
|
|
240
|
+
|
|
241
|
+
## Custom secondary action
|
|
242
|
+
|
|
243
|
+
You can add a secondary action button that's displayed next to the user input field. This button can run any event that you write. You need to add the `secondaryAction` property to the conversation component in the configuration. It accepts an object with the following properties:
|
|
244
|
+
|
|
245
|
+
| Name | Type | Description |
|
|
246
|
+
| -------- | -------- | ------------------------------------------------------------------- |
|
|
247
|
+
| `action` | `string` | An action that will be dispatched when the button is pressed |
|
|
248
|
+
| `label` | `string` | Will be used as a "title" and aria-label on the HTML button element |
|
|
249
|
+
| `icon` | `string` | An icon to be displayed, defaults to "browse" icon if left empty |
|
|
250
|
+
|
|
251
|
+
```json
|
|
252
|
+
"conversation": {
|
|
253
|
+
"type": "conversation",
|
|
254
|
+
"properties": {
|
|
255
|
+
"secondaryAction": {
|
|
256
|
+
"action": "my-secondary-action",
|
|
257
|
+
"label": "Label for the secondary action",
|
|
258
|
+
"icon": "my-icon"
|
|
259
|
+
}
|
|
260
|
+
// ...other properties
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
When you have added this property to the component, you can create an event for it in your code:
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
component.actions.watch('conversation.action', (input, next) => {
|
|
269
|
+
if (input === 'my-secondary-action') {
|
|
270
|
+
// handle action
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
```
|
package/dist/agent.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Symbol } from '@telia-ace/widget-ui';
|
|
2
|
-
import { ConversationEntry } from './conversation-controller';
|
|
3
|
-
import { ConversationProvider } from './conversation-provider';
|
|
4
|
-
import { ConversationMessageSettings, ConverstationMessageItem } from './types';
|
|
5
|
-
export declare type AgentSettings = {
|
|
6
|
-
name?: string;
|
|
7
|
-
avatar?: string | Symbol;
|
|
8
|
-
};
|
|
9
|
-
export declare class Agent {
|
|
10
|
-
private provider;
|
|
11
|
-
name?: string;
|
|
12
|
-
avatar?: string | Symbol;
|
|
13
|
-
constructor(provider: ConversationProvider, settings: AgentSettings);
|
|
14
|
-
print: (settings: string | ConversationMessageSettings | ConverstationMessageItem<any> | ConverstationMessageItem<any>[]) => ConversationEntry | undefined;
|
|
15
|
-
typing: () => (() => void) | undefined;
|
|
16
|
-
update(settings: AgentSettings): void;
|
|
17
|
-
}
|
|
1
|
+
import { Symbol } from '@telia-ace/widget-ui';
|
|
2
|
+
import { ConversationEntry } from './conversation-controller';
|
|
3
|
+
import { ConversationProvider } from './conversation-provider';
|
|
4
|
+
import { ConversationMessageSettings, ConverstationMessageItem } from './types';
|
|
5
|
+
export declare type AgentSettings = {
|
|
6
|
+
name?: string;
|
|
7
|
+
avatar?: string | Symbol;
|
|
8
|
+
};
|
|
9
|
+
export declare class Agent {
|
|
10
|
+
private provider;
|
|
11
|
+
name?: string;
|
|
12
|
+
avatar?: string | Symbol;
|
|
13
|
+
constructor(provider: ConversationProvider, settings: AgentSettings);
|
|
14
|
+
print: (settings: string | ConversationMessageSettings | ConverstationMessageItem<any> | ConverstationMessageItem<any>[]) => ConversationEntry | undefined;
|
|
15
|
+
typing: () => (() => void) | undefined;
|
|
16
|
+
update(settings: AgentSettings): void;
|
|
17
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
declare type Props = {
|
|
3
|
-
className: string;
|
|
4
|
-
};
|
|
5
|
-
declare const Conversation: React.FC<Props>;
|
|
6
|
-
export default Conversation;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare type Props = {
|
|
3
|
+
className: string;
|
|
4
|
+
};
|
|
5
|
+
declare const Conversation: React.FC<Props>;
|
|
6
|
+
export default Conversation;
|