@tiledesk/tiledesk-tybot-connector 0.2.64 → 0.2.65

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
@@ -6,6 +6,9 @@ available on:
6
6
  ▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
7
7
 
8
8
 
9
+ # v0.2.65
10
+ - fix OPENAI_APIKEY: removed Bearer prefix
11
+
9
12
  # v0.2.64
10
13
  - removed system parameters from /reserved/parameters
11
14
  - Web Request Action: added multipart form-data support with files binary from URL source
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.64",
3
+ "version": "0.2.65",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -47,7 +47,7 @@ class DirAssistant {
47
47
  const url = filler.fill(action.url, requestAttributes);
48
48
  // prompt => Mandatory
49
49
  // assistantId => Mandatory
50
- // threadIdAttributeName => Optional // default "firstThread"
50
+ // threadIdAttribute => Optional // default "firstThread"
51
51
  // assignResultTo => Optional // default "assistantReply"
52
52
  // assignErrorTo => Optional // default "assistantError"
53
53
  // action.settings.timeout => Optional
@@ -122,7 +122,7 @@ class DirAssistant {
122
122
 
123
123
  this.timeout = this.#webrequest_timeout(action, 20000, 1, 300000);
124
124
 
125
- const apikey = await this.getGPT_APIKEY();
125
+ let apikey = await this.getGPT_APIKEY();
126
126
  if (this.log) {console.log("apikey:", apikey);}
127
127
  if (!apikey) {
128
128
  const reply = "DirAssistant gptkey is mandatory in Integrations";
@@ -134,6 +134,10 @@ class DirAssistant {
134
134
  }
135
135
  return;
136
136
  }
137
+ else {
138
+ apikey = "Bearer " + apikey;
139
+ console.log("APIKEY::", apikey);
140
+ }
137
141
  let threadId = null;
138
142
  try {
139
143
  threadId = requestAttributes[threadIdAttribute];
@@ -143,11 +147,15 @@ class DirAssistant {
143
147
  const thread = await this.createThread(apikey);
144
148
  if (this.log) {console.log("Thread crated.");}
145
149
  threadId = thread.id;
150
+ await TiledeskChatbot.addParameterStatic(this.context.tdcache, this.context.requestId, threadIdAttribute, threadId);
146
151
  if (this.log) {
147
152
  console.log("thread:", thread);
148
153
  console.log("threadId:", threadId);
149
154
  }
150
155
  }
156
+ else {
157
+ if (this.log) { console.log("Reusing threadId (used flow attribute:" + threadIdAttribute + "):", threadId); }
158
+ }
151
159
  await this.addMessage(prompt, threadId, apikey);
152
160
  if (this.log) {console.log("Message added.");}
153
161
  await this.runThreadOnAssistant(assistantId, threadId, apikey);
@@ -502,11 +510,11 @@ class DirAssistant {
502
510
  if (this.log) { console.log("DirAssistant INTEGRATIONS_HTTPREQUEST ", INTEGRATIONS_HTTPREQUEST) }
503
511
 
504
512
  this.#myrequest(
505
- INTEGRATIONS_HTTPREQUEST, async (err, integration) => {
513
+ INTEGRATIONS_HTTPREQUEST, async (err, res) => {
506
514
  if (err) {
507
515
  resolve(null);
508
516
  } else {
509
-
517
+ let integration = res.data;
510
518
  if (integration &&
511
519
  integration.value) {
512
520
  resolve(integration.value.apikey)
@@ -563,7 +571,7 @@ class DirAssistant {
563
571
  axios(axios_options)
564
572
  .then((res) => {
565
573
  if (this.log) {
566
- console.log("Success Response:", res);
574
+ // console.log("Success Response:", res);
567
575
  console.log("Response for url:", options.url);
568
576
  console.log("Response headers:\n", JSON.stringify(res.headers));
569
577
  }