@tiledesk/tiledesk-voice-twilio-connector 0.1.20 → 0.1.22

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
@@ -269,8 +269,8 @@ router.post('/nextblock/:callSid/', async(req, res) => {
269
269
  user = sessionInfo.user;
270
270
 
271
271
  let vxmlAttributes = {
272
- TTS_VOICE_LANGUAGE: null,
273
- TTS_VOICE_NAME: null,
272
+ TTS_VOICE_LANGUAGE: VOICE_LANGUAGE,
273
+ TTS_VOICE_NAME: VOICE_NAME,
274
274
  callSid: callSid,
275
275
  };
276
276
 
@@ -426,8 +426,8 @@ router.post('/speechresult/:callSid', async (req, res) => {
426
426
  user = sessionInfo.user;
427
427
 
428
428
  let vxmlAttributes = {
429
- TTS_VOICE_LANGUAGE: null,
430
- TTS_VOICE_NAME: null,
429
+ TTS_VOICE_LANGUAGE: VOICE_LANGUAGE,
430
+ TTS_VOICE_NAME: VOICE_NAME,
431
431
  callSid: callSid,
432
432
  };
433
433
 
@@ -551,8 +551,8 @@ router.post('/menublock/:callSid', async (req, res) => {
551
551
  user = sessionInfo.user;
552
552
 
553
553
  let vxmlAttributes = {
554
- TTS_VOICE_LANGUAGE: null,
555
- TTS_VOICE_NAME: null,
554
+ TTS_VOICE_LANGUAGE: VOICE_LANGUAGE,
555
+ TTS_VOICE_NAME: VOICE_NAME,
556
556
  callSid: callSid,
557
557
  };
558
558
 
@@ -625,8 +625,8 @@ router.post('/handle/:callSid/:event', async (req, res) => {
625
625
  user = sessionInfo.user;
626
626
 
627
627
  let vxmlAttributes = {
628
- TTS_VOICE_LANGUAGE: null,
629
- TTS_VOICE_NAME: null,
628
+ TTS_VOICE_LANGUAGE: VOICE_LANGUAGE,
629
+ TTS_VOICE_NAME: VOICE_NAME,
630
630
  callSid: callSid,
631
631
  };
632
632
 
@@ -710,8 +710,8 @@ router.post('/event/:callSid/:event', async(req, res)=> {
710
710
  user = sessionInfo.user;
711
711
 
712
712
  let vxmlAttributes = {
713
- TTS_VOICE_LANGUAGE: null,
714
- TTS_VOICE_NAME: null,
713
+ TTS_VOICE_LANGUAGE: VOICE_LANGUAGE,
714
+ TTS_VOICE_NAME: VOICE_NAME,
715
715
  callSid: callSid,
716
716
  };
717
717
 
@@ -809,8 +809,8 @@ router.post('/twilio/status',async (req, res) => {
809
809
  user = sessionInfo.user;
810
810
 
811
811
  let vxmlAttributes = {
812
- TTS_VOICE_LANGUAGE: null,
813
- TTS_VOICE_NAME: null,
812
+ TTS_VOICE_LANGUAGE: VOICE_LANGUAGE,
813
+ TTS_VOICE_NAME: VOICE_NAME,
814
814
  callSid: callSid,
815
815
  };
816
816
 
@@ -894,8 +894,8 @@ router.post('/record/:callSid/',async (req, res) => {
894
894
  user = sessionInfo.user;
895
895
 
896
896
  let vxmlAttributes = {
897
- TTS_VOICE_LANGUAGE: null,
898
- TTS_VOICE_NAME: null,
897
+ TTS_VOICE_LANGUAGE: VOICE_LANGUAGE,
898
+ TTS_VOICE_NAME: VOICE_NAME,
899
899
  callSid: callSid,
900
900
  };
901
901
 
@@ -1116,8 +1116,8 @@ router.get('/test', async (req, res) => {
1116
1116
 
1117
1117
 
1118
1118
  let vxmlAttributes = {
1119
- TTS_VOICE_LANGUAGE: null,
1120
- TTS_VOICE_NAME: null,
1119
+ TTS_VOICE_LANGUAGE: VOICE_LANGUAGE,
1120
+ TTS_VOICE_NAME: VOICE_NAME,
1121
1121
  callSid: callSid
1122
1122
  };
1123
1123
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-voice-twilio-connector",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "description": "Tiledesk VOICE Twilio connector",
5
5
  "license": "MIT",
6
6
  "author": "Gabriele Panico",
@@ -84,6 +84,7 @@ router.get('/configure', async (req, res) => {
84
84
  } else {
85
85
 
86
86
  let proxy_url = BASE_URL + "/webhook/" + project_id
87
+ let status_url = BASE_URL + "/twilio/status"
87
88
 
88
89
  let CONTENT_KEY = CHANNEL_NAME + "-" + project_id;
89
90
 
@@ -111,6 +112,7 @@ router.get('/configure', async (req, res) => {
111
112
  project_id: project_id,
112
113
  token: token,
113
114
  proxy_url: proxy_url,
115
+ status_url: status_url,
114
116
  subscription_id: settings.subscriptionId,
115
117
  department_id: settings.department_id,
116
118
  account_sid: settings.account_sid,
@@ -138,6 +140,7 @@ router.get('/configure', async (req, res) => {
138
140
  project_id: project_id,
139
141
  token: token,
140
142
  proxy_url: proxy_url,
143
+ status_url: status_url,
141
144
  departments: departments,
142
145
  popup_view: popup_view,
143
146
  brand_name: BRAND_NAME
@@ -167,7 +170,8 @@ router.post('/update', async (req, res) => {
167
170
 
168
171
  winston.verbose("(voice) /update settings", settings);
169
172
 
170
- let proxy_url = BASE_URL + "/webhook/" + project_id
173
+ let proxy_url = BASE_URL + "/webhook/" + project_id;
174
+ let status_url = BASE_URL + "/twilio/status";
171
175
 
172
176
  // get departments
173
177
  const tdChannel = new TiledeskChannel({
@@ -199,6 +203,7 @@ router.post('/update', async (req, res) => {
199
203
  project_id: project_id,
200
204
  token: token,
201
205
  proxy_url: proxy_url,
206
+ status_url: status_url,
202
207
  show_success_modal: true,
203
208
  subscription_id: settings.subscriptionId,
204
209
  department_id: settings.department_id,
@@ -223,6 +228,7 @@ router.post('/update', async (req, res) => {
223
228
  project_id: project_id,
224
229
  token: token,
225
230
  proxy_url: proxy_url,
231
+ status_url: status_url,
226
232
  show_success_modal: true,
227
233
  subscription_id: subscription.subscriptionId,
228
234
  account_sid: account_sid,
@@ -243,6 +249,7 @@ router.post('/update', async (req, res) => {
243
249
  project_id: project_id,
244
250
  token: token,
245
251
  proxy_url: proxy_url,
252
+ status_url: status_url,
246
253
  departments: departments,
247
254
  show_error_modal: true,
248
255
  brand_name: BRAND_NAME
@@ -268,7 +275,8 @@ router.post('/disconnect', async (req, res) => {
268
275
  await db.remove(CONTENT_KEY);
269
276
  winston.verbose("(voice) Content deleted.");
270
277
 
271
- let proxy_url = BASE_URL + "/webhook/" + project_id
278
+ let proxy_url = BASE_URL + "/webhook/" + project_id;
279
+ let status_url = BASE_URL + "/twilio/status";
272
280
 
273
281
  // get departments
274
282
  const tdChannel = new TiledeskChannel({
@@ -293,6 +301,7 @@ router.post('/disconnect', async (req, res) => {
293
301
  project_id: project_id,
294
302
  token: token,
295
303
  proxy_url: proxy_url,
304
+ status_url: status_url,
296
305
  departments: departments,
297
306
  brand_name: BRAND_NAME
298
307
  }
@@ -177,7 +177,7 @@
177
177
  <div style="display: flex; flex-direction: row;">
178
178
  <div style="width: 522px;">
179
179
  <div style="display: flex; flex-direction: row; align-items: center;">
180
- <input type="text" readonly class="form-control copy-form custom-input" name="proxy_url" id="proxy_url" value="{{ proxy_url}}">
180
+ <input type="text" readonly class="form-control copy-form custom-input" name="proxy_url" id="proxy_url" value="{{proxy_url}}">
181
181
  <span style="margin-left: 10px;">
182
182
  <i class="fa fa-question-circle custom-tooltip">
183
183
  <span class="custom-tooltiptext">This is the endpoint to be reached by Twilio. Copy it to the Voice "Configuration URL" section in Configure Tab of your number. Please set "HTTP POST" as the method of the API call</span>
@@ -187,7 +187,31 @@
187
187
  </div>
188
188
 
189
189
  </div>
190
- <div id="copy-div" class="icon-btn-div" onclick="copyTextToClipboard()">
190
+ <div id="copy-div" class="icon-btn-div" onclick="copyTextToClipboard('proxy_url')">
191
+ <i class="fa fa-copy icon-btn"></i>
192
+ </div>
193
+ <div id="copied-div" class="icon-btn-div" style="visibility: hidden;">
194
+ <i class="fa fa-check icon-btn" style="margin-left: -74px; color: green;"></i>
195
+ </div>
196
+ </div>
197
+ </div>
198
+
199
+ <div class="form-group" style="width: 590px;">
200
+ <label class="input-label" for="proxy_url">Status callback URL</label>
201
+ <div style="display: flex; flex-direction: row;">
202
+ <div style="width: 522px;">
203
+ <div style="display: flex; flex-direction: row; align-items: center;">
204
+ <input type="text" readonly class="form-control copy-form custom-input" name="status_url" id="status_url" value="{{status_url}}">
205
+ <span style="margin-left: 10px;">
206
+ <i class="fa fa-question-circle custom-tooltip">
207
+ <span class="custom-tooltiptext">This is the endpoint to be reached by Twilio. Copy it to the Voice "Configuration URL" section in Configure Tab of your number. Please set "HTTP POST" as the method of the API call</span>
208
+ </i>
209
+ </span>
210
+
211
+ </div>
212
+
213
+ </div>
214
+ <div id="copy-div" class="icon-btn-div" onclick="copyTextToClipboard('status_url')">
191
215
  <i class="fa fa-copy icon-btn"></i>
192
216
  </div>
193
217
  <div id="copied-div" class="icon-btn-div" style="visibility: hidden;">
@@ -332,8 +356,8 @@
332
356
 
333
357
  <script>
334
358
 
335
- function copyTextToClipboard() {
336
- const proxyUrl = document.getElementById('proxy_url').select()
359
+ function copyTextToClipboard(element_id) {
360
+ const proxyUrl = document.getElementById(element_id).select()
337
361
 
338
362
  //document.querySelector('textarea').select();
339
363
  try {
@@ -77,8 +77,7 @@ class TiledeskTwilioTranslator {
77
77
  vxmlAttributes.TTS_MODEL = flowAttributes.TTS_MODEL? flowAttributes.TTS_MODEL : OPENAI_SETTINGS.TTS_MODEL;
78
78
  vxmlAttributes.STT_MODEL = flowAttributes.STT_MODEL? flowAttributes.STT_MODEL : OPENAI_SETTINGS.STT_MODEL;
79
79
  }
80
-
81
-
80
+
82
81
 
83
82
  }
84
83
 
@@ -310,7 +309,7 @@ class TiledeskTwilioTranslator {
310
309
  const queryUrl = '?intentName='+ querystring.encode(xmlAttributes.intentName) + "&previousIntentTimestamp="+Date.now();
311
310
  gather.att("action", this.BASE_URL + '/speechresult/' + xmlAttributes.callSid + queryUrl)
312
311
  .att("method", "POST")
313
- .att("language", xmlAttributes.voiceLanguage)
312
+ .att("language", xmlAttributes.TTS_VOICE_LANGUAGE)
314
313
  .att('speechTimeout', "0")
315
314
 
316
315
  //if(xmlAttributes && xmlAttributes.noInputTimeout){
@@ -377,7 +376,7 @@ class TiledeskTwilioTranslator {
377
376
  .att("numDigits", "1" )
378
377
  .att("action", this.BASE_URL + '/menublock/' + xmlAttributes.callSid + queryUrl)
379
378
  .att("method", "POST")
380
- .att("language", xmlAttributes.voiceLanguage)
379
+ .att("language", xmlAttributes.TTS_VOICE_LANGUAGE)
381
380
 
382
381
  const prompt = await this.promptVXML(gather, message, xmlAttributes);
383
382
 
@@ -398,7 +397,7 @@ class TiledeskTwilioTranslator {
398
397
  gather.att("timeout", xmlAttributes.noInputTimeout/1000 )
399
398
  .att("action", this.BASE_URL + '/menublock/' + xmlAttributes.callSid + queryUrl)
400
399
  .att("method", "POST")
401
- .att("language", xmlAttributes.voiceLanguage)
400
+ .att("language", xmlAttributes.TTS_VOICE_LANGUAGE)
402
401
  const settings = await this.optionsVXML(gather, message, xmlAttributes);
403
402
 
404
403
  const prompt = this.promptVXML(gather, message, xmlAttributes);
@@ -429,7 +428,7 @@ class TiledeskTwilioTranslator {
429
428
  //rootEle.att("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
430
429
  //rootEle.att( "xsi:schemaLocation", "http://www.w3.org/2001/vxml http://www.w3.org/TR/2007/REC-voicexml21-20070619/vxml.xsd");
431
430
  //rootEle.att("version", "2.1");
432
- //rootEle.att("xml:lang", attributes.voiceLanguage);
431
+ //rootEle.att("xml:lang", attributes.TTS_VOICE_LANGUAGE);
433
432
 
434
433
  rootEle.ele("Parameter", { name: "callSid", value: "'" + attributes.callSid + "'" }).up();
435
434
  rootEle.ele("Parameter", { name: "intentName", value: "'" + attributes.intentName + "'"}).up();
@@ -40,8 +40,8 @@ module.exports = {
40
40
  },
41
41
  BASE_POOLING_DELAY: 250,
42
42
  MAX_POLLING_TIME: 30000,
43
- VOICE_NAME: 'Polly.Bianca-Neural',
44
- VOICE_LANGUAGE: 'it-IT',
43
+ VOICE_NAME: 'Polly.Danielle',
44
+ VOICE_LANGUAGE: 'en-US',
45
45
  CALL_STATUS: {
46
46
  INITIATED: 'initiated',
47
47
  RINGING: 'ringing',
@@ -69,7 +69,12 @@ class UploadService {
69
69
  }).catch((err) => {
70
70
  console.log('err', err)
71
71
  reject(err);
72
- })
72
+ }).finally(() => {
73
+ // Sempre eseguito
74
+ if (fs.existsSync(tempFilePath)) {
75
+ fs.unlinkSync(tempFilePath);
76
+ }
77
+ });
73
78
 
74
79
  })
75
80
  }