@tiledesk/tiledesk-tybot-connector 0.1.19 → 0.1.21
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 +7 -1
- package/index.js +2 -2
- package/package.json +1 -1
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +1 -1
- package/tiledeskChatbotPlugs/FillParamsChatbotPlug.js +4 -3
- package/tiledeskChatbotPlugs/directives/DirMessage.js +10 -6
- package/tiledeskChatbotPlugs/directives/DirOfflineHours.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
# Tiledesk tybotRoute
|
|
2
2
|
|
|
3
|
-
**npm @tiledesk/tiledesk-tybot-connector@0.1.
|
|
3
|
+
**npm @tiledesk/tiledesk-tybot-connector@0.1.21**
|
|
4
4
|
|
|
5
5
|
available on:
|
|
6
6
|
▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
|
|
7
7
|
|
|
8
|
+
### 0.1.21
|
|
9
|
+
- fixed orginal_text unused var that creating problems in DirOfflineHours
|
|
10
|
+
|
|
11
|
+
### 0.1.20
|
|
12
|
+
- bug fixing on ExtApi endpoint (External chatbots compromised messaging)
|
|
13
|
+
|
|
8
14
|
### 0.1.19
|
|
9
15
|
- fixed action-intent not working
|
|
10
16
|
|
package/index.js
CHANGED
|
@@ -123,11 +123,11 @@ router.post('/ext/:projectId/requests/:requestId/messages', async (req, res) =>
|
|
|
123
123
|
const request_key = "tilebot:" + requestId;
|
|
124
124
|
if (tdcache) {
|
|
125
125
|
request = await tdcache.getJSON(request_key)
|
|
126
|
-
if (log) {console.log("HIT! Request from cache:", request
|
|
126
|
+
if (log) {console.log("HIT! Request from cache:", request);}
|
|
127
127
|
if (!request) {
|
|
128
128
|
if (log) {console.log("!Request from cache", requestId);}
|
|
129
129
|
request = await tdclient.getRequestById(requestId);
|
|
130
|
-
if (log) {console.log("Got request with APIs (after no cache hit)");}
|
|
130
|
+
if (log) {console.log("Got request with APIs (after no cache hit):", request);}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
else {
|
package/package.json
CHANGED
|
@@ -161,7 +161,7 @@ class DirectivesChatbotPlug {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
else if (directive_name === Directives.MESSAGE) {
|
|
164
|
-
const messageDir = new DirMessage();
|
|
164
|
+
const messageDir = new DirMessage({API_ENDPOINT: API_URL});
|
|
165
165
|
messageDir.execute(directive, projectId, requestId, token, () => {
|
|
166
166
|
process(nextDirective());
|
|
167
167
|
});
|
|
@@ -33,9 +33,10 @@ class FillParamsChatbotPlug {
|
|
|
33
33
|
if (this.log) {console.log("all_parameters of requestId:", requestId)}
|
|
34
34
|
const all_parameters = await TiledeskChatbot.allParametersStatic(this.tdcache, requestId);
|
|
35
35
|
if (this.log) {console.log("--got parameters", all_parameters);}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
if (!all_parameters) {
|
|
37
|
+
pipeline.nextplug();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
39
40
|
//all_parameters["tdMessageId"] = message.triggeredByMessageId;
|
|
40
41
|
//console.log("FillParamsChatbotPlug message:", message);
|
|
41
42
|
//console.log("all_parameters[tdMessageId]:", all_parameters["tdMessageId"]);
|
|
@@ -2,7 +2,11 @@ const { ExtApi } = require('../../ExtApi.js');
|
|
|
2
2
|
|
|
3
3
|
class DirMessage {
|
|
4
4
|
|
|
5
|
-
constructor() {
|
|
5
|
+
constructor(settings) {
|
|
6
|
+
if (!settings.API_ENDPOINT) {
|
|
7
|
+
throw new Error("settings.API_ENDPOINT is mandatory!");
|
|
8
|
+
}
|
|
9
|
+
this.API_ENDPOINT = settings.API_ENDPOINT;
|
|
6
10
|
}
|
|
7
11
|
|
|
8
12
|
execute(directive, projectId, requestId, token, callback) {
|
|
@@ -17,10 +21,10 @@ class DirMessage {
|
|
|
17
21
|
}
|
|
18
22
|
}
|
|
19
23
|
//console.log("Message:", message);
|
|
20
|
-
let extEndpoint = `${
|
|
21
|
-
if (process.env.TYBOT_ENDPOINT) {
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
+
let extEndpoint = `${this.API_ENDPOINT}/modules/tilebot`;
|
|
25
|
+
//if (process.env.TYBOT_ENDPOINT) {
|
|
26
|
+
// extEndpoint = `${process.env.TYBOT_ENDPOINT}`;
|
|
27
|
+
//}
|
|
24
28
|
const apiext = new ExtApi({
|
|
25
29
|
ENDPOINT: extEndpoint,
|
|
26
30
|
log: true
|
|
@@ -29,7 +33,7 @@ class DirMessage {
|
|
|
29
33
|
message.attributes = {}
|
|
30
34
|
}
|
|
31
35
|
message.attributes.directives = false;
|
|
32
|
-
message.attributes.splitted =
|
|
36
|
+
message.attributes.splitted = true;
|
|
33
37
|
message.attributes.markbot = true;
|
|
34
38
|
if (message.text) {
|
|
35
39
|
//console.log("original message:", message.text);
|
|
@@ -53,7 +53,7 @@ class DirOfflineHours {
|
|
|
53
53
|
reply(pipeline, directive, offline_reply, callback) {
|
|
54
54
|
let message = pipeline.message;
|
|
55
55
|
console.log("message in pipeline:", JSON.stringify(message));
|
|
56
|
-
const original_text = message.attributes.intent_info.question_payload.text
|
|
56
|
+
//const original_text = message.attributes.intent_info.question_payload.text
|
|
57
57
|
this.tdclient.openNow((err, result) => {
|
|
58
58
|
console.log("whenofflinehours result...", result);
|
|
59
59
|
if (err) {
|