@tiledesk/tiledesk-voice-twilio-connector 0.1.16-rc1 → 0.1.16-rc3
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
|
@@ -75,6 +75,8 @@ let time = null;
|
|
|
75
75
|
const utilsMess = require('./tiledesk/utils-message.js')
|
|
76
76
|
const TYPE_MESSAGE = require('./tiledesk/constants').TYPE_MESSAGE
|
|
77
77
|
|
|
78
|
+
let messageTimeout = null;
|
|
79
|
+
|
|
78
80
|
router.get("/", async (req, res) => {
|
|
79
81
|
res.send("Welcome to Tiledesk-voice-twilio connector");
|
|
80
82
|
});
|
|
@@ -285,7 +287,7 @@ router.post('/nextblock/:callSid/', async(req, res) => {
|
|
|
285
287
|
|
|
286
288
|
|
|
287
289
|
let message = await new Promise(async (resolve, reject) => {
|
|
288
|
-
winston.debug('******* user text -->'
|
|
290
|
+
winston.debug('******* user text -->'+ usertext)
|
|
289
291
|
if(usertext === '' || !usertext){
|
|
290
292
|
|
|
291
293
|
let message = await getMessage(callSid, from, project_id, conversation_id)
|
|
@@ -378,7 +380,7 @@ async function getMessage(callSid, from, project_id, conversation_id){
|
|
|
378
380
|
let delayTime = await voiceChannel.getNextDelayTimeForCallId(callSid)
|
|
379
381
|
await voiceChannel.saveDelayIndexForCallId(callSid)
|
|
380
382
|
winston.debug('(checkQueue FN ) RECALL checkQueue FN in: '+ delayTime + '[ms]')
|
|
381
|
-
setTimeout(checkQueue, delayTime);
|
|
383
|
+
messageTimeout = setTimeout(checkQueue, delayTime);
|
|
382
384
|
|
|
383
385
|
}catch(err){
|
|
384
386
|
winston.debug("Error occurred while check message in queue: ", err);
|
|
@@ -678,6 +680,11 @@ router.post('/event/:callSid/:event', async(req, res)=> {
|
|
|
678
680
|
winston.debug("(voice) called POST /event query" , req.query);
|
|
679
681
|
winston.debug("(voice) called POST /event body" , req.body);
|
|
680
682
|
|
|
683
|
+
//clear getMessage function timeout
|
|
684
|
+
if(messageTimeout){
|
|
685
|
+
clearTimeout(messageTimeout)
|
|
686
|
+
}
|
|
687
|
+
|
|
681
688
|
let event = req.params.event;
|
|
682
689
|
let callSid = req.params.callSid;
|
|
683
690
|
let currentIntentName = req.query.intentName;
|
|
@@ -778,6 +785,11 @@ router.post('/twilio/status',async (req, res) => {
|
|
|
778
785
|
let event = req.body.CallStatus;
|
|
779
786
|
let callSid = req.body.CallSid;
|
|
780
787
|
|
|
788
|
+
//clear getMessage function timeout
|
|
789
|
+
if(messageTimeout){
|
|
790
|
+
clearTimeout(messageTimeout)
|
|
791
|
+
}
|
|
792
|
+
|
|
781
793
|
let sessionInfo;
|
|
782
794
|
let project_id, conversation_id, user;
|
|
783
795
|
let from, to;
|
package/package.json
CHANGED