Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / services / routing / server / applications / dialogflow.js
index 9a2e366..f00c6d8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb4c7=['providerName','providerResponse','metadata','endConversation','lodash','moment','apiai-promise','md5','./utils','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/whatsappMessage','consequence','isNil','UserId','info','[%s][DIALOGFLOW]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','contact','format','YYYY-MM-DD\x20HH:mm:ss','out','channel','whatsapp','phone','interaction','chat','ChatWebsiteId','account','AccountId','upperFirst','InteractionId','created','body','getMustacheRender','Message','create','catch','error','stringify','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!','stop','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','textRequest','message','then','dialogflow','result','fulfillment','speech'];(function(_0xe77565,_0x2aaa7c){var _0x8ee878=function(_0x256bb7){while(--_0x256bb7){_0xe77565['push'](_0xe77565['shift']());}};_0x8ee878(++_0x2aaa7c);}(_0xb4c7,0x1ea));var _0x7b4c=function(_0x1e5399,_0x245ae4){_0x1e5399=_0x1e5399-0x0;var _0x42157b=_0xb4c7[_0x1e5399];return _0x42157b;};'use strict';var _=require(_0x7b4c('0x0'));var moment=require(_0x7b4c('0x1'));var apiai=require(_0x7b4c('0x2'));var md5=require(_0x7b4c('0x3'));var utils=require(_0x7b4c('0x4'));var logger=require('../../../../config/logger')(_0x7b4c('0x5'));var rpc={'chatMessage':require(_0x7b4c('0x6')),'openchannelMessage':require(_0x7b4c('0x7')),'mailMessage':require(_0x7b4c('0x8')),'smsMessage':require(_0x7b4c('0x9')),'faxMessage':require('../../rpc/faxMessage'),'whatsappMessage':require(_0x7b4c('0xa'))};exports[_0x7b4c('0xb')]=function(_0x2dd5c7,_0x4bf85d){return function(_0x2d7b7e){try{if(!_[_0x7b4c('0xc')](this['interaction'][_0x7b4c('0xd')])){logger[_0x7b4c('0xe')](_0x7b4c('0xf'),_0x2dd5c7,_0x7b4c('0x10'));return _0x2d7b7e[_0x7b4c('0x11')]();}var _0x93d013={'ContactId':this[_0x7b4c('0x12')]['id'],'sentAt':moment()[_0x7b4c('0x13')](_0x7b4c('0x14')),'direction':_0x7b4c('0x15')};if(this['channel']==='sms'||this[_0x7b4c('0x16')]===_0x7b4c('0x17')){_0x93d013[_0x7b4c('0x18')]=this[_0x7b4c('0x19')][_0x7b4c('0x18')];}var _0x341d36=this[_0x7b4c('0x16')];if(_0x341d36===_0x7b4c('0x1a')){_0x93d013[_0x7b4c('0x1b')]=this[_0x7b4c('0x1c')]['id'];}else{_0x93d013[_['upperFirst'](_0x341d36)+_0x7b4c('0x1d')]=this[_0x7b4c('0x1c')]['id'];}_0x93d013[_[_0x7b4c('0x1e')](_0x341d36)+_0x7b4c('0x1f')]=this[_0x7b4c('0x19')]['id'];if(this[_0x7b4c('0x19')][_0x7b4c('0x20')]){var _0x22c409=_0x4bf85d[0x2];if(!_['isEmpty'](_0x22c409)){_0x93d013[_0x7b4c('0x21')]=utils[_0x7b4c('0x22')](_0x22c409,this);return rpc[_0x341d36+_0x7b4c('0x23')][_0x7b4c('0x24')](_0x93d013)['then'](function(_0x3ce10c){logger[_0x7b4c('0xe')](_0x7b4c('0xf'),_0x2dd5c7,_0x93d013[_0x7b4c('0x21')]);})[_0x7b4c('0x25')](function(_0x1363b4){logger[_0x7b4c('0x26')](_0x7b4c('0xf'),_0x2dd5c7,JSON[_0x7b4c('0x27')](_0x1363b4));})['finally'](function(){logger[_0x7b4c('0xe')](_0x7b4c('0x28'),_0x2dd5c7);_0x2d7b7e[_0x7b4c('0x29')]();});}else{logger[_0x7b4c('0xe')](_0x7b4c('0x2a'),_0x2dd5c7);_0x2d7b7e[_0x7b4c('0x29')]();}}else{var _0x176704=this;var _0x3d4826=apiai(_0x4bf85d[0x0],{'language':_0x4bf85d[0x1]||'en'});return _0x3d4826[_0x7b4c('0x2b')](this[_0x7b4c('0x2c')]['body'],{'sessionId':md5(this[_0x7b4c('0x19')]['id'])})[_0x7b4c('0x2d')](function(_0x276271){_0x176704[_0x7b4c('0x21')][_0x7b4c('0x2e')]=_0x276271;_0x93d013[_0x7b4c('0x21')]=_0x276271[_0x7b4c('0x2f')][_0x7b4c('0x30')][_0x7b4c('0x31')];_0x93d013[_0x7b4c('0x32')]=_0x7b4c('0x2e');_0x93d013[_0x7b4c('0x33')]=JSON[_0x7b4c('0x27')](_0x276271);return rpc[_0x341d36+'Message'][_0x7b4c('0x24')](_0x93d013)[_0x7b4c('0x2d')](function(_0x1fe0f5){logger[_0x7b4c('0xe')](_0x7b4c('0xf'),_0x2dd5c7,_0x93d013[_0x7b4c('0x21')]);if(_0x276271[_0x7b4c('0x2f')][_0x7b4c('0x34')][_0x7b4c('0x35')]){_0x2d7b7e[_0x7b4c('0x11')]();}else{_0x2d7b7e[_0x7b4c('0x29')]();}})[_0x7b4c('0x25')](function(_0x3544bc){logger[_0x7b4c('0x26')](_0x7b4c('0xf'),_0x2dd5c7,JSON[_0x7b4c('0x27')](_0x3544bc));_0x2d7b7e[_0x7b4c('0x11')]();});})[_0x7b4c('0x25')](function(_0x9d3d31){logger['error']('[%s][DIALOGFLOW]\x20%s',_0x2dd5c7,_0x9d3d31['message']);_0x2d7b7e[_0x7b4c('0x11')]();});}}catch(_0x2efff3){logger[_0x7b4c('0x26')](_0x7b4c('0xf'),_0x2dd5c7,JSON['stringify'](_0x2efff3));_0x2d7b7e[_0x7b4c('0x29')]();}};};
\ No newline at end of file
+var _0x22da=['Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','contact','format','YYYY-MM-DD\x20HH:mm:ss','sms','channel','phone','ChatWebsiteId','account','upperFirst','AccountId','InteractionId','created','isEmpty','body','getMustacheRender','Message','create','then','info','catch','error','stringify','stop','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','textRequest','dialogflow','result','fulfillment','speech','providerResponse','metadata','next','message','apiai-promise','md5','./utils','../../../../config/logger','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/whatsappMessage','consequence','isNil','interaction','[%s][DIALOGFLOW]\x20%s'];(function(_0x363bfb,_0x5c5bcb){var _0x223528=function(_0x1d95ba){while(--_0x1d95ba){_0x363bfb['push'](_0x363bfb['shift']());}};_0x223528(++_0x5c5bcb);}(_0x22da,0x80));var _0xa22d=function(_0x543297,_0x58cac4){_0x543297=_0x543297-0x0;var _0x45990c=_0x22da[_0x543297];return _0x45990c;};'use strict';var _=require('lodash');var moment=require('moment');var apiai=require(_0xa22d('0x0'));var md5=require(_0xa22d('0x1'));var utils=require(_0xa22d('0x2'));var logger=require(_0xa22d('0x3'))('routing');var rpc={'chatMessage':require(_0xa22d('0x4')),'openchannelMessage':require(_0xa22d('0x5')),'mailMessage':require(_0xa22d('0x6')),'smsMessage':require(_0xa22d('0x7')),'faxMessage':require('../../rpc/faxMessage'),'whatsappMessage':require(_0xa22d('0x8'))};exports[_0xa22d('0x9')]=function(_0x4c67ad,_0x215529){return function(_0x44a5c7){try{if(!_[_0xa22d('0xa')](this[_0xa22d('0xb')]['UserId'])){logger['info'](_0xa22d('0xc'),_0x4c67ad,_0xa22d('0xd'));return _0x44a5c7['next']();}var _0x312520={'ContactId':this[_0xa22d('0xe')]['id'],'sentAt':moment()[_0xa22d('0xf')](_0xa22d('0x10')),'direction':'out'};if(this['channel']===_0xa22d('0x11')||this[_0xa22d('0x12')]==='whatsapp'){_0x312520[_0xa22d('0x13')]=this['interaction'][_0xa22d('0x13')];}var _0x3e49f4=this[_0xa22d('0x12')];if(_0x3e49f4==='chat'){_0x312520[_0xa22d('0x14')]=this[_0xa22d('0x15')]['id'];}else{_0x312520[_[_0xa22d('0x16')](_0x3e49f4)+_0xa22d('0x17')]=this[_0xa22d('0x15')]['id'];}_0x312520[_['upperFirst'](_0x3e49f4)+_0xa22d('0x18')]=this[_0xa22d('0xb')]['id'];if(this[_0xa22d('0xb')][_0xa22d('0x19')]){var _0x14a1a7=_0x215529[0x2];if(!_[_0xa22d('0x1a')](_0x14a1a7)){_0x312520[_0xa22d('0x1b')]=utils[_0xa22d('0x1c')](_0x14a1a7,this);return rpc[_0x3e49f4+_0xa22d('0x1d')][_0xa22d('0x1e')](_0x312520)[_0xa22d('0x1f')](function(_0x1ed22e){logger[_0xa22d('0x20')](_0xa22d('0xc'),_0x4c67ad,_0x312520[_0xa22d('0x1b')]);})[_0xa22d('0x21')](function(_0x47f683){logger[_0xa22d('0x22')](_0xa22d('0xc'),_0x4c67ad,JSON[_0xa22d('0x23')](_0x47f683));})['finally'](function(){logger['info']('[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!',_0x4c67ad);_0x44a5c7[_0xa22d('0x24')]();});}else{logger[_0xa22d('0x20')](_0xa22d('0x25'),_0x4c67ad);_0x44a5c7['stop']();}}else{var _0x389675=this;var _0x45f528=apiai(_0x215529[0x0],{'language':_0x215529[0x1]||'en'});return _0x45f528[_0xa22d('0x26')](this['message'][_0xa22d('0x1b')],{'sessionId':md5(this[_0xa22d('0xb')]['id'])})['then'](function(_0x24701d){_0x389675[_0xa22d('0x1b')][_0xa22d('0x27')]=_0x24701d;_0x312520[_0xa22d('0x1b')]=_0x24701d[_0xa22d('0x28')][_0xa22d('0x29')][_0xa22d('0x2a')];_0x312520['providerName']='dialogflow';_0x312520[_0xa22d('0x2b')]=JSON[_0xa22d('0x23')](_0x24701d);return rpc[_0x3e49f4+_0xa22d('0x1d')][_0xa22d('0x1e')](_0x312520)[_0xa22d('0x1f')](function(_0x291763){logger[_0xa22d('0x20')](_0xa22d('0xc'),_0x4c67ad,_0x312520[_0xa22d('0x1b')]);if(_0x24701d[_0xa22d('0x28')][_0xa22d('0x2c')]['endConversation']){_0x44a5c7[_0xa22d('0x2d')]();}else{_0x44a5c7['stop']();}})['catch'](function(_0x1d7b33){logger[_0xa22d('0x22')](_0xa22d('0xc'),_0x4c67ad,JSON[_0xa22d('0x23')](_0x1d7b33));_0x44a5c7[_0xa22d('0x2d')]();});})[_0xa22d('0x21')](function(_0x1ef634){logger[_0xa22d('0x22')]('[%s][DIALOGFLOW]\x20%s',_0x4c67ad,_0x1ef634[_0xa22d('0x2e')]);_0x44a5c7[_0xa22d('0x2d')]();});}}catch(_0x301b96){logger[_0xa22d('0x22')](_0xa22d('0xc'),_0x4c67ad,JSON[_0xa22d('0x23')](_0x301b96));_0x44a5c7[_0xa22d('0x24')]();}};};
\ No newline at end of file