@tiledesk/tiledesk-tybot-connector 0.1.98 → 0.2.0

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
+ ### 0.2.00
9
+ - bug fix
10
+
11
+ ### 0.1.99
12
+ - webrequest json fix (jsonBody renamed to "body")
13
+ - webrequest added bodyType attribute (none | json)
14
+
8
15
  ### 0.1.98 - online
9
16
  - added default EX:86400 to exprire time to tdcache.set()
10
17
  - added "chatbot" instance to DirectivesChatbotPlug instance created in index.js
package/index.js CHANGED
@@ -39,7 +39,7 @@ router.post('/ext/:botid', async (req, res) => {
39
39
  res.status(200).send({"success":true});
40
40
 
41
41
  const botId = req.params.botid;
42
- if (log) {console.log("query botId:", botId);}
42
+ if (log) {console.log(" :", botId);}
43
43
  const message = req.body.payload;
44
44
  const messageId = message._id;
45
45
  //const faq_kb = req.body.hook; now it is "bot"
@@ -92,6 +92,7 @@ router.post('/ext/:botid', async (req, res) => {
92
92
  // bot = await botsDS.getBotById(botId);
93
93
  // bot = await botById(botId, projectId, tdcache, botsDS);
94
94
  bot = await botsDS.getBotByIdCache(botId, tdcache);
95
+ console.log("getBotByIdCache ---> bot: ", JSON.stringify(bot, null, 2))
95
96
  }
96
97
  catch(error) {
97
98
  console.error("Error getting botId:", botId);
@@ -245,6 +246,7 @@ async function updateRequestVariables(chatbot, message, projectId, requestId) {
245
246
  if (chatbot.log) {console.log("Updating request variables. Message:", JSON.stringify(message));}
246
247
  const messageId = message._id;
247
248
  const chat_url = `https://panel.tiledesk.com/v3/dashboard/#/project/${projectId}/wsrequest/${requestId}/messages`
249
+ // await chatbot.addParameter("chatbot", chatbot);
248
250
  await chatbot.addParameter(TiledeskChatbotConst.REQ_CHAT_URL, chat_url);
249
251
  await chatbot.addParameter(TiledeskChatbotConst.REQ_PROJECT_ID_KEY, projectId);
250
252
  // TODO add projectName too
@@ -6,12 +6,14 @@ class IntentsMachineFactory {
6
6
  static getMachine(bot, botId, projectId, log) {
7
7
  let machine;
8
8
  if (bot.intentsEngine === "tiledesk-ai") {
9
+ console.log("bot.intentsEngine is tiledesk-ai");
9
10
  machine = new TiledeskIntentsMachine(
10
11
  {
11
12
  botId: botId
12
13
  });
13
14
  }
14
15
  else {
16
+ console.log("bot.intentsEngine is null");
15
17
  if (log) {console.log("Setting MongodbIntentsMachine with bot:", JSON.stringify(bot));}
16
18
  machine = new MongodbIntentsMachine({projectId: projectId, language: bot.language, log});
17
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.1.98",
3
+ "version": "0.2.00",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -55,13 +55,15 @@ class DirWebRequestV2 {
55
55
  }
56
56
  }
57
57
  let json = null;
58
- if (action.jsonBody) {
59
- let jsonBody = filler.fill(action.jsonBody, requestVariables);
58
+ if (action.body && action.bodyType == "json") {
59
+ if (this.log) {console.log("action.body is:", action.body);}
60
+ let body = filler.fill(action.body, requestVariables);
60
61
  try {
61
- json = JSON.parse(jsonBody);
62
+ json = JSON.parse(body);
63
+ if (this.log) {console.log("json is:", json);}
62
64
  }
63
65
  catch(err) {
64
- console.error("Error parsing webRequest jsonBody:", jsonBody);
66
+ console.error("Error parsing webRequest jsonBody:", body);
65
67
  }
66
68
  }
67
69