@tiledesk/tiledesk-tybot-connector 0.2.91-rc2 → 0.2.91
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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
available on:
|
|
6
6
|
▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
|
|
7
7
|
|
|
8
|
+
# v0.2.91
|
|
9
|
+
- Added voice flow attributes: dnis, callId, ani
|
|
10
|
+
|
|
11
|
+
# v0.2.89
|
|
12
|
+
- Added convertToNumber to operations in setAttribute
|
|
13
|
+
- Added setAttributeV2 test
|
|
14
|
+
|
|
8
15
|
# v0.2.88
|
|
9
16
|
- Added DirContactUpdate (aka LeadUpdate). No test case added for LeadUpdate. Only testable with a validation test.
|
|
10
17
|
- Fixed: Attribute parameters userFullname & userEmail now are able to "bypass" the request.lead not correctly updating on the same conversation. If updated in the flow (through LeadUpdate action), they will maintain their own value through the current conversation flow.
|
|
@@ -435,14 +435,15 @@ class TiledeskChatbotUtil {
|
|
|
435
435
|
let fullName = message.senderFullname;
|
|
436
436
|
if (fullName.trim() === chatbot_name) {
|
|
437
437
|
fullName = "bot:" + fullName;
|
|
438
|
-
}
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
439
440
|
fullName = "user:" + fullName;
|
|
440
441
|
}
|
|
441
442
|
return "<" + fullName + ">";
|
|
442
443
|
}
|
|
443
444
|
}
|
|
444
445
|
|
|
445
|
-
static
|
|
446
|
+
static transcriptJSON(transcript) {
|
|
446
447
|
const regexp = /(<.*>)/gm;
|
|
447
448
|
const parts = transcript.split(regexp);
|
|
448
449
|
// console.log("parts:", parts);
|
|
@@ -714,7 +715,7 @@ class TiledeskChatbotUtil {
|
|
|
714
715
|
const value_type = typeof value;
|
|
715
716
|
//if (projectId === "641864da99c1fb00131ba495") {console.log("641864da99c1fb00131ba495 > importing payload parameter:", key, "value:", value, "type:", value_type);}
|
|
716
717
|
//await chatbot.addParameter(key, String(value));
|
|
717
|
-
console.log("Adding from message.attributes:", key, "->", value);
|
|
718
|
+
// console.log("Adding from message.attributes:", key, "->", value);
|
|
718
719
|
await chatbot.addParameter(key, value);
|
|
719
720
|
}
|
|
720
721
|
}
|
|
@@ -722,6 +723,17 @@ class TiledeskChatbotUtil {
|
|
|
722
723
|
console.error("Error importing message payload in request variables:", err);
|
|
723
724
|
}
|
|
724
725
|
}
|
|
726
|
+
|
|
727
|
+
// voice-vxml attributes
|
|
728
|
+
if (message.attributes.dnis) {
|
|
729
|
+
await chatbot.addParameter("dnis", message.attributes.dnis);
|
|
730
|
+
}
|
|
731
|
+
if (message.attributes.callId) {
|
|
732
|
+
await chatbot.addParameter("callId", message.attributes.callId);
|
|
733
|
+
}
|
|
734
|
+
if (message.attributes.ani) {
|
|
735
|
+
await chatbot.addParameter("ani", message.attributes.ani);
|
|
736
|
+
}
|
|
725
737
|
}
|
|
726
738
|
|
|
727
739
|
const _bot = chatbot.bot; // aka FaqKB
|
package/package.json
CHANGED
|
@@ -3,8 +3,6 @@ const { TiledeskChatbot } = require("../../models/TiledeskChatbot");
|
|
|
3
3
|
const { Filler } = require("../Filler");
|
|
4
4
|
let https = require("https");
|
|
5
5
|
const { DirIntent } = require("./DirIntent");
|
|
6
|
-
const { TiledeskChatbotConst } = require("../../models/TiledeskChatbotConst");
|
|
7
|
-
const { TiledeskChatbotUtil } = require("../../models/TiledeskChatbotUtil");
|
|
8
6
|
require('dotenv').config();
|
|
9
7
|
|
|
10
8
|
class DirGptTask {
|
|
@@ -14,7 +12,6 @@ class DirGptTask {
|
|
|
14
12
|
throw new Error('context object is mandatory');
|
|
15
13
|
}
|
|
16
14
|
this.context = context;
|
|
17
|
-
this.chatbot = this.context.chatbot;
|
|
18
15
|
this.tdcache = this.context.tdcache;
|
|
19
16
|
this.requestId = this.context.requestId;
|
|
20
17
|
this.intentDir = new DirIntent(context);
|
|
@@ -50,7 +47,6 @@ class DirGptTask {
|
|
|
50
47
|
let falseIntent = action.falseIntent;
|
|
51
48
|
let trueIntentAttributes = action.trueIntentAttributes;
|
|
52
49
|
let falseIntentAttributes = action.falseIntentAttributes;
|
|
53
|
-
let transcript;
|
|
54
50
|
|
|
55
51
|
if (this.log) {
|
|
56
52
|
console.log("DirGptTask trueIntent", trueIntent)
|
|
@@ -66,7 +62,6 @@ class DirGptTask {
|
|
|
66
62
|
if (!action.question || action.question === '') {
|
|
67
63
|
console.error("Error: DirGptTask question attribute is mandatory. Executing condition false...")
|
|
68
64
|
if (falseIntent) {
|
|
69
|
-
await this.chatbot.addParameter("flowError", "GPT Error: question attribute is undefined");
|
|
70
65
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
71
66
|
callback(true);
|
|
72
67
|
return;
|
|
@@ -97,18 +92,6 @@ class DirGptTask {
|
|
|
97
92
|
console.log("DirGptTask temperature: ", temperature);
|
|
98
93
|
}
|
|
99
94
|
|
|
100
|
-
if (action.history) {
|
|
101
|
-
let transcript_string = await TiledeskChatbot.getParameterStatic(
|
|
102
|
-
this.context.tdcache,
|
|
103
|
-
this.context.requestId,
|
|
104
|
-
TiledeskChatbotConst.REQ_TRANSCRIPT_KEY);
|
|
105
|
-
if (this.log) { console.log("DirGptTask transcript string: ", transcript_string) }
|
|
106
|
-
|
|
107
|
-
transcript = await TiledeskChatbotUtil.transcriptJSON(transcript_string);
|
|
108
|
-
if (this.log) { console.log("DirGptTask transcript: ", transcript) }
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
95
|
const server_base_url = process.env.API_ENDPOINT || process.env.API_URL;
|
|
113
96
|
const openai_url = process.env.OPENAI_ENDPOINT + "/chat/completions";
|
|
114
97
|
if (this.log) {
|
|
@@ -132,7 +115,6 @@ class DirGptTask {
|
|
|
132
115
|
console.error("DirGptTask gptkey is mandatory");
|
|
133
116
|
await this.#assignAttributes(action, answer);
|
|
134
117
|
if (falseIntent) {
|
|
135
|
-
await this.chatbot.addParameter("flowError", "GPT Error: gpt apikey is undefined");
|
|
136
118
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
137
119
|
callback(true);
|
|
138
120
|
return;
|
|
@@ -152,39 +134,22 @@ class DirGptTask {
|
|
|
152
134
|
|
|
153
135
|
let json = {
|
|
154
136
|
model: action.model,
|
|
155
|
-
messages: [
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// ],
|
|
137
|
+
messages: [
|
|
138
|
+
{
|
|
139
|
+
role: "user",
|
|
140
|
+
content: filled_question
|
|
141
|
+
}
|
|
142
|
+
],
|
|
162
143
|
max_tokens: action.max_tokens,
|
|
163
|
-
temperature: action.temperature
|
|
144
|
+
temperature: action.temperature
|
|
164
145
|
}
|
|
165
146
|
|
|
166
147
|
let message = { role: "", content: "" };
|
|
167
|
-
|
|
168
148
|
if (action.context) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
json.messages.push(message);
|
|
149
|
+
message.role = "system";
|
|
150
|
+
message.content = filled_context;
|
|
151
|
+
json.messages.unshift(message);
|
|
174
152
|
}
|
|
175
|
-
|
|
176
|
-
if (transcript) {
|
|
177
|
-
transcript.forEach(msg => {
|
|
178
|
-
if (!msg.content.startsWith('/')) {
|
|
179
|
-
let message = {
|
|
180
|
-
role: msg.role,
|
|
181
|
-
content: msg.content
|
|
182
|
-
}
|
|
183
|
-
json.messages.push(message)
|
|
184
|
-
}
|
|
185
|
-
})
|
|
186
|
-
}
|
|
187
|
-
|
|
188
153
|
if (this.log) { console.log("DirGptTask json: ", json) }
|
|
189
154
|
|
|
190
155
|
const HTTPREQUEST = {
|
|
@@ -202,11 +167,10 @@ class DirGptTask {
|
|
|
202
167
|
if (err) {
|
|
203
168
|
if (this.log) {
|
|
204
169
|
console.error("(httprequest) DirGptTask openai err:", err);
|
|
205
|
-
console.error("(httprequest) DirGptTask openai err:", err.response
|
|
170
|
+
console.error("(httprequest) DirGptTask openai err:", err.response.data);
|
|
206
171
|
}
|
|
207
172
|
await this.#assignAttributes(action, answer);
|
|
208
173
|
if (falseIntent) {
|
|
209
|
-
await this.chatbot.addParameter("flowError", "GPT Error: " + err.response?.data?.error?.message);
|
|
210
174
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
211
175
|
callback(true);
|
|
212
176
|
return;
|