Built motion from commit (unavailable).|2.5.1
[motion2.git] / server / services / routing / server / applications / dialogflow.js
index 1c1dfd2..1f926b0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8a13=['getMustacheRender','Message','create','then','info','catch','error','stringify','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!','stop','textRequest','message','dialogflow','result','fulfillment','speech','metadata','endConversation','lodash','moment','apiai-promise','md5','./utils','../../../../config/logger','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','isNil','interaction','[%s][DIALOGFLOW]\x20%s','next','contact','format','YYYY-MM-DD\x20HH:mm:ss','out','channel','whatsapp','phone','chat','ChatWebsiteId','upperFirst','AccountId','account','InteractionId','isEmpty','body'];(function(_0x18f8ff,_0x257e95){var _0x18de97=function(_0xc8eb68){while(--_0xc8eb68){_0x18f8ff['push'](_0x18f8ff['shift']());}};_0x18de97(++_0x257e95);}(_0x8a13,0xd6));var _0x38a1=function(_0x205e5b,_0x3d9293){_0x205e5b=_0x205e5b-0x0;var _0x2e60db=_0x8a13[_0x205e5b];return _0x2e60db;};'use strict';var _=require(_0x38a1('0x0'));var moment=require(_0x38a1('0x1'));var apiai=require(_0x38a1('0x2'));var md5=require(_0x38a1('0x3'));var utils=require(_0x38a1('0x4'));var logger=require(_0x38a1('0x5'))('routing');var rpc={'chatMessage':require(_0x38a1('0x6')),'openchannelMessage':require(_0x38a1('0x7')),'mailMessage':require(_0x38a1('0x8')),'smsMessage':require(_0x38a1('0x9')),'faxMessage':require(_0x38a1('0xa')),'whatsappMessage':require(_0x38a1('0xb'))};exports['consequence']=function(_0x4d957b,_0x43c43e){return function(_0x2ae3fe){try{if(!_[_0x38a1('0xc')](this[_0x38a1('0xd')]['UserId'])){logger['info'](_0x38a1('0xe'),_0x4d957b,'Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.');return _0x2ae3fe[_0x38a1('0xf')]();}var _0x3e6f3d={'ContactId':this[_0x38a1('0x10')]['id'],'sentAt':moment()[_0x38a1('0x11')](_0x38a1('0x12')),'direction':_0x38a1('0x13')};if(this[_0x38a1('0x14')]==='sms'||this['channel']===_0x38a1('0x15')){_0x3e6f3d[_0x38a1('0x16')]=this[_0x38a1('0xd')][_0x38a1('0x16')];}var _0x3f2bba=this[_0x38a1('0x14')];if(_0x3f2bba===_0x38a1('0x17')){_0x3e6f3d[_0x38a1('0x18')]=this['account']['id'];}else{_0x3e6f3d[_[_0x38a1('0x19')](_0x3f2bba)+_0x38a1('0x1a')]=this[_0x38a1('0x1b')]['id'];}_0x3e6f3d[_[_0x38a1('0x19')](_0x3f2bba)+_0x38a1('0x1c')]=this[_0x38a1('0xd')]['id'];if(this[_0x38a1('0xd')]['created']){var _0x4331ea=_0x43c43e[0x2];if(!_[_0x38a1('0x1d')](_0x4331ea)){_0x3e6f3d[_0x38a1('0x1e')]=utils[_0x38a1('0x1f')](_0x4331ea,this);return rpc[_0x3f2bba+_0x38a1('0x20')][_0x38a1('0x21')](_0x3e6f3d)[_0x38a1('0x22')](function(_0xe7eb53){logger[_0x38a1('0x23')]('[%s][DIALOGFLOW]\x20%s',_0x4d957b,_0x3e6f3d[_0x38a1('0x1e')]);})[_0x38a1('0x24')](function(_0x267d65){logger[_0x38a1('0x25')](_0x38a1('0xe'),_0x4d957b,JSON[_0x38a1('0x26')](_0x267d65));})['finally'](function(){logger[_0x38a1('0x23')](_0x38a1('0x27'),_0x4d957b);_0x2ae3fe['stop']();});}else{logger[_0x38a1('0x23')]('[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!',_0x4d957b);_0x2ae3fe[_0x38a1('0x28')]();}}else{var _0x5c1580=this;var _0x510fb5=apiai(_0x43c43e[0x0],{'language':_0x43c43e[0x1]||'en'});return _0x510fb5[_0x38a1('0x29')](this[_0x38a1('0x2a')][_0x38a1('0x1e')],{'sessionId':md5(this['interaction']['id'])})['then'](function(_0x56b8a7){_0x5c1580[_0x38a1('0x1e')][_0x38a1('0x2b')]=_0x56b8a7;_0x3e6f3d['body']=_0x56b8a7[_0x38a1('0x2c')][_0x38a1('0x2d')][_0x38a1('0x2e')];_0x3e6f3d['providerName']=_0x38a1('0x2b');_0x3e6f3d['providerResponse']=JSON[_0x38a1('0x26')](_0x56b8a7);return rpc[_0x3f2bba+_0x38a1('0x20')][_0x38a1('0x21')](_0x3e6f3d)[_0x38a1('0x22')](function(_0x3e5183){logger[_0x38a1('0x23')](_0x38a1('0xe'),_0x4d957b,_0x3e6f3d['body']);if(_0x56b8a7[_0x38a1('0x2c')][_0x38a1('0x2f')][_0x38a1('0x30')]){_0x2ae3fe['next']();}else{_0x2ae3fe[_0x38a1('0x28')]();}})[_0x38a1('0x24')](function(_0x353774){logger[_0x38a1('0x25')]('[%s][DIALOGFLOW]\x20%s',_0x4d957b,JSON['stringify'](_0x353774));_0x2ae3fe['next']();});})[_0x38a1('0x24')](function(_0xcf853c){logger[_0x38a1('0x25')](_0x38a1('0xe'),_0x4d957b,_0xcf853c[_0x38a1('0x2a')]);_0x2ae3fe['next']();});}}catch(_0x176d26){logger[_0x38a1('0x25')]('[%s][DIALOGFLOW]\x20%s',_0x4d957b,JSON[_0x38a1('0x26')](_0x176d26));_0x2ae3fe[_0x38a1('0x28')]();}};};
\ No newline at end of file
+var _0x5c7a=['routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/whatsappMessage','consequence','isNil','interaction','UserId','info','[%s][DIALOGFLOW]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','contact','format','channel','sms','whatsapp','phone','chat','upperFirst','InteractionId','body','Message','create','then','catch','error','stringify','finally','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!','stop','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','textRequest','message','dialogflow','result','fulfillment','speech','providerName','metadata','endConversation','lodash','moment','apiai-promise','md5','./utils','../../../../config/logger'];(function(_0x331a2c,_0xc59b3e){var _0x508e83=function(_0x5e8d02){while(--_0x5e8d02){_0x331a2c['push'](_0x331a2c['shift']());}};_0x508e83(++_0xc59b3e);}(_0x5c7a,0x8d));var _0xa5c7=function(_0x3b76f7,_0x566c53){_0x3b76f7=_0x3b76f7-0x0;var _0x43984e=_0x5c7a[_0x3b76f7];return _0x43984e;};'use strict';var _=require(_0xa5c7('0x0'));var moment=require(_0xa5c7('0x1'));var apiai=require(_0xa5c7('0x2'));var md5=require(_0xa5c7('0x3'));var utils=require(_0xa5c7('0x4'));var logger=require(_0xa5c7('0x5'))(_0xa5c7('0x6'));var rpc={'chatMessage':require(_0xa5c7('0x7')),'openchannelMessage':require(_0xa5c7('0x8')),'mailMessage':require(_0xa5c7('0x9')),'smsMessage':require(_0xa5c7('0xa')),'faxMessage':require('../../rpc/faxMessage'),'whatsappMessage':require(_0xa5c7('0xb'))};exports[_0xa5c7('0xc')]=function(_0x5e1940,_0x214e3f){return function(_0x5cc82f){try{if(!_[_0xa5c7('0xd')](this[_0xa5c7('0xe')][_0xa5c7('0xf')])){logger[_0xa5c7('0x10')](_0xa5c7('0x11'),_0x5e1940,_0xa5c7('0x12'));return _0x5cc82f[_0xa5c7('0x13')]();}var _0x3a5fa9={'ContactId':this[_0xa5c7('0x14')]['id'],'sentAt':moment()[_0xa5c7('0x15')]('YYYY-MM-DD\x20HH:mm:ss'),'direction':'out'};if(this[_0xa5c7('0x16')]===_0xa5c7('0x17')||this[_0xa5c7('0x16')]===_0xa5c7('0x18')){_0x3a5fa9['phone']=this['interaction'][_0xa5c7('0x19')];}var _0x5a8fae=this[_0xa5c7('0x16')];if(_0x5a8fae===_0xa5c7('0x1a')){_0x3a5fa9['ChatWebsiteId']=this['account']['id'];}else{_0x3a5fa9[_['upperFirst'](_0x5a8fae)+'AccountId']=this['account']['id'];}_0x3a5fa9[_[_0xa5c7('0x1b')](_0x5a8fae)+_0xa5c7('0x1c')]=this['interaction']['id'];if(this[_0xa5c7('0xe')]['created']){var _0x59aa63=_0x214e3f[0x2];if(!_['isEmpty'](_0x59aa63)){_0x3a5fa9[_0xa5c7('0x1d')]=utils['getMustacheRender'](_0x59aa63,this);return rpc[_0x5a8fae+_0xa5c7('0x1e')][_0xa5c7('0x1f')](_0x3a5fa9)[_0xa5c7('0x20')](function(_0x32963d){logger['info'](_0xa5c7('0x11'),_0x5e1940,_0x3a5fa9[_0xa5c7('0x1d')]);})[_0xa5c7('0x21')](function(_0x1b8784){logger[_0xa5c7('0x22')](_0xa5c7('0x11'),_0x5e1940,JSON[_0xa5c7('0x23')](_0x1b8784));})[_0xa5c7('0x24')](function(){logger[_0xa5c7('0x10')](_0xa5c7('0x25'),_0x5e1940);_0x5cc82f[_0xa5c7('0x26')]();});}else{logger[_0xa5c7('0x10')](_0xa5c7('0x27'),_0x5e1940);_0x5cc82f[_0xa5c7('0x26')]();}}else{var _0x18fca9=this;var _0x2815fa=apiai(_0x214e3f[0x0],{'language':_0x214e3f[0x1]||'en'});return _0x2815fa[_0xa5c7('0x28')](this[_0xa5c7('0x29')][_0xa5c7('0x1d')],{'sessionId':md5(this[_0xa5c7('0xe')]['id'])})[_0xa5c7('0x20')](function(_0x4defe0){_0x18fca9[_0xa5c7('0x1d')][_0xa5c7('0x2a')]=_0x4defe0;_0x3a5fa9['body']=_0x4defe0[_0xa5c7('0x2b')][_0xa5c7('0x2c')][_0xa5c7('0x2d')];_0x3a5fa9[_0xa5c7('0x2e')]=_0xa5c7('0x2a');_0x3a5fa9['providerResponse']=JSON[_0xa5c7('0x23')](_0x4defe0);return rpc[_0x5a8fae+'Message'][_0xa5c7('0x1f')](_0x3a5fa9)[_0xa5c7('0x20')](function(_0x27b26c){logger[_0xa5c7('0x10')](_0xa5c7('0x11'),_0x5e1940,_0x3a5fa9[_0xa5c7('0x1d')]);if(_0x4defe0[_0xa5c7('0x2b')][_0xa5c7('0x2f')][_0xa5c7('0x30')]){_0x5cc82f['next']();}else{_0x5cc82f['stop']();}})[_0xa5c7('0x21')](function(_0x5dbecd){logger[_0xa5c7('0x22')](_0xa5c7('0x11'),_0x5e1940,JSON[_0xa5c7('0x23')](_0x5dbecd));_0x5cc82f['next']();});})[_0xa5c7('0x21')](function(_0x545641){logger[_0xa5c7('0x22')]('[%s][DIALOGFLOW]\x20%s',_0x5e1940,_0x545641[_0xa5c7('0x29')]);_0x5cc82f['next']();});}}catch(_0x28de0f){logger[_0xa5c7('0x22')]('[%s][DIALOGFLOW]\x20%s',_0x5e1940,JSON[_0xa5c7('0x23')](_0x28de0f));_0x5cc82f[_0xa5c7('0x26')]();}};};
\ No newline at end of file