@tiledesk/tiledesk-tybot-connector 0.2.9 → 0.2.11

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,15 @@
5
5
  available on:
6
6
  ▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
7
7
 
8
+ ### 0.2.11
9
+ - TiledeskClient update to 0.10.3
10
+ - updateLead() replaces the deprecated updateLeadData()
11
+ - added support to automatically update userPhone as well as the already supported userEmail and UserFullname
12
+ - fixed form messages: missing replace of {{...}} attributes
13
+
14
+ ### 0.2.10 - online pre
15
+ - WebRequest: "body" renamed in "jsonBody"
16
+
8
17
  ### 0.2.9 - online
9
18
  - restored logs
10
19
 
@@ -735,7 +735,14 @@ class TiledeskChatbot {
735
735
  if (all_parameters) {
736
736
  if (this.log) {console.log("(populatePrechatFormAndLead) userEmail:", all_parameters['userEmail']);}
737
737
  if (this.log) {console.log("(populatePrechatFormAndLead) userFullname:", all_parameters['userFullname']);}
738
- tdclient.updateLeadData(leadId, all_parameters['userEmail'], all_parameters['userFullname'], null, () => {
738
+ if (this.log) {console.log("(populatePrechatFormAndLead) userPhone:", all_parameters['userPhone']);}
739
+ let nativeAttributes = {
740
+ email: all_parameters['userEmail'],
741
+ fullname: all_parameters['userFullname'],
742
+ phone: all_parameters['userPhone']
743
+ }
744
+ // tdclient.updateLeadData(leadId, all_parameters['userEmail'], all_parameters['userFullname'], null, () => {
745
+ tdclient.updateLead(leadId, nativeAttributes, null, null, () => {
739
746
  if (this.log) {console.log("Lead updated.")}
740
747
  // tdclient.updateRequestAttributes(requestId, {
741
748
  // preChatForm: all_parameters,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -14,7 +14,7 @@
14
14
  "@tiledesk/helpcenter-query-client": "^0.1.8",
15
15
  "@tiledesk/tiledesk-chatbot-client": "^0.5.30",
16
16
  "@tiledesk/tiledesk-chatbot-util": "^0.8.39",
17
- "@tiledesk/tiledesk-client": "^0.10.2",
17
+ "@tiledesk/tiledesk-client": "^0.10.3",
18
18
  "accept-language-parser": "^1.5.0",
19
19
  "axios": "^0.27.2",
20
20
  "body-parser": "^1.19.0",
@@ -1,5 +1,6 @@
1
1
  const { TiledeskChatbotUtil } = require('@tiledesk/tiledesk-chatbot-util');
2
2
  const { TiledeskChatbot } = require('../models/TiledeskChatbot.js');
3
+ const { Filler } = require('./Filler');
3
4
 
4
5
  class FillParamsChatbotPlug {
5
6
 
@@ -34,7 +35,10 @@ class FillParamsChatbotPlug {
34
35
  pipeline.nextplug();
35
36
  return;
36
37
  }
37
- const filled_message_text = this.fillWithRequestParams(message.text, all_parameters);
38
+
39
+ const filler = new Filler();
40
+ const filled_message_text = filler.fill(message.text, all_parameters);
41
+ // const filled_message_text = this.fillWithRequestParams(message.text, all_parameters);
38
42
  message.text = filled_message_text;
39
43
  //console.log("message filled_message_text:", message)
40
44
  if (!message.attributes) {
@@ -55,15 +55,15 @@ class DirWebRequestV2 {
55
55
  }
56
56
  }
57
57
  let json = null;
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);
58
+ if (action.jsonBody && action.bodyType == "json") {
59
+ if (this.log) {console.log("action.body is:", action.jsonBody);}
60
+ let jsonBody = filler.fill(action.jsonBody, requestVariables);
61
61
  try {
62
- json = JSON.parse(body);
62
+ json = JSON.parse(jsonBody);
63
63
  if (this.log) {console.log("json is:", json);}
64
64
  }
65
65
  catch(err) {
66
- console.error("Error parsing webRequest jsonBody:", body);
66
+ console.error("Error parsing webRequest jsonBody:", jsonBody);
67
67
  }
68
68
  }
69
69