@tiledesk/tiledesk-voice-twilio-connector 0.1.16-rc2 → 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 +14 -5
- package/package.json +1 -1
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
|
});
|
|
@@ -252,9 +254,6 @@ router.post('/nextblock/:callSid/', async(req, res) => {
|
|
|
252
254
|
let from, to;
|
|
253
255
|
|
|
254
256
|
let redis_data = await redis_client.get('tiledesk:vxml:'+callSid+':session');
|
|
255
|
-
console.log('redissssss', redis_client)
|
|
256
|
-
console.log('redissssss 2', 'tiledesk:vxml:'+callSid+':session')
|
|
257
|
-
console.log('redissssss 3', redis_data)
|
|
258
257
|
//let redis_data = await redis_client.hGetAll('tiledesk:vxml:'+callId);
|
|
259
258
|
if (!redis_data) {
|
|
260
259
|
return res.status(500).send({ success: "false", message: "Can't retrive data for callSid ->" + callSid });
|
|
@@ -288,7 +287,7 @@ router.post('/nextblock/:callSid/', async(req, res) => {
|
|
|
288
287
|
|
|
289
288
|
|
|
290
289
|
let message = await new Promise(async (resolve, reject) => {
|
|
291
|
-
winston.debug('******* user text -->'
|
|
290
|
+
winston.debug('******* user text -->'+ usertext)
|
|
292
291
|
if(usertext === '' || !usertext){
|
|
293
292
|
|
|
294
293
|
let message = await getMessage(callSid, from, project_id, conversation_id)
|
|
@@ -381,7 +380,7 @@ async function getMessage(callSid, from, project_id, conversation_id){
|
|
|
381
380
|
let delayTime = await voiceChannel.getNextDelayTimeForCallId(callSid)
|
|
382
381
|
await voiceChannel.saveDelayIndexForCallId(callSid)
|
|
383
382
|
winston.debug('(checkQueue FN ) RECALL checkQueue FN in: '+ delayTime + '[ms]')
|
|
384
|
-
setTimeout(checkQueue, delayTime);
|
|
383
|
+
messageTimeout = setTimeout(checkQueue, delayTime);
|
|
385
384
|
|
|
386
385
|
}catch(err){
|
|
387
386
|
winston.debug("Error occurred while check message in queue: ", err);
|
|
@@ -681,6 +680,11 @@ router.post('/event/:callSid/:event', async(req, res)=> {
|
|
|
681
680
|
winston.debug("(voice) called POST /event query" , req.query);
|
|
682
681
|
winston.debug("(voice) called POST /event body" , req.body);
|
|
683
682
|
|
|
683
|
+
//clear getMessage function timeout
|
|
684
|
+
if(messageTimeout){
|
|
685
|
+
clearTimeout(messageTimeout)
|
|
686
|
+
}
|
|
687
|
+
|
|
684
688
|
let event = req.params.event;
|
|
685
689
|
let callSid = req.params.callSid;
|
|
686
690
|
let currentIntentName = req.query.intentName;
|
|
@@ -781,6 +785,11 @@ router.post('/twilio/status',async (req, res) => {
|
|
|
781
785
|
let event = req.body.CallStatus;
|
|
782
786
|
let callSid = req.body.CallSid;
|
|
783
787
|
|
|
788
|
+
//clear getMessage function timeout
|
|
789
|
+
if(messageTimeout){
|
|
790
|
+
clearTimeout(messageTimeout)
|
|
791
|
+
}
|
|
792
|
+
|
|
784
793
|
let sessionInfo;
|
|
785
794
|
let project_id, conversation_id, user;
|
|
786
795
|
let from, to;
|