@tiledesk/tiledesk-server 2.10.87 → 2.10.89

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.
@@ -0,0 +1,717 @@
1
+ const uuidv4 = require('uuid/v4');
2
+
3
+ module.exports = function generateTemplate(options) {
4
+
5
+ let namespace_id = options.namespace_id;
6
+
7
+ const get_message_intent = uuidv4();
8
+ const get_request_intent = uuidv4();
9
+ const no_msg_or_req_intent = uuidv4();
10
+ const check_message_intent = uuidv4();
11
+ const check_no_issue_intent = uuidv4();
12
+ const check_question_intent = uuidv4();
13
+ const extract_issue_ai_intent = uuidv4();
14
+ const check_request_id_intent = uuidv4();
15
+ const extract_question_intent = uuidv4();
16
+ const create_transcript_intent = uuidv4();
17
+ const ask_kb_from_request_intent = uuidv4();
18
+ const ask_kb_from_message_intent = uuidv4();
19
+ const return_no_content_1_intent = uuidv4();
20
+ const return_no_content_2_intent = uuidv4();
21
+ const return_no_content_3_intent = uuidv4();
22
+ const return_no_content_4_intent = uuidv4();
23
+ const return_response_message_intent = uuidv4();
24
+ const return_response_request_intent = uuidv4();
25
+
26
+ return [
27
+ {
28
+ "webhook_enabled": false,
29
+ "enabled": true,
30
+ "actions": [{
31
+ "_tdActionType": "intent",
32
+ "intentName": "#" + get_message_intent
33
+ }],
34
+ "intent_display_name": "webhook",
35
+ "question": "",
36
+ "attributes": {
37
+ "position": {
38
+ "x": 172,
39
+ "y": 384
40
+ },
41
+ "readonly": true,
42
+ },
43
+ "agents_available": false
44
+ },
45
+ {
46
+ "webhook_enabled": false,
47
+ "enabled": true,
48
+ "actions": [{
49
+ "_tdActionTitle": "",
50
+ "_tdActionType": "jsoncondition",
51
+ "groups": [
52
+ {
53
+ "type": "expression",
54
+ "conditions": [
55
+ {
56
+ "type": "condition",
57
+ "operand1": "message",
58
+ "operator": "isEmpty",
59
+ "operand2": {
60
+ "type": "const",
61
+ "value": "",
62
+ "name": ""
63
+ }
64
+ },
65
+ {
66
+ "type": "operator",
67
+ "operator": "OR"
68
+ },
69
+ {
70
+ "type": "condition",
71
+ "operand1": "message",
72
+ "operator": "isNull",
73
+ "operand2": {
74
+ "type": "const",
75
+ "value": "",
76
+ "name": ""
77
+ }
78
+ },
79
+ {
80
+ "type": "operator",
81
+ "operator": "OR"
82
+ },
83
+ {
84
+ "type": "condition",
85
+ "operand1": "message",
86
+ "operator": "isUndefined",
87
+ "operand2": {
88
+ "type": "const",
89
+ "value": "",
90
+ "name": ""
91
+ }
92
+ }
93
+ ]
94
+ }
95
+ ],
96
+ "stopOnConditionMet": true,
97
+ "noelse": true,
98
+ "trueIntent": "#" + check_request_id_intent
99
+ }],
100
+ "intent_display_name": "check_message",
101
+ "intent_id": check_message_intent,
102
+ "attributes": {
103
+ "position": {
104
+ "x": 960,
105
+ "y": 245
106
+ },
107
+ "nextBlockAction": {
108
+ "_tdActionId": "e459225f-0a01-4786-b987-7fa3d4421877",
109
+ "_tdActionType": "intent",
110
+ "intentName": "#" + extract_issue_ai_intent
111
+ },
112
+ },
113
+ "agents_available": false
114
+ },
115
+ {
116
+ "webhook_enabled": false,
117
+ "enabled": true,
118
+ "actions": [{
119
+ "_tdActionTitle": "",
120
+ "_tdActionType": "askgptv2",
121
+ "question": "{{gpt_reply}}",
122
+ "assignReplyTo": "kb_reply",
123
+ "assignSourceTo": "kb_source",
124
+ "max_tokens": 1024,
125
+ "temperature": 0.7,
126
+ "top_k": 10,
127
+ "model": "gpt-4o",
128
+ "preview": [],
129
+ "history": false,
130
+ "citations": true,
131
+ "namespace": namespace_id,
132
+ "context": "",
133
+ "trueIntent": "#" + return_response_message_intent,
134
+ "falseIntent": "#" + return_no_content_4_intent
135
+ }],
136
+ "intent_display_name": "ask_kb_from_message",
137
+ "intent_id": ask_kb_from_message_intent,
138
+ "language": "en",
139
+ "attributes": {
140
+ "position": {
141
+ "x": 2477,
142
+ "y": 801
143
+ },
144
+ "readonly": false
145
+ },
146
+ "agents_available": false
147
+ },
148
+ {
149
+ "webhook_enabled": false,
150
+ "enabled": true,
151
+ "actions": [{
152
+ "_tdActionTitle": "",
153
+ "_tdActionType": "gpt_task",
154
+ "max_tokens": 256,
155
+ "temperature": 0.7,
156
+ "model": "gpt-4o",
157
+ "assignReplyTo": "gpt_reply",
158
+ "preview": [],
159
+ "formatType": "none",
160
+ "question": "This is a user message taken from support conversation.\n\n{{message}}\n\nCheck that the message contains a question or poses a problem. If there is, make it clear and concise as if the user were writing, otherwise reply with \"NULL\".",
161
+ "context": "",
162
+ "trueIntent": "#" + check_no_issue_intent
163
+ }],
164
+ "intent_display_name": "extract_issue_ai",
165
+ "intent_id": extract_issue_ai_intent,
166
+ "language": "en",
167
+ "attributes": {
168
+ "position": {
169
+ "x": 1510,
170
+ "y": 473
171
+ },
172
+ "readonly": false
173
+ },
174
+ "agents_available": false
175
+ },
176
+ {
177
+ "webhook_enabled": false,
178
+ "enabled": true,
179
+ "actions": [{
180
+ "_tdActionTitle": "",
181
+ "_tdActionType": "jsoncondition",
182
+ "groups": [
183
+ {
184
+ "type": "expression",
185
+ "conditions": [
186
+ {
187
+ "type": "condition",
188
+ "operand1": "gpt_reply",
189
+ "operator": "equalAsStrings",
190
+ "operand2": {
191
+ "type": "const",
192
+ "value": "NULL",
193
+ "name": ""
194
+ }
195
+ }
196
+ ]
197
+ }
198
+ ],
199
+ "stopOnConditionMet": true,
200
+ "noelse": true,
201
+ "trueIntent": "#" + return_no_content_3_intent
202
+ }],
203
+ "intent_display_name": "check_no_issue",
204
+ "intent_id": check_no_issue_intent,
205
+ "language": "en",
206
+ "attributes": {
207
+ "position": {
208
+ "x": 1978,
209
+ "y": 557
210
+ },
211
+ "nextBlockAction": {
212
+ "_tdActionId": "37185650-df70-4b90-9784-bcff646e37ce",
213
+ "_tdActionType": "intent",
214
+ "intentName": "#" + ask_kb_from_message_intent
215
+ },
216
+ "readonly": false
217
+ },
218
+ "agents_available": false
219
+ },
220
+ {
221
+ "webhook_enabled": false,
222
+ "enabled": true,
223
+ "actions": [{
224
+ "_tdActionTitle": "",
225
+ "payload": "{}",
226
+ "headersString": {
227
+ "Content-Type": "*/*",
228
+ "Cache-Control": "no-cache",
229
+ "User-Agent": "TiledeskBotRuntime",
230
+ "Accept": "*/*"
231
+ },
232
+ "bodyType": "json",
233
+ "assignTo": "",
234
+ "_tdActionType": "web_response",
235
+ "status": "400"
236
+ }],
237
+ "intent_display_name": "return_no_content_3",
238
+ "intent_id": return_no_content_3_intent,
239
+ "language": "en",
240
+ "attributes": {
241
+ "position": {
242
+ "x": 2465,
243
+ "y": 461
244
+ },
245
+ "readonly": false
246
+ },
247
+ "agents_available": false
248
+ },
249
+ {
250
+ "webhook_enabled": false,
251
+ "enabled": true,
252
+ "actions": [{
253
+ "_tdActionTitle": "",
254
+ "_tdActionType": "jsoncondition",
255
+ "groups": [
256
+ {
257
+ "type": "expression",
258
+ "conditions": [
259
+ {
260
+ "type": "condition",
261
+ "operand1": "request_id",
262
+ "operator": "isEmpty",
263
+ "operand2": {
264
+ "type": "const",
265
+ "value": "",
266
+ "name": ""
267
+ }
268
+ },
269
+ {
270
+ "type": "operator",
271
+ "operator": "OR"
272
+ },
273
+ {
274
+ "type": "condition",
275
+ "operand1": "request_id",
276
+ "operator": "isNull",
277
+ "operand2": {
278
+ "type": "const",
279
+ "value": "",
280
+ "name": ""
281
+ }
282
+ },
283
+ {
284
+ "type": "operator",
285
+ "operator": "OR"
286
+ },
287
+ {
288
+ "type": "condition",
289
+ "operand1": "request_id",
290
+ "operator": "isUndefined",
291
+ "operand2": {
292
+ "type": "const",
293
+ "value": "",
294
+ "name": ""
295
+ }
296
+ }
297
+ ]
298
+ }
299
+ ],
300
+ "stopOnConditionMet": true,
301
+ "noelse": true,
302
+ "trueIntent": "#" + no_msg_or_req_intent
303
+ }],
304
+ "intent_display_name": "check_request_id",
305
+ "intent_id": check_request_id_intent,
306
+ "language": "en",
307
+ "attributes": {
308
+ "position": {
309
+ "x": 1505,
310
+ "y": 52
311
+ },
312
+ "nextBlockAction": {
313
+ "_tdActionId": "a32cc3aa-8fd2-4ef4-8129-06ec8de6de32",
314
+ "_tdActionType": "intent",
315
+ "intentName": "#" + get_request_intent
316
+ },
317
+ "color": "80,100,147",
318
+ "readonly": false
319
+ },
320
+ "agents_available": false
321
+ },
322
+ {
323
+ "webhook_enabled": false,
324
+ "enabled": true,
325
+ "actions": [{
326
+ "_tdActionTitle": "",
327
+ "_tdActionType": "setattribute-v2",
328
+ "operation": {
329
+ "operands": [
330
+ {
331
+ "value": "{{result | json}}",
332
+ "isVariable": false
333
+ }
334
+ ],
335
+ "operators": []
336
+ },
337
+ "destination": "messages"
338
+ },
339
+ {
340
+ "_tdActionTitle": "",
341
+ "_tdActionType": "code",
342
+ "source": "let messages = context.attributes[\"messages\"]\nmessages = JSON.parse(messages);\n\nlet transcript = \"\";\nmessages?.forEach(message => {\n // only unuseful messages have subtype\n const subtype = message?.attributes?.subtype;\n\n // only chatbots\n const intentName = message?.attributes?.intentName;\n\n // only end-users\n // const requester_id = message?.attributes?.requester_id;\n\n // only service messages\n const messagelabel = message?.attributes?.messagelabel;\n\n // human only messages\n if (!subtype && !messagelabel && !intentName) {\n //console.log(\"message:\", message);\n let text = message.senderFullname + \": \" + message.text;\n transcript += text + \"\\n\";\n }\n });\n\ncontext.setAttribute(\"transcript\", transcript);"
343
+ }],
344
+ "intent_display_name": "create_transcript",
345
+ "intent_id": create_transcript_intent,
346
+ "language": "en",
347
+ "attributes": {
348
+ "position": {
349
+ "x": 2724,
350
+ "y": -217
351
+ },
352
+ "nextBlockAction": {
353
+ "_tdActionId": "dbe26ec5-5c96-47b4-a885-294289a45f00",
354
+ "_tdActionType": "intent",
355
+ "intentName": "#" + extract_question_intent
356
+ },
357
+ "readonly": false
358
+ },
359
+ "agents_available": false
360
+ },
361
+ {
362
+ "webhook_enabled": false,
363
+ "enabled": true,
364
+ "actions": [{
365
+ "_tdActionTitle": "",
366
+ "_tdActionType": "setattribute-v2",
367
+ "operation": {
368
+ "operands": [
369
+ {
370
+ "value": "{{payload.text}}",
371
+ "isVariable": false
372
+ }
373
+ ],
374
+ "operators": []
375
+ },
376
+ "destination": "message"
377
+ },
378
+ {
379
+ "_tdActionTitle": "",
380
+ "_tdActionType": "setattribute-v2",
381
+ "operation": {
382
+ "operands": [
383
+ {
384
+ "value": "{{payload.request_id}}",
385
+ "isVariable": false
386
+ }
387
+ ],
388
+ "operators": []
389
+ },
390
+ "destination": "request_id"
391
+ }],
392
+ "intent_display_name": "get_message",
393
+ "intent_id": get_message_intent,
394
+ "attributes": {
395
+ "position": {
396
+ "x": 527,
397
+ "y": 247
398
+ },
399
+ "nextBlockAction": {
400
+ "_tdActionId": "282fc8fd-c315-4c66-ae5e-82513595e718",
401
+ "_tdActionType": "intent",
402
+ "intentName": "#" + check_message_intent
403
+ },
404
+ "readonly": false
405
+ },
406
+ "agents_available": false
407
+ },
408
+ {
409
+ "webhook_enabled": false,
410
+ "enabled": true,
411
+ "actions": [{
412
+ "_tdActionType": "web_response",
413
+ "status": "400",
414
+ "bodyType": "json",
415
+ "payload": "{}"
416
+ }],
417
+ "intent_display_name": "no_msg_or_req",
418
+ "intent_id": no_msg_or_req_intent,
419
+ "language": "en",
420
+ "attributes": {
421
+ "position": {
422
+ "x": 2019,
423
+ "y": -183
424
+ },
425
+ },
426
+ "agents_available": false
427
+ },
428
+ {
429
+ "webhook_enabled": false,
430
+ "enabled": true,
431
+ "actions": [{
432
+ "_tdActionTitle": "",
433
+ "payload": "{}",
434
+ "headersString": {
435
+ "Content-Type": "*/*",
436
+ "Cache-Control": "no-cache",
437
+ "User-Agent": "TiledeskBotRuntime",
438
+ "Accept": "*/*"
439
+ },
440
+ "bodyType": "json",
441
+ "assignTo": "",
442
+ "_tdActionType": "web_response",
443
+ "status": "404"
444
+ }],
445
+ "intent_display_name": "return_no_content_1",
446
+ "intent_id": return_no_content_1_intent,
447
+ "language": "en",
448
+ "attributes": {
449
+ "position": {
450
+ "x": 4170,
451
+ "y": -251
452
+ },
453
+ "readonly": false
454
+ },
455
+ "agents_available": false
456
+ },
457
+ {
458
+ "webhook_enabled": false,
459
+ "enabled": true,
460
+ "actions": [{
461
+ "_tdActionTitle": "",
462
+ "url": "https://api.tiledesk.com/v3/public/requests/{{request_id}}/messages",
463
+ "headersString": {
464
+ "Content-Type": "*/*",
465
+ "Cache-Control": "no-cache",
466
+ "User-Agent": "TiledeskBotRuntime",
467
+ "Accept": "*/*"
468
+ },
469
+ "settings": {
470
+ "timeout": 20000
471
+ },
472
+ "jsonBody": null,
473
+ "bodyType": "none",
474
+ "formData": [],
475
+ "assignStatusTo": "status",
476
+ "assignErrorTo": "error",
477
+ "method": "GET",
478
+ "_tdActionType": "webrequestv2",
479
+ "assignResultTo": "result",
480
+ "trueIntent": "#" + create_transcript_intent
481
+ }],
482
+ "intent_display_name": "get_request",
483
+ "intent_id": get_request_intent,
484
+ "language": "en",
485
+ "attributes": {
486
+ "position": {
487
+ "x": 2110,
488
+ "y": 88
489
+ },
490
+ "readonly": false
491
+ },
492
+ "agents_available": false
493
+ },
494
+ {
495
+ "webhook_enabled": false,
496
+ "enabled": true,
497
+ "actions": [{
498
+ "_tdActionTitle": "",
499
+ "payload": "{}",
500
+ "headersString": {
501
+ "Cache-Control": "no-cache",
502
+ "User-Agent": "TiledeskBotRuntime",
503
+ "Accept": "*/*",
504
+ "Content-Type": "application/json"
505
+ },
506
+ "bodyType": "json",
507
+ "assignTo": "",
508
+ "_tdActionType": "web_response",
509
+ "status": "404"
510
+ }],
511
+ "intent_display_name": "return_no_content_4",
512
+ "intent_id": return_no_content_4_intent,
513
+ "language": "en",
514
+ "attributes": {
515
+ "position": {
516
+ "x": 2971,
517
+ "y": 1064
518
+ },
519
+ "readonly": false
520
+ },
521
+ "agents_available": false
522
+ },
523
+ {
524
+ "webhook_enabled": false,
525
+ "enabled": true,
526
+ "actions": [{
527
+ "_tdActionTitle": "",
528
+ "_tdActionType": "gpt_task",
529
+ "max_tokens": 256,
530
+ "temperature": 0.7,
531
+ "model": "gpt-4o",
532
+ "assignReplyTo": "gpt_reply",
533
+ "preview": [],
534
+ "formatType": "none",
535
+ "question": "This is a support conversation.\n\n{{transcript}}\n\nAnalyze the conversation, summarize the question that was asked or the problem that was posed. If there are multiple problems or questions, try to consider the last unsolved problem.\nIf there is no question or unsolved problem, respond with \"NULL\".",
536
+ "context": "",
537
+ "trueIntent": "#" + check_question_intent
538
+ }],
539
+ "intent_display_name": "extract_question",
540
+ "intent_id": extract_question_intent,
541
+ "language": "en",
542
+ "attributes": {
543
+ "position": {
544
+ "x": 3194,
545
+ "y": -223
546
+ },
547
+ "readonly": false
548
+ },
549
+ "agents_available": false
550
+ },
551
+ {
552
+ "webhook_enabled": false,
553
+ "enabled": true,
554
+ "actions": [{
555
+ "_tdActionTitle": "",
556
+ "payload": "{}",
557
+ "headersString": {
558
+ "Content-Type": "*/*",
559
+ "Cache-Control": "no-cache",
560
+ "User-Agent": "TiledeskBotRuntime",
561
+ "Accept": "*/*"
562
+ },
563
+ "bodyType": "json",
564
+ "assignTo": "",
565
+ "_tdActionType": "web_response",
566
+ "status": "404"
567
+ }],
568
+ "intent_display_name": "return_no_content_2",
569
+ "intent_id": return_no_content_2_intent,
570
+ "language": "en",
571
+ "attributes": {
572
+ "position": {
573
+ "x": 4699,
574
+ "y": 272
575
+ },
576
+ "readonly": false
577
+ },
578
+ "agents_available": false
579
+ },
580
+ {
581
+ "webhook_enabled": false,
582
+ "enabled": true,
583
+ "actions": [{
584
+ "_tdActionTitle": "",
585
+ "payload": "{\n\"title\": \"Copilot Official\",\n\"question\": {{gpt_reply | json}},\n\"text\": {{kb_reply | json}}\n}",
586
+ "headersString": {
587
+ "Content-Type": "*/*",
588
+ "Cache-Control": "no-cache",
589
+ "User-Agent": "TiledeskBotRuntime",
590
+ "Accept": "*/*"
591
+ },
592
+ "bodyType": "json",
593
+ "assignTo": "",
594
+ "_tdActionType": "web_response",
595
+ "status": "200"
596
+ }],
597
+ "intent_display_name": "return_response_request",
598
+ "intent_id": return_response_request_intent,
599
+ "attributes": {
600
+ "position": {
601
+ "x": 4690,
602
+ "y": 16
603
+ },
604
+ "readonly": false
605
+ },
606
+ "agents_available": false
607
+ },
608
+ {
609
+ "webhook_enabled": false,
610
+ "enabled": true,
611
+ "actions": [{
612
+ "_tdActionTitle": "",
613
+ "_tdActionType": "askgptv2",
614
+ "question": "{{gpt_reply}}",
615
+ "assignReplyTo": "kb_reply",
616
+ "assignSourceTo": "kb_source",
617
+ "max_tokens": 1024,
618
+ "temperature": 0.7,
619
+ "top_k": 10,
620
+ "model": "gpt-4o",
621
+ "preview": [],
622
+ "history": false,
623
+ "citations": true,
624
+ "namespace": namespace_id,
625
+ "context": "",
626
+ "trueIntent": "#" + return_response_request_intent,
627
+ "falseIntent": "#" + return_no_content_2_intent
628
+ }],
629
+ "intent_display_name": "ask_kb_from_request",
630
+ "intent_id": ask_kb_from_request_intent,
631
+ "language": "en",
632
+ "attributes": {
633
+ "position": {
634
+ "x": 4179,
635
+ "y": 22
636
+ },
637
+ "readonly": false
638
+ },
639
+ "agents_available": false
640
+ },
641
+ {
642
+ "webhook_enabled": false,
643
+ "enabled": true,
644
+ "actions": [{
645
+ "_tdActionTitle": "",
646
+ "_tdActionType": "jsoncondition",
647
+ "groups": [
648
+ {
649
+ "type": "expression",
650
+ "conditions": [
651
+ {
652
+ "type": "condition",
653
+ "operand1": "gpt_reply",
654
+ "operator": "equalAsStrings",
655
+ "operand2": {
656
+ "type": "const",
657
+ "value": "NIENTE",
658
+ "name": ""
659
+ }
660
+ }
661
+ ]
662
+ }
663
+ ],
664
+ "stopOnConditionMet": true,
665
+ "noelse": true,
666
+ "trueIntent": "#" + return_no_content_1_intent
667
+ }],
668
+ "intent_display_name": "check_question",
669
+ "intent_id": check_question_intent,
670
+ "language": "en",
671
+ "attributes": {
672
+ "position": {
673
+ "x": 3653,
674
+ "y": -127
675
+ },
676
+ "nextBlockAction": {
677
+ "_tdActionId": "11879363-4439-4723-82bc-efeb1e7c62ef",
678
+ "_tdActionType": "intent",
679
+ "intentName": "#" + ask_kb_from_request_intent
680
+ },
681
+ "readonly": false
682
+ },
683
+ "agents_available": false
684
+ },
685
+ {
686
+ "webhook_enabled": false,
687
+ "enabled": true,
688
+ "actions": [{
689
+ "_tdActionTitle": "",
690
+ "payload": "{\n\"title\": \"Copilot Official\",\n\"question\": {{gpt_reply | json}},\n\"text\": {{kb_reply | json}}\n}",
691
+ "headersString": {
692
+ "Content-Type": "*/*",
693
+ "Cache-Control": "no-cache",
694
+ "User-Agent": "TiledeskBotRuntime",
695
+ "Accept": "*/*"
696
+ },
697
+ "bodyType": "json",
698
+ "assignTo": "",
699
+ "_tdActionType": "web_response",
700
+ "status": "200"
701
+ }],
702
+ "intent_display_name": "return_response_message",
703
+ "intent_id": return_response_message_intent,
704
+ "language": "en",
705
+ "attributes": {
706
+ "position": {
707
+ "x": 2969,
708
+ "y": 841
709
+ },
710
+ "readonly": false
711
+ },
712
+ "agents_available": false
713
+ }
714
+ ]
715
+ }
716
+
717
+