Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / services / routing / server / applications / dialogflow.js
index 481a0f8..e98f570 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x15b2=['result','fulfillment','speech','providerName','dialogflow','providerResponse','stringify','metadata','endConversation','error','moment','md5','./utils','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/faxMessage','consequence','isNil','interaction','info','[%s][DIALOGFLOW]\x20%s','next','YYYY-MM-DD\x20HH:mm:ss','channel','sms','whatsapp','phone','ChatWebsiteId','account','upperFirst','InteractionId','created','isEmpty','body','Message','create','then','catch','finally','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!','stop','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','message'];(function(_0x3663c7,_0x4a9c13){var _0x127c0e=function(_0x232f74){while(--_0x232f74){_0x3663c7['push'](_0x3663c7['shift']());}};_0x127c0e(++_0x4a9c13);}(_0x15b2,0x145));var _0x215b=function(_0x245ac5,_0x4215f1){_0x245ac5=_0x245ac5-0x0;var _0x437858=_0x15b2[_0x245ac5];return _0x437858;};'use strict';var _=require('lodash');var moment=require(_0x215b('0x0'));var apiai=require('apiai-promise');var md5=require(_0x215b('0x1'));var utils=require(_0x215b('0x2'));var logger=require('../../../../config/logger')(_0x215b('0x3'));var rpc={'chatMessage':require(_0x215b('0x4')),'openchannelMessage':require(_0x215b('0x5')),'mailMessage':require(_0x215b('0x6')),'smsMessage':require('../../rpc/smsMessage'),'faxMessage':require(_0x215b('0x7')),'whatsappMessage':require('../../rpc/whatsappMessage')};exports[_0x215b('0x8')]=function(_0x3a5a4b,_0x2d0018){return function(_0x1a8033){try{if(!_[_0x215b('0x9')](this[_0x215b('0xa')]['UserId'])){logger[_0x215b('0xb')](_0x215b('0xc'),_0x3a5a4b,'Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.');return _0x1a8033[_0x215b('0xd')]();}var _0x44bbd9={'ContactId':this['contact']['id'],'sentAt':moment()['format'](_0x215b('0xe')),'direction':'out'};if(this[_0x215b('0xf')]===_0x215b('0x10')||this['channel']===_0x215b('0x11')){_0x44bbd9['phone']=this['interaction'][_0x215b('0x12')];}var _0x52e5f1=this[_0x215b('0xf')];if(_0x52e5f1==='chat'){_0x44bbd9[_0x215b('0x13')]=this[_0x215b('0x14')]['id'];}else{_0x44bbd9[_[_0x215b('0x15')](_0x52e5f1)+'AccountId']=this['account']['id'];}_0x44bbd9[_['upperFirst'](_0x52e5f1)+_0x215b('0x16')]=this[_0x215b('0xa')]['id'];if(this[_0x215b('0xa')][_0x215b('0x17')]){var _0x35508e=_0x2d0018[0x2];if(!_[_0x215b('0x18')](_0x35508e)){_0x44bbd9[_0x215b('0x19')]=utils['getMustacheRender'](_0x35508e,this);return rpc[_0x52e5f1+_0x215b('0x1a')][_0x215b('0x1b')](_0x44bbd9)[_0x215b('0x1c')](function(_0x37248f){logger[_0x215b('0xb')](_0x215b('0xc'),_0x3a5a4b,_0x44bbd9[_0x215b('0x19')]);})[_0x215b('0x1d')](function(_0x4e1525){logger['error'](_0x215b('0xc'),_0x3a5a4b,JSON['stringify'](_0x4e1525));})[_0x215b('0x1e')](function(){logger[_0x215b('0xb')](_0x215b('0x1f'),_0x3a5a4b);_0x1a8033[_0x215b('0x20')]();});}else{logger[_0x215b('0xb')](_0x215b('0x21'),_0x3a5a4b);_0x1a8033[_0x215b('0x20')]();}}else{var _0x1a41c0=this;var _0x5cce5d=apiai(_0x2d0018[0x0],{'language':_0x2d0018[0x1]||'en'});return _0x5cce5d['textRequest'](this[_0x215b('0x22')]['body'],{'sessionId':md5(this[_0x215b('0xa')]['id'])})[_0x215b('0x1c')](function(_0x48568a){_0x1a41c0[_0x215b('0x19')]['dialogflow']=_0x48568a;_0x44bbd9[_0x215b('0x19')]=_0x48568a[_0x215b('0x23')][_0x215b('0x24')][_0x215b('0x25')];_0x44bbd9[_0x215b('0x26')]=_0x215b('0x27');_0x44bbd9[_0x215b('0x28')]=JSON[_0x215b('0x29')](_0x48568a);return rpc[_0x52e5f1+'Message'][_0x215b('0x1b')](_0x44bbd9)[_0x215b('0x1c')](function(_0x47d96d){logger[_0x215b('0xb')](_0x215b('0xc'),_0x3a5a4b,_0x44bbd9[_0x215b('0x19')]);if(_0x48568a['result'][_0x215b('0x2a')][_0x215b('0x2b')]){_0x1a8033[_0x215b('0xd')]();}else{_0x1a8033[_0x215b('0x20')]();}})[_0x215b('0x1d')](function(_0xca5e4a){logger['error'](_0x215b('0xc'),_0x3a5a4b,JSON[_0x215b('0x29')](_0xca5e4a));_0x1a8033[_0x215b('0xd')]();});})[_0x215b('0x1d')](function(_0x5eb42b){logger['error']('[%s][DIALOGFLOW]\x20%s',_0x3a5a4b,_0x5eb42b['message']);_0x1a8033['next']();});}}catch(_0xa14a89){logger[_0x215b('0x2c')](_0x215b('0xc'),_0x3a5a4b,JSON[_0x215b('0x29')](_0xa14a89));_0x1a8033['stop']();}};};
\ No newline at end of file
+var _0x5a4f=['info','[%s][DIALOGFLOW]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','format','YYYY-MM-DD\x20HH:mm:ss','out','channel','sms','phone','chat','ChatWebsiteId','upperFirst','AccountId','account','InteractionId','created','body','create','then','catch','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','dialogflow','fulfillment','providerName','providerResponse','result','endConversation','error','lodash','apiai-promise','./utils','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','isNil','interaction','UserId'];(function(_0x30c0af,_0x17a5b5){var _0x3314fa=function(_0x2dc9dd){while(--_0x2dc9dd){_0x30c0af['push'](_0x30c0af['shift']());}};_0x3314fa(++_0x17a5b5);}(_0x5a4f,0x10d));var _0xf5a4=function(_0xbd08b4,_0x4790ed){_0xbd08b4=_0xbd08b4-0x0;var _0x314f1e=_0x5a4f[_0xbd08b4];return _0x314f1e;};'use strict';var _=require(_0xf5a4('0x0'));var moment=require('moment');var apiai=require(_0xf5a4('0x1'));var md5=require('md5');var utils=require(_0xf5a4('0x2'));var logger=require('../../../../config/logger')(_0xf5a4('0x3'));var rpc={'chatMessage':require(_0xf5a4('0x4')),'openchannelMessage':require(_0xf5a4('0x5')),'mailMessage':require(_0xf5a4('0x6')),'smsMessage':require(_0xf5a4('0x7')),'faxMessage':require(_0xf5a4('0x8')),'whatsappMessage':require(_0xf5a4('0x9'))};exports['consequence']=function(_0x354c7d,_0xac1c57){return function(_0x3ef3da){try{if(!_[_0xf5a4('0xa')](this[_0xf5a4('0xb')][_0xf5a4('0xc')])){logger[_0xf5a4('0xd')](_0xf5a4('0xe'),_0x354c7d,_0xf5a4('0xf'));return _0x3ef3da[_0xf5a4('0x10')]();}var _0x3cdf31={'ContactId':this['contact']['id'],'sentAt':moment()[_0xf5a4('0x11')](_0xf5a4('0x12')),'direction':_0xf5a4('0x13')};if(this[_0xf5a4('0x14')]===_0xf5a4('0x15')||this[_0xf5a4('0x14')]==='whatsapp'){_0x3cdf31[_0xf5a4('0x16')]=this[_0xf5a4('0xb')][_0xf5a4('0x16')];}var _0x3bf5ec=this[_0xf5a4('0x14')];if(_0x3bf5ec===_0xf5a4('0x17')){_0x3cdf31[_0xf5a4('0x18')]=this['account']['id'];}else{_0x3cdf31[_[_0xf5a4('0x19')](_0x3bf5ec)+_0xf5a4('0x1a')]=this[_0xf5a4('0x1b')]['id'];}_0x3cdf31[_[_0xf5a4('0x19')](_0x3bf5ec)+_0xf5a4('0x1c')]=this[_0xf5a4('0xb')]['id'];if(this['interaction'][_0xf5a4('0x1d')]){var _0x14c8c3=_0xac1c57[0x2];if(!_['isEmpty'](_0x14c8c3)){_0x3cdf31[_0xf5a4('0x1e')]=utils['getMustacheRender'](_0x14c8c3,this);return rpc[_0x3bf5ec+'Message'][_0xf5a4('0x1f')](_0x3cdf31)[_0xf5a4('0x20')](function(_0x30d013){logger[_0xf5a4('0xd')](_0xf5a4('0xe'),_0x354c7d,_0x3cdf31[_0xf5a4('0x1e')]);})[_0xf5a4('0x21')](function(_0x357db0){logger['error'](_0xf5a4('0xe'),_0x354c7d,JSON[_0xf5a4('0x22')](_0x357db0));})['finally'](function(){logger['info'](_0xf5a4('0x23'),_0x354c7d);_0x3ef3da[_0xf5a4('0x24')]();});}else{logger[_0xf5a4('0xd')](_0xf5a4('0x25'),_0x354c7d);_0x3ef3da[_0xf5a4('0x24')]();}}else{var _0x5d577a=this;var _0x544d10=apiai(_0xac1c57[0x0],{'language':_0xac1c57[0x1]||'en'});return _0x544d10[_0xf5a4('0x26')](this[_0xf5a4('0x27')][_0xf5a4('0x1e')],{'sessionId':md5(this[_0xf5a4('0xb')]['id'])})[_0xf5a4('0x20')](function(_0x27ebae){_0x5d577a['body'][_0xf5a4('0x28')]=_0x27ebae;_0x3cdf31[_0xf5a4('0x1e')]=_0x27ebae['result'][_0xf5a4('0x29')]['speech'];_0x3cdf31[_0xf5a4('0x2a')]=_0xf5a4('0x28');_0x3cdf31[_0xf5a4('0x2b')]=JSON[_0xf5a4('0x22')](_0x27ebae);return rpc[_0x3bf5ec+'Message'][_0xf5a4('0x1f')](_0x3cdf31)[_0xf5a4('0x20')](function(_0x2f45a4){logger[_0xf5a4('0xd')](_0xf5a4('0xe'),_0x354c7d,_0x3cdf31[_0xf5a4('0x1e')]);if(_0x27ebae[_0xf5a4('0x2c')]['metadata'][_0xf5a4('0x2d')]){_0x3ef3da[_0xf5a4('0x10')]();}else{_0x3ef3da[_0xf5a4('0x24')]();}})[_0xf5a4('0x21')](function(_0x219aa6){logger['error'](_0xf5a4('0xe'),_0x354c7d,JSON[_0xf5a4('0x22')](_0x219aa6));_0x3ef3da[_0xf5a4('0x10')]();});})[_0xf5a4('0x21')](function(_0x43ebf2){logger[_0xf5a4('0x2e')](_0xf5a4('0xe'),_0x354c7d,_0x43ebf2[_0xf5a4('0x27')]);_0x3ef3da[_0xf5a4('0x10')]();});}}catch(_0x5a500a){logger['error'](_0xf5a4('0xe'),_0x354c7d,JSON[_0xf5a4('0x22')](_0x5a500a));_0x3ef3da[_0xf5a4('0x24')]();}};};
\ No newline at end of file