@tiledesk/tiledesk-whatsapp-connector 0.1.38 → 0.1.39

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/index.js CHANGED
@@ -253,8 +253,8 @@ router.get('/configure', async (req, res) => {
253
253
 
254
254
  router.post('/update', async (req, res) => {
255
255
  console.log("\n(whatsapp) /update");
256
- console.log("(whatsapp) /update body: ", req.body);
257
256
  if (log) {
257
+ console.log("(whatsapp) /update body: ", req.body);
258
258
  }
259
259
 
260
260
  let projectId = req.body.project_id;
@@ -448,8 +448,8 @@ router.post('/disconnect', async (req, res) => {
448
448
 
449
449
  router.post('/tiledesk', async (req, res) => {
450
450
  console.log("\n(whatsapp) /tiledesk")
451
- console.log("(whatsapp) /tiledesk ---> tiledeskChannelMessage: " + JSON.stringify(req.body.payload));
452
451
  if (log) {
452
+ console.log("(whatsapp) /tiledesk ---> tiledeskChannelMessage: " + JSON.stringify(req.body.payload));
453
453
  }
454
454
 
455
455
  var tiledeskChannelMessage = req.body.payload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-whatsapp-connector",
3
- "version": "0.1.38",
3
+ "version": "0.1.39",
4
4
  "description": "Tiledesk Whatsapp connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -204,29 +204,6 @@
204
204
  <!-- Departments -->
205
205
  <div class="form-group" style="width: 522px;">
206
206
  <label class="input-label" for="department">Department <span style="font-weight: normal;">(Optional)</span></label>
207
-
208
-
209
-
210
-
211
-
212
- <!--
213
- <div class="dep-container">
214
- {{#each departments}}
215
-
216
- {{#if (isEqual _id department_id)}}
217
- <div class="selected-department-div" onclick="submitInputSelected.click()">
218
- <img class="tick-image" src="https://static.vecteezy.com/system/resources/previews/010/152/436/original/tick-check-mark-icon-sign-symbol-design-free-png.png" width="18" height="auto">
219
- {{ name }}
220
- </div>
221
- {{else}}
222
- <div class="department-div">
223
- {{ name }}
224
- </div>
225
- {{/if}}
226
- {{/each}}
227
- </div>
228
- -->
229
-
230
207
  <div style="display: flex; flex-direction: row; align-items: center;">
231
208
  <select class="custom-select" name="department" class="form-control">
232
209
  {{#each departments}}
@@ -243,7 +220,6 @@
243
220
  </i>
244
221
  </span>
245
222
  </div>
246
-
247
223
  </div>
248
224
 
249
225
  <input type="hidden" name="project_id" value="{{ project_id }}" />
@@ -35,15 +35,17 @@ class MessageHandler {
35
35
  }
36
36
 
37
37
  async generateMessageObject(command) {
38
- console.log("[MessageHandler] command: ", command);
39
- //console.log("[MessageHandler] tiledeskChannelMessage: ", this.tiledeskChannelMessage);
40
- let tiledeskCommandMessage = command.message;
38
+ if (this.log) {
39
+ console.log("[MessageHandler] command: ", JSON.stringify(command));
40
+ }
41
41
 
42
+ let tiledeskCommandMessage = command.message;
42
43
  tiledeskCommandMessage.recipient = this.tiledeskChannelMessage.recipient;
43
44
 
44
45
  return tiledeskCommandMessage;
45
46
  }
46
47
 
48
+ /*
47
49
  generateMessageObjectOriginal(command_message) {
48
50
  let parentUid = this.tiledeskChannelMessage.uid
49
51
  //command_message.uid = this.tiledeskChannelMessage.uid + "_" + index;
@@ -65,6 +67,7 @@ class MessageHandler {
65
67
 
66
68
  return command_message
67
69
  }
70
+ */
68
71
 
69
72
 
70
73
 
@@ -51,11 +51,7 @@ class TiledeskBotTester {
51
51
 
52
52
  return new Promise( async (resolve, reject) => {
53
53
  console.log("\n/startBotConversation()");
54
- /*
55
- let projectId = req.params.project_id;
56
- console.log("(testitout) projectId: ", projectId)
57
- */
58
-
54
+
59
55
  let whatsappChannelMessage = body.entry[0].changes[0].value.messages[0];
60
56
  console.log("(testitout) whatsappChannelMessage: ", whatsappChannelMessage);
61
57
 
@@ -89,9 +89,9 @@ class TiledeskChannel {
89
89
  data: {},
90
90
  method: 'POST'
91
91
  }).then((response) => {
92
-
92
+
93
93
  let token = response.data.token;
94
-
94
+
95
95
  return axios({
96
96
  url: this.API_URL + `/${this.settings.project_id}/requests/me?channel=${messageInfo.channel}`,
97
97
  headers: {
@@ -118,6 +118,7 @@ class TiledeskChannel {
118
118
  console.log("[Tiledesk Channel] tiledeskMessage:", tiledeskMessage);
119
119
  }
120
120
 
121
+
121
122
  return axios({
122
123
  url: this.API_URL + `/${this.settings.project_id}/requests/${request_id}/messages`,
123
124
  headers: {
@@ -173,7 +174,10 @@ class TiledeskChannel {
173
174
 
174
175
  let channel;
175
176
  let new_request_id;
176
- tiledeskMessage.participants = ["bot_" + bot_id]
177
+ tiledeskMessage.participants = ["bot_" + bot_id];
178
+ tiledeskMessage.attributes = {
179
+ sourcePage: "whatsapp://&td_draft=true"
180
+ }
177
181
 
178
182
  if (messageInfo.channel == "whatsapp") {
179
183
  channel = messageInfo.whatsapp;
@@ -214,6 +218,7 @@ class TiledeskChannel {
214
218
  data: tiledeskMessage,
215
219
  method: 'POST'
216
220
  }).then((response) => {
221
+ console.log("##### response: ", JSON.stringify(response.data));
217
222
  return response.data
218
223
  }).catch((err) => {
219
224
  console.error("[Tiledesk Channel ERROR] send message (open conversation): " + err);
@@ -54,7 +54,7 @@ const path = require('path');
54
54
  toWhatsapp(tiledeskChannelMessage, whatsapp_receiver) {
55
55
 
56
56
  // to --> recipient
57
- if (this.log) {
57
+ if (!this.log) {
58
58
  console.log("[Translator] tiledesk message: ", tiledeskChannelMessage)
59
59
  }
60
60
 
@@ -70,7 +70,18 @@ const path = require('path');
70
70
  to: whatsapp_receiver,
71
71
  }
72
72
 
73
- if (tiledeskChannelMessage.metadata) {
73
+ if (tiledeskChannelMessage.type === 'frame') {
74
+ text = text + "\n\nšŸ‘‰ " + tiledeskChannelMessage.metadata.src
75
+ whatsapp_message.text = { body: text };
76
+
77
+ if (this.log) {
78
+ console.log("[Translator] whatsapp message: ", whatsapp_message)
79
+ }
80
+ return whatsapp_message
81
+ }
82
+
83
+ else if (tiledeskChannelMessage.metadata) {
84
+
74
85
 
75
86
  if ((tiledeskChannelMessage.metadata.type && tiledeskChannelMessage.metadata.type.startsWith('image')) || tiledeskChannelMessage.type.startsWith('image')) {
76
87
 
@@ -213,7 +224,8 @@ const path = require('path');
213
224
  id: "quick" + uuidv4().substring(0,4) + "_"+ btn.value,
214
225
  title: title
215
226
  }
216
- option_rows.push(row);
227
+ //option_rows.push(row);
228
+ action_rows.push(row);
217
229
  }
218
230
 
219
231
  if (btn.type == 'action') {
@@ -258,7 +270,7 @@ const path = require('path');
258
270
  if (option_rows.length == 0 && action_rows.length > 0) {
259
271
  sections = [
260
272
  {
261
- title: "Actions",
273
+ //title: "Menu",
262
274
  rows: action_rows
263
275
  }
264
276
  ]
Binary file
Binary file
Binary file
Binary file