@tiledesk/tiledesk-voice-twilio-connector 0.1.12 → 0.1.13

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
@@ -82,7 +82,7 @@ router.post("/tiledesk", async (req, res) => {
82
82
 
83
83
  // TWILIO WEBHOOK : message from user to tiledesk
84
84
  router.post('/webhook/:id_project', async (req, res) => {
85
- winston.debug('(voice) called POST /webhook/:id_project ', req.params)
85
+ winston.verbose('(voice) called POST /webhook/:id_project '+ new Date(), req.params)
86
86
 
87
87
  let project_id = req.params.id_project;
88
88
  let callSid = req.body.CallSid;
@@ -185,8 +185,8 @@ router.post('/webhook/:id_project', async (req, res) => {
185
185
 
186
186
 
187
187
  router.post('/nextblock/:callSid/', async(req, res) => {
188
- winston.debug("(vxml) called POST /nextblock" , req.body);
189
- winston.debug("(vxml) called POST /nextblock query", req.query);
188
+ winston.verbose("(vxml) called POST /nextblock" + new Date(), req.body);
189
+ winston.verbose("(vxml) called POST /nextblock query", req.query);
190
190
 
191
191
  let usertext = req.body.SpeechResult;
192
192
  let confidence = req.body.Confidence
@@ -279,6 +279,7 @@ router.post('/nextblock/:callSid/', async(req, res) => {
279
279
  // convert response to vxml
280
280
  let messageToVXML = await tdTranslator.toVXML(message, callSid, vxmlAttributes)
281
281
  winston.debug("(voice) VXML to SEND: "+ messageToVXML);
282
+ winston.debug("(voice) send response to TWILIO : "+ new Date());
282
283
 
283
284
  // Render the response as XML in reply to the webhook request
284
285
  res.set('Content-Type', 'text/xml');
@@ -287,8 +288,8 @@ router.post('/nextblock/:callSid/', async(req, res) => {
287
288
 
288
289
 
289
290
  router.post('/menublock/:callSid', async (req, res) => {
290
- winston.debug("(voice) called POST /menu", req.body);
291
- winston.debug("(voice) called POST /menu query" , req.query);
291
+ winston.verbose("(voice) called POST /menu", req.body);
292
+ winston.verbose("(voice) called POST /menu query" , req.query);
292
293
 
293
294
  let message_text = '';
294
295
  let attributes = {};
@@ -390,7 +391,7 @@ router.post('/menublock/:callSid', async (req, res) => {
390
391
  });
391
392
 
392
393
  router.post('/handle/:callSid/:event', async (req, res) => {
393
- winston.debug("(voice) called POST /handle", req.body);
394
+ winston.verbose("(voice) called POST /handle", req.body);
394
395
  winston.debug("(voice) called POST /handle query -->", req.query);
395
396
  winston.debug("(voice) called POST /handle params-->", req.params);
396
397
 
@@ -467,7 +468,7 @@ router.post('/handle/:callSid/:event', async (req, res) => {
467
468
 
468
469
  /* ----> catch Event block <----- */
469
470
  router.post('/event/:callSid/:event', async(req, res)=> {
470
- winston.debug("(voice) called POST /event" , req.params);
471
+ winston.verbose("(voice) called POST /event" , req.params);
471
472
  winston.debug("(voice) called POST /event query" , req.query);
472
473
  winston.debug("(voice) called POST /event body" , req.body);
473
474
 
@@ -564,7 +565,7 @@ router.post('/event/:callSid/:event', async(req, res)=> {
564
565
 
565
566
  /* ----> catch Twilio Events <----- */
566
567
  router.post('/twilio/status',async (req, res) => {
567
- winston.debug('+++++++++++(voice) called POST twilio/status ', req.body);
568
+ winston.verbose('+++++++++++(voice) called POST twilio/status ', req.body);
568
569
 
569
570
  let event = req.body.CallStatus;
570
571
  let callSid = req.body.CallSid;
@@ -635,7 +636,7 @@ router.post('/twilio/status',async (req, res) => {
635
636
  })
636
637
 
637
638
  router.post('/twilio/fail',async (req, res) => {
638
- winston.debug('+++++++++++(voice) called POST twilio/fail ', req.params)
639
+ winston.verbose('+++++++++++(voice) called POST twilio/fail ', req.params)
639
640
  winston.debug('+++++++++++(voice) called POST twilio/fail ', req.body)
640
641
 
641
642
  res.set('Content-Type', 'text/xml');
@@ -645,7 +646,7 @@ router.post('/twilio/fail',async (req, res) => {
645
646
 
646
647
  /* ----> catch Twilio Events <----- */
647
648
  router.post('/record/:callSid/',async (req, res) => {
648
- winston.debug('+++++++++++(voice) called POST record/:callSid ', req.body);
649
+ winston.verbose('+++++++++++(voice) called POST record/:callSid ', req.body);
649
650
 
650
651
  let callSid = req.body.CallSid;
651
652
 
@@ -729,7 +730,7 @@ router.post('/record/:callSid/',async (req, res) => {
729
730
 
730
731
 
731
732
  router.get('/addon/transcript', async (req, res) => {
732
- winston.debug("(vxml) called GET /transcript query-->" , req.query);
733
+ winston.verbose("(vxml) called GET /transcript query-->" , req.query);
733
734
  winston.debug("(vxml) called GET /transcript body -->" , req.body);
734
735
 
735
736
  res.status(200).send('ok');
@@ -738,7 +739,7 @@ router.get('/addon/transcript', async (req, res) => {
738
739
 
739
740
  /** --> only for test purpose <-- **/
740
741
  router.get('/test', async (req, res) => {
741
- winston.debug("(vxml) called GET /test" , req.query);
742
+ winston.verbose("(vxml) called GET /test" , req.query);
742
743
 
743
744
  let project_id = req.query.id_project;
744
745
  let callSid = req.body.CallSid;
@@ -827,7 +828,7 @@ router.get('/test', async (req, res) => {
827
828
  type: 'wait',
828
829
  time: 0
829
830
  },
830
- {
831
+ /*{
831
832
  type: 'settings',
832
833
  subType: 'blind_transfer',
833
834
  settings: {
@@ -836,25 +837,26 @@ router.get('/test', async (req, res) => {
836
837
  falseIntent: "#falseIntenttt",
837
838
  trueIntent: "#trueIntennt"
838
839
  }
839
- }
840
+ }*/
840
841
  /*{
841
842
  type: 'settings',
842
843
  subType: 'dtmf_form',
843
844
  settings: {
844
845
  minDigits: 5,
845
846
  maxDigits: 5,
846
- terminators: "#"
847
+ terminators: "#",
848
+ noInputIntent: "#a",
849
+ noInputTimeout: 2000,
847
850
  }
848
851
  }*/
849
- /*{
852
+ {
850
853
  type: 'settings',
851
854
  subType: 'speech_form',
852
855
  settings: {
853
856
  noInputIntent: "#a",
854
857
  noInputTimeout: 2000,
855
- incompleteSpeechTimeout: 2000
856
858
  }
857
- }*/
859
+ }
858
860
  ]
859
861
  }
860
862
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-voice-twilio-connector",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Tiledesk VOICE Twilio connector",
5
5
  "license": "MIT",
6
6
  "author": "Gabriele Panico",
@@ -63,8 +63,7 @@ class KVBaseMongo {
63
63
  return new Promise((resolve, reject) => {
64
64
  //this.db.get(k).then(value => {resolve(value)});
65
65
 
66
- winston.debug("Searching on " + this.db)
67
- winston.verbose("Searching on Collection " + this.KV_COLLECTION + ' for key: ', k)
66
+ winston.debug("Searching on Collection " + this.KV_COLLECTION + ' for key: '+ k)
68
67
 
69
68
  this.db.collection(this.KV_COLLECTION).findOne({ key: k }, function(err, doc) {
70
69
  if (err) {
@@ -73,7 +72,7 @@ class KVBaseMongo {
73
72
  }
74
73
  else {
75
74
  if (doc) {
76
- winston.verbose("Doc found with key: " + doc.key);
75
+ winston.debug("Doc found with key: " + doc.key);
77
76
  resolve(doc.value);
78
77
  }
79
78
  else {
@@ -213,7 +213,6 @@ class TiledeskChannel {
213
213
  })
214
214
 
215
215
  const base64 = Buffer.from(stream.data, 'binary').toString('base64');
216
- console.log('baseeeeeeee', base64)
217
216
  return 'text'
218
217
 
219
218
 
@@ -258,17 +257,17 @@ class TiledeskChannel {
258
257
 
259
258
  /*SKIP INFO MESSAGES*/
260
259
  if(utils.messageType(TYPE_MESSAGE.INFO, message)){
261
- winston.verbose("> SKIPPING INFO message: " + JSON.stringify(message) );
260
+ winston.debug("> SKIPPING INFO message: " + JSON.stringify(message) );
262
261
  return;
263
262
  }
264
263
 
265
264
  /*SKIP CURRENT USER MESSAGES*/
266
265
  if (message.sender.indexOf(CHANNEL_NAME) > -1) {
267
- winston.verbose("> SKIPPING ECHO message: " + JSON.stringify(message) );
266
+ winston.debug("> SKIPPING ECHO message: " + JSON.stringify(message) );
268
267
  return;
269
268
  }
270
269
 
271
- winston.verbose("> SAVE message TO QUEUE: " + JSON.stringify(message) );
270
+ winston.debug("> SAVE message TO QUEUE: " + JSON.stringify(message) );
272
271
  /*SAVE MESSAGE TO QUEUE WITH KET tiledesk:queue:+conversation_id*/
273
272
  let conversation_id = message.recipient
274
273
  let redis_data = [ message ]
@@ -59,7 +59,7 @@ class TiledeskSubscriptionClient {
59
59
  if (callback) {
60
60
  callback(null, resbody);
61
61
  }
62
- winston.verbose("[TiledeskSubscriptionClient] Subscribed");
62
+ winston.debug("[TiledeskSubscriptionClient] Subscribed");
63
63
  resolve(resbody);
64
64
  }
65
65
  }, true);
@@ -92,7 +92,7 @@ class TiledeskSubscriptionClient {
92
92
  if (callback) {
93
93
  callback(null, resbody);
94
94
  }
95
- winston.verbose("[TiledeskSubscriptionClient] Unsubscribed");
95
+ winston.debug("[TiledeskSubscriptionClient] Unsubscribed");
96
96
  resolve(resbody);
97
97
  }
98
98
  }, true);
@@ -263,21 +263,24 @@ class TiledeskTwilioTranslator {
263
263
 
264
264
  const gather = rootEle.ele("Gather", { input: "speech"})
265
265
 
266
- if(xmlAttributes && xmlAttributes.noInputTimeout){
267
- gather.att("timeout", xmlAttributes.noInputTimeout/1000 ).up();
268
- }
269
-
270
266
  const queryUrl = '?intentName='+ querystring.encode(xmlAttributes.intentName) + "&previousIntentTimestamp="+Date.now();
271
267
  gather.att("action", this.BASE_URL + '/nextblock/' + xmlAttributes.callSid + queryUrl)
272
268
  .att("method", "POST")
273
269
  .att("language", xmlAttributes.voiceLanguage)
270
+ .att('speechTimeout', "auto")
274
271
 
272
+ if(xmlAttributes && xmlAttributes.noInputTimeout){
273
+ gather.att("timeout", xmlAttributes.noInputTimeout/1000 ).up();
274
+ }
275
+ if(xmlAttributes && xmlAttributes.incompleteSpeechTimeout){
276
+ gather.att("speechTimeout", xmlAttributes.incompleteSpeechTimeout/1000 ).up();
277
+ }
275
278
 
276
279
  const prompt = this.promptVXML(gather, message, xmlAttributes);
277
280
 
278
281
  const handleNoInputNoMatchQuery = await this.handleNoInputNoMatch(rootEle, message, xmlAttributes);
279
282
  if(handleNoInputNoMatchQuery && handleNoInputNoMatchQuery.queryNoInput){
280
- rootEle.ele("Redirect", {}, this.BASE_URL + '/handle/' + xmlAttributes.callSid + '/no_input?'+ handleNoInputNoMatchQuery.queryNoInput)
283
+ rootEle.ele("Redirect", {method: "POST"}, this.BASE_URL + '/handle/' + xmlAttributes.callSid + '/no_input?'+ handleNoInputNoMatchQuery.queryNoInput)
281
284
  }
282
285
 
283
286
 
@@ -355,7 +358,7 @@ class TiledeskTwilioTranslator {
355
358
 
356
359
  const handleNoInputNoMatchQuery = await this.handleNoInputNoMatch(rootEle, message, xmlAttributes);
357
360
  if(handleNoInputNoMatchQuery && handleNoInputNoMatchQuery.queryNoInput){
358
- rootEle.ele("Redirect", {}, this.BASE_URL + '/handle/' + xmlAttributes.callSid + '/no_input?'+ handleNoInputNoMatchQuery.queryNoInput)
361
+ rootEle.ele("Redirect", {method: "POST"}, this.BASE_URL + '/handle/' + xmlAttributes.callSid + '/no_input?'+ handleNoInputNoMatchQuery.queryNoInput)
359
362
  }
360
363
 
361
364
  //.ele('disconnect')