Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / services / routing / server / applications / dialogflow.js
index 923358f..ef74f76 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf02c=['consequence','info','[%s][DIALOGFLOW]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','contact','format','YYYY-MM-DD\x20HH:mm:ss','sms','channel','whatsapp','phone','interaction','chat','ChatWebsiteId','account','upperFirst','AccountId','InteractionId','created','isEmpty','body','then','catch','stringify','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!','stop','textRequest','message','result','fulfillment','speech','providerName','dialogflow','providerResponse','Message','create','metadata','endConversation','error','lodash','moment','apiai-promise','md5','./utils','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage'];(function(_0xe0e9ad,_0x5af9cf){var _0x1ae462=function(_0x3883af){while(--_0x3883af){_0xe0e9ad['push'](_0xe0e9ad['shift']());}};_0x1ae462(++_0x5af9cf);}(_0xf02c,0x92));var _0xcf02=function(_0x3bc395,_0x36b58a){_0x3bc395=_0x3bc395-0x0;var _0x6a48fa=_0xf02c[_0x3bc395];return _0x6a48fa;};'use strict';var _=require(_0xcf02('0x0'));var moment=require(_0xcf02('0x1'));var apiai=require(_0xcf02('0x2'));var md5=require(_0xcf02('0x3'));var utils=require(_0xcf02('0x4'));var logger=require(_0xcf02('0x5'))(_0xcf02('0x6'));var rpc={'chatMessage':require(_0xcf02('0x7')),'openchannelMessage':require(_0xcf02('0x8')),'mailMessage':require(_0xcf02('0x9')),'smsMessage':require(_0xcf02('0xa')),'faxMessage':require(_0xcf02('0xb')),'whatsappMessage':require(_0xcf02('0xc'))};exports[_0xcf02('0xd')]=function(_0x3569a1,_0x49ad8e){return function(_0x45745e){try{if(!_['isNil'](this['interaction']['UserId'])){logger[_0xcf02('0xe')](_0xcf02('0xf'),_0x3569a1,_0xcf02('0x10'));return _0x45745e[_0xcf02('0x11')]();}var _0x5bd27c={'ContactId':this[_0xcf02('0x12')]['id'],'sentAt':moment()[_0xcf02('0x13')](_0xcf02('0x14')),'direction':'out'};if(this['channel']===_0xcf02('0x15')||this[_0xcf02('0x16')]===_0xcf02('0x17')){_0x5bd27c[_0xcf02('0x18')]=this[_0xcf02('0x19')]['phone'];}var _0x4448c2=this[_0xcf02('0x16')];if(_0x4448c2===_0xcf02('0x1a')){_0x5bd27c[_0xcf02('0x1b')]=this[_0xcf02('0x1c')]['id'];}else{_0x5bd27c[_[_0xcf02('0x1d')](_0x4448c2)+_0xcf02('0x1e')]=this['account']['id'];}_0x5bd27c[_[_0xcf02('0x1d')](_0x4448c2)+_0xcf02('0x1f')]=this[_0xcf02('0x19')]['id'];if(this['interaction'][_0xcf02('0x20')]){var _0x419418=_0x49ad8e[0x2];if(!_[_0xcf02('0x21')](_0x419418)){_0x5bd27c[_0xcf02('0x22')]=utils['getMustacheRender'](_0x419418,this);return rpc[_0x4448c2+'Message']['create'](_0x5bd27c)[_0xcf02('0x23')](function(_0x53a97e){logger[_0xcf02('0xe')](_0xcf02('0xf'),_0x3569a1,_0x5bd27c[_0xcf02('0x22')]);})[_0xcf02('0x24')](function(_0x56c4e8){logger['error'](_0xcf02('0xf'),_0x3569a1,JSON[_0xcf02('0x25')](_0x56c4e8));})['finally'](function(){logger[_0xcf02('0xe')](_0xcf02('0x26'),_0x3569a1);_0x45745e[_0xcf02('0x27')]();});}else{logger[_0xcf02('0xe')]('[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!',_0x3569a1);_0x45745e[_0xcf02('0x27')]();}}else{var _0x4260e2=this;var _0x3bf3f4=apiai(_0x49ad8e[0x0],{'language':_0x49ad8e[0x1]||'en'});return _0x3bf3f4[_0xcf02('0x28')](this[_0xcf02('0x29')][_0xcf02('0x22')],{'sessionId':md5(this[_0xcf02('0x19')]['id'])})[_0xcf02('0x23')](function(_0x4f651c){_0x4260e2['body']['dialogflow']=_0x4f651c;_0x5bd27c[_0xcf02('0x22')]=_0x4f651c[_0xcf02('0x2a')][_0xcf02('0x2b')][_0xcf02('0x2c')];_0x5bd27c[_0xcf02('0x2d')]=_0xcf02('0x2e');_0x5bd27c[_0xcf02('0x2f')]=JSON[_0xcf02('0x25')](_0x4f651c);return rpc[_0x4448c2+_0xcf02('0x30')][_0xcf02('0x31')](_0x5bd27c)[_0xcf02('0x23')](function(_0x58c2a3){logger['info'](_0xcf02('0xf'),_0x3569a1,_0x5bd27c[_0xcf02('0x22')]);if(_0x4f651c[_0xcf02('0x2a')][_0xcf02('0x32')][_0xcf02('0x33')]){_0x45745e[_0xcf02('0x11')]();}else{_0x45745e[_0xcf02('0x27')]();}})[_0xcf02('0x24')](function(_0x32edbf){logger['error'](_0xcf02('0xf'),_0x3569a1,JSON[_0xcf02('0x25')](_0x32edbf));_0x45745e[_0xcf02('0x11')]();});})['catch'](function(_0x2bef8e){logger[_0xcf02('0x34')]('[%s][DIALOGFLOW]\x20%s',_0x3569a1,_0x2bef8e[_0xcf02('0x29')]);_0x45745e[_0xcf02('0x11')]();});}}catch(_0x5bb15e){logger[_0xcf02('0x34')](_0xcf02('0xf'),_0x3569a1,JSON[_0xcf02('0x25')](_0x5bb15e));_0x45745e[_0xcf02('0x27')]();}};};
\ No newline at end of file
+var _0xad40=['textRequest','message','then','dialogflow','result','providerName','stringify','metadata','endConversation','error','lodash','moment','apiai-promise','md5','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','consequence','isNil','interaction','UserId','[%s][DIALOGFLOW]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','contact','format','YYYY-MM-DD\x20HH:mm:ss','channel','sms','whatsapp','phone','chat','account','AccountId','upperFirst','created','isEmpty','body','Message','create','info','catch','stop','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!'];(function(_0x1a08cc,_0x1ff763){var _0x2ce2ec=function(_0x4c28a9){while(--_0x4c28a9){_0x1a08cc['push'](_0x1a08cc['shift']());}};_0x2ce2ec(++_0x1ff763);}(_0xad40,0xfa));var _0x0ad4=function(_0x31e29a,_0x349c9b){_0x31e29a=_0x31e29a-0x0;var _0x32d892=_0xad40[_0x31e29a];return _0x32d892;};'use strict';var _=require(_0x0ad4('0x0'));var moment=require(_0x0ad4('0x1'));var apiai=require(_0x0ad4('0x2'));var md5=require(_0x0ad4('0x3'));var utils=require('./utils');var logger=require(_0x0ad4('0x4'))(_0x0ad4('0x5'));var rpc={'chatMessage':require(_0x0ad4('0x6')),'openchannelMessage':require(_0x0ad4('0x7')),'mailMessage':require(_0x0ad4('0x8')),'smsMessage':require(_0x0ad4('0x9')),'faxMessage':require(_0x0ad4('0xa')),'whatsappMessage':require('../../rpc/whatsappMessage')};exports[_0x0ad4('0xb')]=function(_0x1ad5fc,_0x1fa7ac){return function(_0x3e738d){try{if(!_[_0x0ad4('0xc')](this[_0x0ad4('0xd')][_0x0ad4('0xe')])){logger['info'](_0x0ad4('0xf'),_0x1ad5fc,_0x0ad4('0x10'));return _0x3e738d[_0x0ad4('0x11')]();}var _0x2c5757={'ContactId':this[_0x0ad4('0x12')]['id'],'sentAt':moment()[_0x0ad4('0x13')](_0x0ad4('0x14')),'direction':'out'};if(this[_0x0ad4('0x15')]===_0x0ad4('0x16')||this[_0x0ad4('0x15')]===_0x0ad4('0x17')){_0x2c5757[_0x0ad4('0x18')]=this[_0x0ad4('0xd')][_0x0ad4('0x18')];}var _0x67f340=this[_0x0ad4('0x15')];if(_0x67f340===_0x0ad4('0x19')){_0x2c5757['ChatWebsiteId']=this[_0x0ad4('0x1a')]['id'];}else{_0x2c5757[_['upperFirst'](_0x67f340)+_0x0ad4('0x1b')]=this['account']['id'];}_0x2c5757[_[_0x0ad4('0x1c')](_0x67f340)+'InteractionId']=this[_0x0ad4('0xd')]['id'];if(this['interaction'][_0x0ad4('0x1d')]){var _0x5a611f=_0x1fa7ac[0x2];if(!_[_0x0ad4('0x1e')](_0x5a611f)){_0x2c5757[_0x0ad4('0x1f')]=utils['getMustacheRender'](_0x5a611f,this);return rpc[_0x67f340+_0x0ad4('0x20')][_0x0ad4('0x21')](_0x2c5757)['then'](function(_0x196d75){logger[_0x0ad4('0x22')](_0x0ad4('0xf'),_0x1ad5fc,_0x2c5757[_0x0ad4('0x1f')]);})[_0x0ad4('0x23')](function(_0x5a3460){logger['error'](_0x0ad4('0xf'),_0x1ad5fc,JSON['stringify'](_0x5a3460));})['finally'](function(){logger[_0x0ad4('0x22')]('[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!',_0x1ad5fc);_0x3e738d[_0x0ad4('0x24')]();});}else{logger[_0x0ad4('0x22')](_0x0ad4('0x25'),_0x1ad5fc);_0x3e738d[_0x0ad4('0x24')]();}}else{var _0x34810e=this;var _0x327bf8=apiai(_0x1fa7ac[0x0],{'language':_0x1fa7ac[0x1]||'en'});return _0x327bf8[_0x0ad4('0x26')](this[_0x0ad4('0x27')][_0x0ad4('0x1f')],{'sessionId':md5(this[_0x0ad4('0xd')]['id'])})[_0x0ad4('0x28')](function(_0x2bd3f2){_0x34810e[_0x0ad4('0x1f')][_0x0ad4('0x29')]=_0x2bd3f2;_0x2c5757['body']=_0x2bd3f2[_0x0ad4('0x2a')]['fulfillment']['speech'];_0x2c5757[_0x0ad4('0x2b')]=_0x0ad4('0x29');_0x2c5757['providerResponse']=JSON[_0x0ad4('0x2c')](_0x2bd3f2);return rpc[_0x67f340+_0x0ad4('0x20')][_0x0ad4('0x21')](_0x2c5757)[_0x0ad4('0x28')](function(_0x53af91){logger[_0x0ad4('0x22')](_0x0ad4('0xf'),_0x1ad5fc,_0x2c5757[_0x0ad4('0x1f')]);if(_0x2bd3f2[_0x0ad4('0x2a')][_0x0ad4('0x2d')][_0x0ad4('0x2e')]){_0x3e738d['next']();}else{_0x3e738d[_0x0ad4('0x24')]();}})[_0x0ad4('0x23')](function(_0x529826){logger['error'](_0x0ad4('0xf'),_0x1ad5fc,JSON['stringify'](_0x529826));_0x3e738d['next']();});})[_0x0ad4('0x23')](function(_0x4df804){logger[_0x0ad4('0x2f')](_0x0ad4('0xf'),_0x1ad5fc,_0x4df804[_0x0ad4('0x27')]);_0x3e738d['next']();});}}catch(_0x2e8fed){logger[_0x0ad4('0x2f')](_0x0ad4('0xf'),_0x1ad5fc,JSON[_0x0ad4('0x2c')](_0x2e8fed));_0x3e738d[_0x0ad4('0x24')]();}};};
\ No newline at end of file