@tiledesk/tiledesk-tybot-connector 2.0.26 → 2.0.27

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,9 @@
5
5
  available on:
6
6
  ▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
7
7
 
8
+ # 2.0.27
9
+ - bug-fixed: not all chatbot variable are updated with leadUpdate action
10
+
8
11
  # 2.0.26
9
12
 
10
13
  # 2.0.9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "2.0.26",
3
+ "version": "2.0.27",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -61,15 +61,24 @@ class DirContactUpdate {
61
61
  }
62
62
  const filler = new Filler();
63
63
  let updateProperties = {}
64
+
65
+ //map the key from the action to the chatbot const variable key
66
+ const keyToChatbotConstMap = {
67
+ fullname: TiledeskChatbotConst.REQ_LEAD_USERFULLNAME_KEY,
68
+ email: TiledeskChatbotConst.REQ_LEAD_EMAIL_KEY,
69
+ phone: TiledeskChatbotConst.REQ_USER_PHONE_KEY,
70
+ currentPhoneNumber: TiledeskChatbotConst.REQ_CURRENT_PHONE_NUMBER_KEY,
71
+ userLeadId: TiledeskChatbotConst.REQ_USER_LEAD_ID_KEY,
72
+ company: TiledeskChatbotConst.REQ_USER_COMPANY_KEY
73
+ };
74
+
64
75
  for (const [key, value] of Object.entries(contactProperties)) {
65
76
  let filled_value = filler.fill(value, requestAttributes);
66
77
  updateProperties[key] = filled_value;
67
78
  // it's important that all the lead's properties are immediatly updated in the current flow invocation so the updated values will be available in the next actions
68
- if (key === "fullname") {
69
- await this.context.chatbot.addParameter(TiledeskChatbotConst.REQ_LEAD_USERFULLNAME_KEY, filled_value);
70
- }
71
- else if ( key === "email") {
72
- await this.context.chatbot.addParameter(TiledeskChatbotConst.REQ_LEAD_EMAIL_KEY, filled_value);
79
+ const chatbotKey = keyToChatbotConstMap[key];
80
+ if (chatbotKey) {
81
+ await this.context.chatbot.addParameter(chatbotKey, filled_value);
73
82
  }
74
83
  }
75
84
  const leadId = requestAttributes[TiledeskChatbotConst.REQ_USER_LEAD_ID_KEY];