@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.24 → 0.0.1-alpha.27

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.
@@ -33,6 +33,9 @@ var ContactMethodItem = function (props) {
33
33
  var container = useContainer();
34
34
  var _a = __read(useState(props.contactMethod.body), 2), body = _a[0], setBody = _a[1];
35
35
  useEffect(function () {
36
+ if (!container || !container.get('$widget')) {
37
+ return;
38
+ }
36
39
  var events = container.get('$widget').events;
37
40
  events.subscribe('form:validated', function (_event, _data) {
38
41
  // TODO: this is a due to props not being updated when props.contactMethod.body changes
@@ -1,6 +1,7 @@
1
1
  export declare enum ServerEntryTypeEnum {
2
2
  Widget = 0,
3
3
  Text = 1,
4
- List = 2,
5
- Error = 3
4
+ Contact = 2,
5
+ List = 3,
6
+ Error = 4
6
7
  }
@@ -2,6 +2,7 @@ export var ServerEntryTypeEnum;
2
2
  (function (ServerEntryTypeEnum) {
3
3
  ServerEntryTypeEnum[ServerEntryTypeEnum["Widget"] = 0] = "Widget";
4
4
  ServerEntryTypeEnum[ServerEntryTypeEnum["Text"] = 1] = "Text";
5
- ServerEntryTypeEnum[ServerEntryTypeEnum["List"] = 2] = "List";
6
- ServerEntryTypeEnum[ServerEntryTypeEnum["Error"] = 3] = "Error";
5
+ ServerEntryTypeEnum[ServerEntryTypeEnum["Contact"] = 2] = "Contact";
6
+ ServerEntryTypeEnum[ServerEntryTypeEnum["List"] = 3] = "List";
7
+ ServerEntryTypeEnum[ServerEntryTypeEnum["Error"] = 4] = "Error";
7
8
  })(ServerEntryTypeEnum || (ServerEntryTypeEnum = {}));
@@ -0,0 +1,375 @@
1
+ {
2
+ "ContactMethod": {
3
+ "Form": {
4
+ "Groups": [
5
+ {
6
+ "Components": [
7
+ {
8
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
9
+ "Name": "customer-id",
10
+ "HasCustomName": false,
11
+ "Type": "text/number",
12
+ "Value": "",
13
+ "Constraints": {
14
+ "Required": true,
15
+ "Regex": null,
16
+ "VerifyValue": false
17
+ },
18
+ "HasDependencies": false,
19
+ "Title": "Customer ID",
20
+ "Description": null,
21
+ "Hints": [],
22
+ "Visible": true,
23
+ "VisibilityCriteria": {
24
+ "Value": true,
25
+ "Negated": true,
26
+ "Description": null,
27
+ "Criteria": [],
28
+ "Operator": "And"
29
+ },
30
+ "HasDependants": false
31
+ },
32
+ {
33
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormGroupComponent, Humany.KnowledgeBase",
34
+ "Children": [
35
+ {
36
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
37
+ "Name": "first-name",
38
+ "HasCustomName": false,
39
+ "Type": "text/sentence",
40
+ "Value": "",
41
+ "Constraints": {
42
+ "Required": false,
43
+ "Regex": null,
44
+ "VerifyValue": false
45
+ },
46
+ "HasDependencies": false,
47
+ "Title": "First name",
48
+ "Description": null,
49
+ "Hints": ["firstname", "verifyLabel=Confirm First name"],
50
+ "Visible": true,
51
+ "VisibilityCriteria": {
52
+ "Value": true,
53
+ "Negated": true,
54
+ "Description": null,
55
+ "Criteria": [],
56
+ "Operator": "And"
57
+ },
58
+ "HasDependants": false
59
+ },
60
+ {
61
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
62
+ "Name": "last-name",
63
+ "HasCustomName": false,
64
+ "Type": "text/sentence",
65
+ "Value": "",
66
+ "Constraints": {
67
+ "Required": false,
68
+ "Regex": null,
69
+ "VerifyValue": false
70
+ },
71
+ "HasDependencies": false,
72
+ "Title": "Last name",
73
+ "Description": null,
74
+ "Hints": ["lastname"],
75
+ "Visible": true,
76
+ "VisibilityCriteria": {
77
+ "Value": true,
78
+ "Negated": true,
79
+ "Description": null,
80
+ "Criteria": [],
81
+ "Operator": "And"
82
+ },
83
+ "HasDependants": false
84
+ }
85
+ ],
86
+ "Title": "Name",
87
+ "Description": null,
88
+ "Hints": ["fullname"],
89
+ "Visible": true,
90
+ "VisibilityCriteria": {
91
+ "Value": true,
92
+ "Negated": true,
93
+ "Description": null,
94
+ "Criteria": [],
95
+ "Operator": "And"
96
+ },
97
+ "HasDependants": false
98
+ },
99
+ {
100
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormChoiceComponent, Humany.KnowledgeBase",
101
+ "UseCustomValues": false,
102
+ "Options": [
103
+ {
104
+ "Title": "CheckBox 1",
105
+ "Value": "CheckBox 1",
106
+ "Selected": false
107
+ },
108
+ {
109
+ "Title": "CheckBox 2",
110
+ "Value": "CheckBox 2",
111
+ "Selected": false
112
+ }
113
+ ],
114
+ "Name": "checkboxes",
115
+ "HasCustomName": false,
116
+ "Type": "choice",
117
+ "Value": "",
118
+ "Constraints": {
119
+ "Required": true,
120
+ "Regex": null,
121
+ "VerifyValue": false
122
+ },
123
+ "HasDependencies": true,
124
+ "Title": "Checkboxes",
125
+ "Description": null,
126
+ "Hints": ["checkbox", "multiple"],
127
+ "Visible": true,
128
+ "VisibilityCriteria": {
129
+ "Value": true,
130
+ "Negated": true,
131
+ "Description": null,
132
+ "Criteria": [],
133
+ "Operator": "And"
134
+ },
135
+ "HasDependants": false
136
+ },
137
+ {
138
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormChoiceComponent, Humany.KnowledgeBase",
139
+ "UseCustomValues": false,
140
+ "Options": [
141
+ {
142
+ "Title": "Test 1",
143
+ "Value": "Test 1",
144
+ "Selected": false
145
+ },
146
+ {
147
+ "Title": "Test 2",
148
+ "Value": "Test 2",
149
+ "Selected": false
150
+ }
151
+ ],
152
+ "Name": "select-one",
153
+ "HasCustomName": false,
154
+ "Type": "choice",
155
+ "Value": "",
156
+ "Constraints": {
157
+ "Required": true,
158
+ "Regex": null,
159
+ "VerifyValue": false
160
+ },
161
+ "HasDependencies": true,
162
+ "Title": "Select one",
163
+ "Description": null,
164
+ "Hints": ["dropdown"],
165
+ "Visible": true,
166
+ "VisibilityCriteria": {
167
+ "Value": true,
168
+ "Negated": true,
169
+ "Description": null,
170
+ "Criteria": [],
171
+ "Operator": "And"
172
+ },
173
+ "HasDependants": false
174
+ },
175
+ {
176
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
177
+ "Name": "e-mail",
178
+ "HasCustomName": false,
179
+ "Type": "text/sentence",
180
+ "Value": "",
181
+ "Constraints": {
182
+ "Required": true,
183
+ "Regex": "^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$",
184
+ "VerifyValue": false
185
+ },
186
+ "HasDependencies": false,
187
+ "Title": "E-mail",
188
+ "Description": null,
189
+ "Hints": ["email"],
190
+ "Visible": true,
191
+ "VisibilityCriteria": {
192
+ "Value": true,
193
+ "Negated": true,
194
+ "Description": null,
195
+ "Criteria": [],
196
+ "Operator": "And"
197
+ },
198
+ "HasDependants": false
199
+ },
200
+ {
201
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormGroupComponent, Humany.KnowledgeBase",
202
+ "Children": [
203
+ {
204
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
205
+ "Name": "street",
206
+ "HasCustomName": false,
207
+ "Type": "text/sentence",
208
+ "Value": "",
209
+ "Constraints": {
210
+ "Required": false,
211
+ "Regex": null,
212
+ "VerifyValue": false
213
+ },
214
+ "HasDependencies": false,
215
+ "Title": "Street",
216
+ "Description": null,
217
+ "Hints": ["street"],
218
+ "Visible": true,
219
+ "VisibilityCriteria": {
220
+ "Value": true,
221
+ "Negated": true,
222
+ "Description": null,
223
+ "Criteria": [],
224
+ "Operator": "And"
225
+ },
226
+ "HasDependants": false
227
+ },
228
+ {
229
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
230
+ "Name": "number",
231
+ "HasCustomName": false,
232
+ "Type": "text/word",
233
+ "Value": "",
234
+ "Constraints": {
235
+ "Required": false,
236
+ "Regex": null,
237
+ "VerifyValue": false
238
+ },
239
+ "HasDependencies": false,
240
+ "Title": "Number",
241
+ "Description": null,
242
+ "Hints": ["number"],
243
+ "Visible": true,
244
+ "VisibilityCriteria": {
245
+ "Value": true,
246
+ "Negated": true,
247
+ "Description": null,
248
+ "Criteria": [],
249
+ "Operator": "And"
250
+ },
251
+ "HasDependants": false
252
+ },
253
+ {
254
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
255
+ "Name": "postcode",
256
+ "HasCustomName": false,
257
+ "Type": "text/word",
258
+ "Value": "",
259
+ "Constraints": {
260
+ "Required": false,
261
+ "Regex": null,
262
+ "VerifyValue": false
263
+ },
264
+ "HasDependencies": false,
265
+ "Title": "Postcode",
266
+ "Description": null,
267
+ "Hints": ["zipcode"],
268
+ "Visible": true,
269
+ "VisibilityCriteria": {
270
+ "Value": true,
271
+ "Negated": true,
272
+ "Description": null,
273
+ "Criteria": [],
274
+ "Operator": "And"
275
+ },
276
+ "HasDependants": false
277
+ },
278
+ {
279
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
280
+ "Name": "city",
281
+ "HasCustomName": false,
282
+ "Type": "text/sentence",
283
+ "Value": "",
284
+ "Constraints": {
285
+ "Required": false,
286
+ "Regex": null,
287
+ "VerifyValue": false
288
+ },
289
+ "HasDependencies": false,
290
+ "Title": "City",
291
+ "Description": null,
292
+ "Hints": ["city"],
293
+ "Visible": true,
294
+ "VisibilityCriteria": {
295
+ "Value": true,
296
+ "Negated": true,
297
+ "Description": null,
298
+ "Criteria": [],
299
+ "Operator": "And"
300
+ },
301
+ "HasDependants": false
302
+ }
303
+ ],
304
+ "Title": "Address",
305
+ "Description": null,
306
+ "Hints": ["address"],
307
+ "Visible": true,
308
+ "VisibilityCriteria": {
309
+ "Value": true,
310
+ "Negated": true,
311
+ "Description": null,
312
+ "Criteria": [],
313
+ "Operator": "And"
314
+ },
315
+ "HasDependants": false
316
+ }
317
+ ],
318
+ "Title": "",
319
+ "Description": null,
320
+ "Hints": null,
321
+ "Visible": true,
322
+ "VisibilityCriteria": {
323
+ "Value": true,
324
+ "Negated": true,
325
+ "Description": null,
326
+ "Criteria": [],
327
+ "Operator": "And"
328
+ },
329
+ "HasDependants": false
330
+ }
331
+ ],
332
+ "HasValueComponents": true,
333
+ "Extra": {}
334
+ },
335
+ "Exits": [
336
+ {
337
+ "Name": "email1",
338
+ "Type": "email",
339
+ "Adapter": {
340
+ "Id": "6973ff0a-b1a9-4f01-cd87-e7547f1384c0",
341
+ "ClientName": "email.form",
342
+ "CustomClientName": null,
343
+ "Uri": "/interfaces/widgets/adapters/email.form.js",
344
+ "Settings": {}
345
+ }
346
+ }
347
+ ],
348
+ "ConfirmationText": "<h1>Thank you!</h1><p>Your message has been sent.</p>",
349
+ "Id": 942,
350
+ "Title": "Report a problem",
351
+ "Description": "<p>Use this contact form to send us the relevant information.</p>\n",
352
+ "UriName": "report-a-problem",
353
+ "Attributes": [],
354
+ "Translations": {
355
+ "en": 942
356
+ },
357
+ "MatchQuestion": false,
358
+ "ExitType": "email",
359
+ "ExitConfiguration": "email.form",
360
+ "Highlighted": false,
361
+ "HighlightedInStart": false,
362
+ "ExecuteImmediately": false,
363
+ "ExpandFormAutomatically": false,
364
+ "DefaultIcon": {
365
+ "Type": "FontAwesome",
366
+ "Content": "envelope"
367
+ },
368
+ "ActiveIcon": {
369
+ "Type": null,
370
+ "Content": null
371
+ },
372
+ "LastModified": "2022-04-07T11:14:20.5582864Z",
373
+ "Parents": [808]
374
+ }
375
+ }
@@ -0,0 +1 @@
1
+ export declare const toContactMethod: ({ Id, Title, DefaultIcon, Exits: [Exit], ExitType, ConfirmationText, ExpandFormAutomatically, Form, Description, }: any, Validation?: any) => any;
@@ -0,0 +1,68 @@
1
+ // TODO: remove this file
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ import { FormBuilder } from '@humany/widget-forms';
19
+ export var toContactMethod = function (_a, Validation) {
20
+ var Id = _a.Id, Title = _a.Title, DefaultIcon = _a.DefaultIcon, _b = __read(_a.Exits, 1), Exit = _b[0], ExitType = _a.ExitType, ConfirmationText = _a.ConfirmationText, ExpandFormAutomatically = _a.ExpandFormAutomatically, Form = _a.Form, Description = _a.Description;
21
+ var Adapter = (Exit || { Adapter: {} }).Adapter;
22
+ var _c = Adapter.ClientName, ClientName = _c === void 0 ? '' : _c, _d = Adapter.Settings, Settings = _d === void 0 ? {} : _d, _e = Adapter.CustomClientName, CustomClientName = _e === void 0 ? '' : _e;
23
+ var settings = {
24
+ id: Id.toString(),
25
+ title: Title,
26
+ description: Description,
27
+ // symbol: convertLegacySymbol(DefaultIcon), // TODO:
28
+ symbol: null,
29
+ clientName: ClientName === 'custom.adapter' ? CustomClientName : ClientName,
30
+ expanded: true,
31
+ inline: true,
32
+ body: {},
33
+ };
34
+ if (ClientName.indexOf('phone') > -1 || ClientName.indexOf('freetext') > -1) {
35
+ var displayTextBeforeClick = Settings.displayTextBeforeClick, textBeforeClick = Settings.textBeforeClick;
36
+ if (displayTextBeforeClick === 'true') {
37
+ settings.expanded = false;
38
+ settings.title = textBeforeClick;
39
+ }
40
+ if (ClientName.indexOf('phone.text') > -1) {
41
+ settings.body.phoneNumber = Settings.phoneNumber;
42
+ }
43
+ else {
44
+ settings.body.freetext = Settings.freetext;
45
+ }
46
+ }
47
+ if (ClientName.indexOf('chat.popup') > -1 ||
48
+ ClientName.indexOf('link') > -1 ||
49
+ (ClientName === 'custom.adapter' && ExitType === 'custom')) {
50
+ settings.body = Settings;
51
+ settings.body.confirmationFallback = ConfirmationText;
52
+ }
53
+ if (ClientName.indexOf('ace') > -1) {
54
+ settings.body = Settings;
55
+ }
56
+ if (Form && Form.HasValueComponents) {
57
+ if (Validation) {
58
+ settings.body.form = FormBuilder.fromLegacyForm(Id.toString(), Form, Validation).get();
59
+ }
60
+ else {
61
+ settings.body.form = FormBuilder.fromLegacyForm(Id.toString(), Form).get();
62
+ }
63
+ if (!ExpandFormAutomatically) {
64
+ settings.expanded = settings.inline = false;
65
+ }
66
+ }
67
+ return settings;
68
+ };
@@ -5,6 +5,7 @@ export default class EntryInterface {
5
5
  private nextActionKey;
6
6
  constructor();
7
7
  transform(entry: ServerEntry): Message | undefined;
8
+ transformContactMethod(entry: ServerEntry): any;
8
9
  transformArray(entryArray: ServerEntry[]): Message[];
9
10
  getUserMessage(action: string): string | undefined;
10
11
  private listTransform;
@@ -1,6 +1,9 @@
1
1
  import { ConversationMessageListItemType, } from '@humany/widget-conversation';
2
2
  import { ServerEntryTypeEnum } from '../contract/enum/server-entry-type.enum';
3
3
  import { StoreHelper } from '../helper/store.helper';
4
+ import { toContactMethod } from './convert';
5
+ import mocked from './_mocked-contact-method.json';
6
+ // TODO: toContactMethod and mocked.json should be removed
4
7
  var EntryInterface = /** @class */ (function () {
5
8
  function EntryInterface() {
6
9
  this.helpActionKey = 'help';
@@ -31,8 +34,23 @@ var EntryInterface = /** @class */ (function () {
31
34
  entry: entry,
32
35
  isUser: false,
33
36
  };
37
+ case ServerEntryTypeEnum.Contact:
38
+ return {
39
+ id: entry.id,
40
+ message: this.transformContactMethod(entry),
41
+ entry: entry,
42
+ isUser: false,
43
+ };
34
44
  }
35
45
  };
46
+ EntryInterface.prototype.transformContactMethod = function (entry) {
47
+ var contactMethod = toContactMethod(mocked.ContactMethod);
48
+ contactMethod.expanded = true; // TODO: ?
49
+ return {
50
+ type: 'ace-knowledge-contact-method',
51
+ contactMethods: [contactMethod],
52
+ };
53
+ };
36
54
  // transform an array of entries
37
55
  EntryInterface.prototype.transformArray = function (entryArray) {
38
56
  var _this = this;
@@ -50,6 +68,10 @@ var EntryInterface = /** @class */ (function () {
50
68
  return this.getTitleFromEntry(entry, action);
51
69
  };
52
70
  EntryInterface.prototype.listTransform = function (entry) {
71
+ if (entry.type === 'Contact') {
72
+ // TODO: is this needed
73
+ return undefined;
74
+ }
53
75
  if (!entry.content)
54
76
  return undefined;
55
77
  var object = this.getListActions(entry.content.items, this.getContentText(entry), entry.actions, entry.localState);
@@ -94,12 +116,10 @@ var EntryInterface = /** @class */ (function () {
94
116
  case _this.nextActionKey: {
95
117
  if (!!actions['next'] && actions['next'].take === items.length + 1)
96
118
  mainListContent[o.actionKey] = o.title;
97
- // console.log(actions['next'], actions['next'].take, items.length, items.length - 2)
98
119
  break;
99
120
  }
100
121
  default: {
101
122
  mainListContent[o.actionKey] = o.title;
102
- // mainListContent.push(this.getItemObject(o))
103
123
  }
104
124
  }
105
125
  });
package/lib/plugin.js CHANGED
@@ -111,7 +111,11 @@ var KnowledgeBotProviderPlugin = function (container) { return __awaiter(void 0,
111
111
  component.actions.watch('conversation.action', function (input, next) {
112
112
  var chatClient = new ChatClient();
113
113
  var cmClient = new ContactMethodClient();
114
- if (input === 'contact' || input.split('/').length > 1) {
114
+ // if (input === 'contact' || input.split('/').length > 1) {
115
+ // cmClient.handleContactMethod(input);
116
+ // return next(input);
117
+ // }
118
+ if (input.split('/').length > 1) {
115
119
  cmClient.handleContactMethod(input);
116
120
  return next(input);
117
121
  }
@@ -33,6 +33,9 @@ var ContactMethodItem = function (props) {
33
33
  var container = useContainer();
34
34
  var _a = __read(useState(props.contactMethod.body), 2), body = _a[0], setBody = _a[1];
35
35
  useEffect(function () {
36
+ if (!container || !container.get('$widget')) {
37
+ return;
38
+ }
36
39
  var events = container.get('$widget').events;
37
40
  events.subscribe('form:validated', function (_event, _data) {
38
41
  // TODO: this is a due to props not being updated when props.contactMethod.body changes
@@ -1,6 +1,7 @@
1
1
  export declare enum ServerEntryTypeEnum {
2
2
  Widget = 0,
3
3
  Text = 1,
4
- List = 2,
5
- Error = 3
4
+ Contact = 2,
5
+ List = 3,
6
+ Error = 4
6
7
  }
@@ -2,6 +2,7 @@ export var ServerEntryTypeEnum;
2
2
  (function (ServerEntryTypeEnum) {
3
3
  ServerEntryTypeEnum[ServerEntryTypeEnum["Widget"] = 0] = "Widget";
4
4
  ServerEntryTypeEnum[ServerEntryTypeEnum["Text"] = 1] = "Text";
5
- ServerEntryTypeEnum[ServerEntryTypeEnum["List"] = 2] = "List";
6
- ServerEntryTypeEnum[ServerEntryTypeEnum["Error"] = 3] = "Error";
5
+ ServerEntryTypeEnum[ServerEntryTypeEnum["Contact"] = 2] = "Contact";
6
+ ServerEntryTypeEnum[ServerEntryTypeEnum["List"] = 3] = "List";
7
+ ServerEntryTypeEnum[ServerEntryTypeEnum["Error"] = 4] = "Error";
7
8
  })(ServerEntryTypeEnum || (ServerEntryTypeEnum = {}));
@@ -0,0 +1,375 @@
1
+ {
2
+ "ContactMethod": {
3
+ "Form": {
4
+ "Groups": [
5
+ {
6
+ "Components": [
7
+ {
8
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
9
+ "Name": "customer-id",
10
+ "HasCustomName": false,
11
+ "Type": "text/number",
12
+ "Value": "",
13
+ "Constraints": {
14
+ "Required": true,
15
+ "Regex": null,
16
+ "VerifyValue": false
17
+ },
18
+ "HasDependencies": false,
19
+ "Title": "Customer ID",
20
+ "Description": null,
21
+ "Hints": [],
22
+ "Visible": true,
23
+ "VisibilityCriteria": {
24
+ "Value": true,
25
+ "Negated": true,
26
+ "Description": null,
27
+ "Criteria": [],
28
+ "Operator": "And"
29
+ },
30
+ "HasDependants": false
31
+ },
32
+ {
33
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormGroupComponent, Humany.KnowledgeBase",
34
+ "Children": [
35
+ {
36
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
37
+ "Name": "first-name",
38
+ "HasCustomName": false,
39
+ "Type": "text/sentence",
40
+ "Value": "",
41
+ "Constraints": {
42
+ "Required": false,
43
+ "Regex": null,
44
+ "VerifyValue": false
45
+ },
46
+ "HasDependencies": false,
47
+ "Title": "First name",
48
+ "Description": null,
49
+ "Hints": ["firstname", "verifyLabel=Confirm First name"],
50
+ "Visible": true,
51
+ "VisibilityCriteria": {
52
+ "Value": true,
53
+ "Negated": true,
54
+ "Description": null,
55
+ "Criteria": [],
56
+ "Operator": "And"
57
+ },
58
+ "HasDependants": false
59
+ },
60
+ {
61
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
62
+ "Name": "last-name",
63
+ "HasCustomName": false,
64
+ "Type": "text/sentence",
65
+ "Value": "",
66
+ "Constraints": {
67
+ "Required": false,
68
+ "Regex": null,
69
+ "VerifyValue": false
70
+ },
71
+ "HasDependencies": false,
72
+ "Title": "Last name",
73
+ "Description": null,
74
+ "Hints": ["lastname"],
75
+ "Visible": true,
76
+ "VisibilityCriteria": {
77
+ "Value": true,
78
+ "Negated": true,
79
+ "Description": null,
80
+ "Criteria": [],
81
+ "Operator": "And"
82
+ },
83
+ "HasDependants": false
84
+ }
85
+ ],
86
+ "Title": "Name",
87
+ "Description": null,
88
+ "Hints": ["fullname"],
89
+ "Visible": true,
90
+ "VisibilityCriteria": {
91
+ "Value": true,
92
+ "Negated": true,
93
+ "Description": null,
94
+ "Criteria": [],
95
+ "Operator": "And"
96
+ },
97
+ "HasDependants": false
98
+ },
99
+ {
100
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormChoiceComponent, Humany.KnowledgeBase",
101
+ "UseCustomValues": false,
102
+ "Options": [
103
+ {
104
+ "Title": "CheckBox 1",
105
+ "Value": "CheckBox 1",
106
+ "Selected": false
107
+ },
108
+ {
109
+ "Title": "CheckBox 2",
110
+ "Value": "CheckBox 2",
111
+ "Selected": false
112
+ }
113
+ ],
114
+ "Name": "checkboxes",
115
+ "HasCustomName": false,
116
+ "Type": "choice",
117
+ "Value": "",
118
+ "Constraints": {
119
+ "Required": true,
120
+ "Regex": null,
121
+ "VerifyValue": false
122
+ },
123
+ "HasDependencies": true,
124
+ "Title": "Checkboxes",
125
+ "Description": null,
126
+ "Hints": ["checkbox", "multiple"],
127
+ "Visible": true,
128
+ "VisibilityCriteria": {
129
+ "Value": true,
130
+ "Negated": true,
131
+ "Description": null,
132
+ "Criteria": [],
133
+ "Operator": "And"
134
+ },
135
+ "HasDependants": false
136
+ },
137
+ {
138
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormChoiceComponent, Humany.KnowledgeBase",
139
+ "UseCustomValues": false,
140
+ "Options": [
141
+ {
142
+ "Title": "Test 1",
143
+ "Value": "Test 1",
144
+ "Selected": false
145
+ },
146
+ {
147
+ "Title": "Test 2",
148
+ "Value": "Test 2",
149
+ "Selected": false
150
+ }
151
+ ],
152
+ "Name": "select-one",
153
+ "HasCustomName": false,
154
+ "Type": "choice",
155
+ "Value": "",
156
+ "Constraints": {
157
+ "Required": true,
158
+ "Regex": null,
159
+ "VerifyValue": false
160
+ },
161
+ "HasDependencies": true,
162
+ "Title": "Select one",
163
+ "Description": null,
164
+ "Hints": ["dropdown"],
165
+ "Visible": true,
166
+ "VisibilityCriteria": {
167
+ "Value": true,
168
+ "Negated": true,
169
+ "Description": null,
170
+ "Criteria": [],
171
+ "Operator": "And"
172
+ },
173
+ "HasDependants": false
174
+ },
175
+ {
176
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
177
+ "Name": "e-mail",
178
+ "HasCustomName": false,
179
+ "Type": "text/sentence",
180
+ "Value": "",
181
+ "Constraints": {
182
+ "Required": true,
183
+ "Regex": "^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$",
184
+ "VerifyValue": false
185
+ },
186
+ "HasDependencies": false,
187
+ "Title": "E-mail",
188
+ "Description": null,
189
+ "Hints": ["email"],
190
+ "Visible": true,
191
+ "VisibilityCriteria": {
192
+ "Value": true,
193
+ "Negated": true,
194
+ "Description": null,
195
+ "Criteria": [],
196
+ "Operator": "And"
197
+ },
198
+ "HasDependants": false
199
+ },
200
+ {
201
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormGroupComponent, Humany.KnowledgeBase",
202
+ "Children": [
203
+ {
204
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
205
+ "Name": "street",
206
+ "HasCustomName": false,
207
+ "Type": "text/sentence",
208
+ "Value": "",
209
+ "Constraints": {
210
+ "Required": false,
211
+ "Regex": null,
212
+ "VerifyValue": false
213
+ },
214
+ "HasDependencies": false,
215
+ "Title": "Street",
216
+ "Description": null,
217
+ "Hints": ["street"],
218
+ "Visible": true,
219
+ "VisibilityCriteria": {
220
+ "Value": true,
221
+ "Negated": true,
222
+ "Description": null,
223
+ "Criteria": [],
224
+ "Operator": "And"
225
+ },
226
+ "HasDependants": false
227
+ },
228
+ {
229
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
230
+ "Name": "number",
231
+ "HasCustomName": false,
232
+ "Type": "text/word",
233
+ "Value": "",
234
+ "Constraints": {
235
+ "Required": false,
236
+ "Regex": null,
237
+ "VerifyValue": false
238
+ },
239
+ "HasDependencies": false,
240
+ "Title": "Number",
241
+ "Description": null,
242
+ "Hints": ["number"],
243
+ "Visible": true,
244
+ "VisibilityCriteria": {
245
+ "Value": true,
246
+ "Negated": true,
247
+ "Description": null,
248
+ "Criteria": [],
249
+ "Operator": "And"
250
+ },
251
+ "HasDependants": false
252
+ },
253
+ {
254
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
255
+ "Name": "postcode",
256
+ "HasCustomName": false,
257
+ "Type": "text/word",
258
+ "Value": "",
259
+ "Constraints": {
260
+ "Required": false,
261
+ "Regex": null,
262
+ "VerifyValue": false
263
+ },
264
+ "HasDependencies": false,
265
+ "Title": "Postcode",
266
+ "Description": null,
267
+ "Hints": ["zipcode"],
268
+ "Visible": true,
269
+ "VisibilityCriteria": {
270
+ "Value": true,
271
+ "Negated": true,
272
+ "Description": null,
273
+ "Criteria": [],
274
+ "Operator": "And"
275
+ },
276
+ "HasDependants": false
277
+ },
278
+ {
279
+ "$type": "Humany.KnowledgeBase.ContactMethods.FormTextComponent, Humany.KnowledgeBase",
280
+ "Name": "city",
281
+ "HasCustomName": false,
282
+ "Type": "text/sentence",
283
+ "Value": "",
284
+ "Constraints": {
285
+ "Required": false,
286
+ "Regex": null,
287
+ "VerifyValue": false
288
+ },
289
+ "HasDependencies": false,
290
+ "Title": "City",
291
+ "Description": null,
292
+ "Hints": ["city"],
293
+ "Visible": true,
294
+ "VisibilityCriteria": {
295
+ "Value": true,
296
+ "Negated": true,
297
+ "Description": null,
298
+ "Criteria": [],
299
+ "Operator": "And"
300
+ },
301
+ "HasDependants": false
302
+ }
303
+ ],
304
+ "Title": "Address",
305
+ "Description": null,
306
+ "Hints": ["address"],
307
+ "Visible": true,
308
+ "VisibilityCriteria": {
309
+ "Value": true,
310
+ "Negated": true,
311
+ "Description": null,
312
+ "Criteria": [],
313
+ "Operator": "And"
314
+ },
315
+ "HasDependants": false
316
+ }
317
+ ],
318
+ "Title": "",
319
+ "Description": null,
320
+ "Hints": null,
321
+ "Visible": true,
322
+ "VisibilityCriteria": {
323
+ "Value": true,
324
+ "Negated": true,
325
+ "Description": null,
326
+ "Criteria": [],
327
+ "Operator": "And"
328
+ },
329
+ "HasDependants": false
330
+ }
331
+ ],
332
+ "HasValueComponents": true,
333
+ "Extra": {}
334
+ },
335
+ "Exits": [
336
+ {
337
+ "Name": "email1",
338
+ "Type": "email",
339
+ "Adapter": {
340
+ "Id": "6973ff0a-b1a9-4f01-cd87-e7547f1384c0",
341
+ "ClientName": "email.form",
342
+ "CustomClientName": null,
343
+ "Uri": "/interfaces/widgets/adapters/email.form.js",
344
+ "Settings": {}
345
+ }
346
+ }
347
+ ],
348
+ "ConfirmationText": "<h1>Thank you!</h1><p>Your message has been sent.</p>",
349
+ "Id": 942,
350
+ "Title": "Report a problem",
351
+ "Description": "<p>Use this contact form to send us the relevant information.</p>\n",
352
+ "UriName": "report-a-problem",
353
+ "Attributes": [],
354
+ "Translations": {
355
+ "en": 942
356
+ },
357
+ "MatchQuestion": false,
358
+ "ExitType": "email",
359
+ "ExitConfiguration": "email.form",
360
+ "Highlighted": false,
361
+ "HighlightedInStart": false,
362
+ "ExecuteImmediately": false,
363
+ "ExpandFormAutomatically": false,
364
+ "DefaultIcon": {
365
+ "Type": "FontAwesome",
366
+ "Content": "envelope"
367
+ },
368
+ "ActiveIcon": {
369
+ "Type": null,
370
+ "Content": null
371
+ },
372
+ "LastModified": "2022-04-07T11:14:20.5582864Z",
373
+ "Parents": [808]
374
+ }
375
+ }
@@ -0,0 +1 @@
1
+ export declare const toContactMethod: ({ Id, Title, DefaultIcon, Exits: [Exit], ExitType, ConfirmationText, ExpandFormAutomatically, Form, Description, }: any, Validation?: any) => any;
@@ -0,0 +1,68 @@
1
+ // TODO: remove this file
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ import { FormBuilder } from '@humany/widget-forms';
19
+ export var toContactMethod = function (_a, Validation) {
20
+ var Id = _a.Id, Title = _a.Title, DefaultIcon = _a.DefaultIcon, _b = __read(_a.Exits, 1), Exit = _b[0], ExitType = _a.ExitType, ConfirmationText = _a.ConfirmationText, ExpandFormAutomatically = _a.ExpandFormAutomatically, Form = _a.Form, Description = _a.Description;
21
+ var Adapter = (Exit || { Adapter: {} }).Adapter;
22
+ var _c = Adapter.ClientName, ClientName = _c === void 0 ? '' : _c, _d = Adapter.Settings, Settings = _d === void 0 ? {} : _d, _e = Adapter.CustomClientName, CustomClientName = _e === void 0 ? '' : _e;
23
+ var settings = {
24
+ id: Id.toString(),
25
+ title: Title,
26
+ description: Description,
27
+ // symbol: convertLegacySymbol(DefaultIcon), // TODO:
28
+ symbol: null,
29
+ clientName: ClientName === 'custom.adapter' ? CustomClientName : ClientName,
30
+ expanded: true,
31
+ inline: true,
32
+ body: {},
33
+ };
34
+ if (ClientName.indexOf('phone') > -1 || ClientName.indexOf('freetext') > -1) {
35
+ var displayTextBeforeClick = Settings.displayTextBeforeClick, textBeforeClick = Settings.textBeforeClick;
36
+ if (displayTextBeforeClick === 'true') {
37
+ settings.expanded = false;
38
+ settings.title = textBeforeClick;
39
+ }
40
+ if (ClientName.indexOf('phone.text') > -1) {
41
+ settings.body.phoneNumber = Settings.phoneNumber;
42
+ }
43
+ else {
44
+ settings.body.freetext = Settings.freetext;
45
+ }
46
+ }
47
+ if (ClientName.indexOf('chat.popup') > -1 ||
48
+ ClientName.indexOf('link') > -1 ||
49
+ (ClientName === 'custom.adapter' && ExitType === 'custom')) {
50
+ settings.body = Settings;
51
+ settings.body.confirmationFallback = ConfirmationText;
52
+ }
53
+ if (ClientName.indexOf('ace') > -1) {
54
+ settings.body = Settings;
55
+ }
56
+ if (Form && Form.HasValueComponents) {
57
+ if (Validation) {
58
+ settings.body.form = FormBuilder.fromLegacyForm(Id.toString(), Form, Validation).get();
59
+ }
60
+ else {
61
+ settings.body.form = FormBuilder.fromLegacyForm(Id.toString(), Form).get();
62
+ }
63
+ if (!ExpandFormAutomatically) {
64
+ settings.expanded = settings.inline = false;
65
+ }
66
+ }
67
+ return settings;
68
+ };
@@ -5,6 +5,7 @@ export default class EntryInterface {
5
5
  private nextActionKey;
6
6
  constructor();
7
7
  transform(entry: ServerEntry): Message | undefined;
8
+ transformContactMethod(entry: ServerEntry): any;
8
9
  transformArray(entryArray: ServerEntry[]): Message[];
9
10
  getUserMessage(action: string): string | undefined;
10
11
  private listTransform;
@@ -1,6 +1,9 @@
1
1
  import { ConversationMessageListItemType, } from '@humany/widget-conversation';
2
2
  import { ServerEntryTypeEnum } from '../contract/enum/server-entry-type.enum';
3
3
  import { StoreHelper } from '../helper/store.helper';
4
+ import { toContactMethod } from './convert';
5
+ import mocked from './_mocked-contact-method.json';
6
+ // TODO: toContactMethod and mocked.json should be removed
4
7
  var EntryInterface = /** @class */ (function () {
5
8
  function EntryInterface() {
6
9
  this.helpActionKey = 'help';
@@ -31,8 +34,23 @@ var EntryInterface = /** @class */ (function () {
31
34
  entry: entry,
32
35
  isUser: false,
33
36
  };
37
+ case ServerEntryTypeEnum.Contact:
38
+ return {
39
+ id: entry.id,
40
+ message: this.transformContactMethod(entry),
41
+ entry: entry,
42
+ isUser: false,
43
+ };
34
44
  }
35
45
  };
46
+ EntryInterface.prototype.transformContactMethod = function (entry) {
47
+ var contactMethod = toContactMethod(mocked.ContactMethod);
48
+ contactMethod.expanded = true; // TODO: ?
49
+ return {
50
+ type: 'ace-knowledge-contact-method',
51
+ contactMethods: [contactMethod],
52
+ };
53
+ };
36
54
  // transform an array of entries
37
55
  EntryInterface.prototype.transformArray = function (entryArray) {
38
56
  var _this = this;
@@ -50,6 +68,10 @@ var EntryInterface = /** @class */ (function () {
50
68
  return this.getTitleFromEntry(entry, action);
51
69
  };
52
70
  EntryInterface.prototype.listTransform = function (entry) {
71
+ if (entry.type === 'Contact') {
72
+ // TODO: is this needed
73
+ return undefined;
74
+ }
53
75
  if (!entry.content)
54
76
  return undefined;
55
77
  var object = this.getListActions(entry.content.items, this.getContentText(entry), entry.actions, entry.localState);
@@ -94,12 +116,10 @@ var EntryInterface = /** @class */ (function () {
94
116
  case _this.nextActionKey: {
95
117
  if (!!actions['next'] && actions['next'].take === items.length + 1)
96
118
  mainListContent[o.actionKey] = o.title;
97
- // console.log(actions['next'], actions['next'].take, items.length, items.length - 2)
98
119
  break;
99
120
  }
100
121
  default: {
101
122
  mainListContent[o.actionKey] = o.title;
102
- // mainListContent.push(this.getItemObject(o))
103
123
  }
104
124
  }
105
125
  });
package/lib-esm/plugin.js CHANGED
@@ -111,7 +111,11 @@ var KnowledgeBotProviderPlugin = function (container) { return __awaiter(void 0,
111
111
  component.actions.watch('conversation.action', function (input, next) {
112
112
  var chatClient = new ChatClient();
113
113
  var cmClient = new ContactMethodClient();
114
- if (input === 'contact' || input.split('/').length > 1) {
114
+ // if (input === 'contact' || input.split('/').length > 1) {
115
+ // cmClient.handleContactMethod(input);
116
+ // return next(input);
117
+ // }
118
+ if (input.split('/').length > 1) {
115
119
  cmClient.handleContactMethod(input);
116
120
  return next(input);
117
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-bot-provider",
3
- "version": "0.0.1-alpha.24",
3
+ "version": "0.0.1-alpha.27",
4
4
  "description": "Bot Provider Plugin ACE Knowledge Widgets.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",
@@ -26,25 +26,27 @@
26
26
  "typings": "lib/index.d.ts",
27
27
  "peerDependencies": {
28
28
  "@humany/utils": "^2.1.4",
29
+ "@humany/widget-adapters": "^2.0.24-alpha.3",
29
30
  "@humany/widget-components": "^1.4.12-alpha.0",
30
- "@humany/widget-conversation": "^2.1.28-alpha.3",
31
+ "@humany/widget-conversation": "^2.1.28-alpha.5",
31
32
  "@humany/widget-core": "^2.0.11",
32
- "@humany/widget-forms": "^2.1.8",
33
+ "@humany/widget-forms": "^2.1.9-alpha.0",
33
34
  "@humany/widget-services": "^2.0.8",
34
- "@humany/widget-types-grid": "^1.2.11-alpha.0",
35
- "@humany/widget-ui": "^2.2.6",
35
+ "@humany/widget-types-grid": "^1.2.11-alpha.1",
36
+ "@humany/widget-ui": "^2.2.7-alpha.3",
36
37
  "@webprovisions/bootstrapping": "^1.0.12",
37
38
  "uuid": "^8.3.2"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@humany/utils": "^2.1.4",
42
+ "@humany/widget-adapters": "^2.0.24-alpha.3",
41
43
  "@humany/widget-components": "^1.4.12-alpha.0",
42
- "@humany/widget-conversation": "^2.1.28-alpha.3",
44
+ "@humany/widget-conversation": "^2.1.28-alpha.5",
43
45
  "@humany/widget-core": "^2.0.11",
44
- "@humany/widget-forms": "^2.1.8",
46
+ "@humany/widget-forms": "^2.1.9-alpha.0",
45
47
  "@humany/widget-services": "^2.0.8",
46
- "@humany/widget-types-grid": "^1.2.11-alpha.0",
47
- "@humany/widget-ui": "^2.2.6",
48
+ "@humany/widget-types-grid": "^1.2.11-alpha.1",
49
+ "@humany/widget-ui": "^2.2.7-alpha.3",
48
50
  "@types/uuid": "^8.3.4",
49
51
  "@webprovisions/bootstrapping": "^1.0.12",
50
52
  "uuid": "^8.3.2"