Built motion from commit 25580385.|2.6.2
[motion2.git] / server / services / routing / server / applications / dialogflow.js
index a99c030..20b7d86 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc14a=['isNil','UserId','info','[%s][DIALOGFLOW]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','format','YYYY-MM-DD\x20HH:mm:ss','sms','channel','phone','interaction','chat','ChatWebsiteId','account','InteractionId','created','isEmpty','body','Message','create','then','error','stringify','finally','stop','message','fulfillment','speech','dialogflow','providerResponse','metadata','endConversation','next','catch','lodash','moment','apiai-promise','md5','./utils','routing','../../rpc/chatMessage','../../rpc/mailMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','consequence'];(function(_0x4dfe9d,_0x1bbd61){var _0x2d8540=function(_0x434fc7){while(--_0x434fc7){_0x4dfe9d['push'](_0x4dfe9d['shift']());}};_0x2d8540(++_0x1bbd61);}(_0xc14a,0xa9));var _0xac14=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0xc14a[_0x3947c9];return _0x2e7871;};'use strict';var _=require(_0xac14('0x0'));var moment=require(_0xac14('0x1'));var apiai=require(_0xac14('0x2'));var md5=require(_0xac14('0x3'));var utils=require(_0xac14('0x4'));var logger=require('../../../../config/logger')(_0xac14('0x5'));var rpc={'chatMessage':require(_0xac14('0x6')),'openchannelMessage':require('../../rpc/openchannelMessage'),'mailMessage':require(_0xac14('0x7')),'smsMessage':require('../../rpc/smsMessage'),'faxMessage':require(_0xac14('0x8')),'whatsappMessage':require(_0xac14('0x9'))};exports[_0xac14('0xa')]=function(_0x59a627,_0x1fff1f){return function(_0x1783be){try{if(!_[_0xac14('0xb')](this['interaction'][_0xac14('0xc')])){logger[_0xac14('0xd')](_0xac14('0xe'),_0x59a627,_0xac14('0xf'));return _0x1783be['next']();}var _0x86118d={'ContactId':this['contact']['id'],'sentAt':moment()[_0xac14('0x10')](_0xac14('0x11')),'direction':'out'};if(this['channel']===_0xac14('0x12')||this[_0xac14('0x13')]==='whatsapp'){_0x86118d[_0xac14('0x14')]=this[_0xac14('0x15')]['phone'];}var _0x5dc164=this['channel'];if(_0x5dc164===_0xac14('0x16')){_0x86118d[_0xac14('0x17')]=this[_0xac14('0x18')]['id'];}else{_0x86118d[_['upperFirst'](_0x5dc164)+'AccountId']=this[_0xac14('0x18')]['id'];}_0x86118d[_['upperFirst'](_0x5dc164)+_0xac14('0x19')]=this['interaction']['id'];if(this[_0xac14('0x15')][_0xac14('0x1a')]){var _0x1023e2=_0x1fff1f[0x2];if(!_[_0xac14('0x1b')](_0x1023e2)){_0x86118d[_0xac14('0x1c')]=utils['getMustacheRender'](_0x1023e2,this);return rpc[_0x5dc164+_0xac14('0x1d')][_0xac14('0x1e')](_0x86118d)[_0xac14('0x1f')](function(_0x1682b1){logger[_0xac14('0xd')](_0xac14('0xe'),_0x59a627,_0x86118d[_0xac14('0x1c')]);})['catch'](function(_0x429390){logger[_0xac14('0x20')](_0xac14('0xe'),_0x59a627,JSON[_0xac14('0x21')](_0x429390));})[_0xac14('0x22')](function(){logger['info']('[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!',_0x59a627);_0x1783be[_0xac14('0x23')]();});}else{logger[_0xac14('0xd')]('[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!',_0x59a627);_0x1783be[_0xac14('0x23')]();}}else{var _0x492f37=this;var _0x528406=apiai(_0x1fff1f[0x0],{'language':_0x1fff1f[0x1]||'en'});return _0x528406['textRequest'](this[_0xac14('0x24')]['body'],{'sessionId':md5(this[_0xac14('0x15')]['id'])})[_0xac14('0x1f')](function(_0x272b46){_0x492f37[_0xac14('0x1c')]['dialogflow']=_0x272b46;_0x86118d[_0xac14('0x1c')]=_0x272b46['result'][_0xac14('0x25')][_0xac14('0x26')];_0x86118d['providerName']=_0xac14('0x27');_0x86118d[_0xac14('0x28')]=JSON[_0xac14('0x21')](_0x272b46);return rpc[_0x5dc164+_0xac14('0x1d')][_0xac14('0x1e')](_0x86118d)[_0xac14('0x1f')](function(_0x5d033d){logger[_0xac14('0xd')]('[%s][DIALOGFLOW]\x20%s',_0x59a627,_0x86118d['body']);if(_0x272b46['result'][_0xac14('0x29')][_0xac14('0x2a')]){_0x1783be[_0xac14('0x2b')]();}else{_0x1783be['stop']();}})['catch'](function(_0x506837){logger['error']('[%s][DIALOGFLOW]\x20%s',_0x59a627,JSON[_0xac14('0x21')](_0x506837));_0x1783be[_0xac14('0x2b')]();});})[_0xac14('0x2c')](function(_0x464ae9){logger[_0xac14('0x20')]('[%s][DIALOGFLOW]\x20%s',_0x59a627,_0x464ae9[_0xac14('0x24')]);_0x1783be['next']();});}}catch(_0x30dc81){logger[_0xac14('0x20')](_0xac14('0xe'),_0x59a627,JSON[_0xac14('0x21')](_0x30dc81));_0x1783be['stop']();}};};
\ No newline at end of file
+var _0xe928=['info','[%s][DIALOGFLOW]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','contact','YYYY-MM-DD\x20HH:mm:ss','out','channel','whatsapp','phone','ChatWebsiteId','upperFirst','AccountId','created','isEmpty','body','getMustacheRender','Message','then','error','stop','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','dialogflow','result','speech','providerName','providerResponse','stringify','metadata','catch','message','lodash','moment','apiai-promise','./utils','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/faxMessage','consequence','interaction'];(function(_0x4bc112,_0x812afe){var _0x43a4cc=function(_0x31787f){while(--_0x31787f){_0x4bc112['push'](_0x4bc112['shift']());}};_0x43a4cc(++_0x812afe);}(_0xe928,0x145));var _0x8e92=function(_0x17f515,_0x26e47f){_0x17f515=_0x17f515-0x0;var _0x5ea54b=_0xe928[_0x17f515];return _0x5ea54b;};'use strict';var _=require(_0x8e92('0x0'));var moment=require(_0x8e92('0x1'));var apiai=require(_0x8e92('0x2'));var md5=require('md5');var utils=require(_0x8e92('0x3'));var logger=require('../../../../config/logger')(_0x8e92('0x4'));var rpc={'chatMessage':require(_0x8e92('0x5')),'openchannelMessage':require(_0x8e92('0x6')),'mailMessage':require(_0x8e92('0x7')),'smsMessage':require('../../rpc/smsMessage'),'faxMessage':require(_0x8e92('0x8')),'whatsappMessage':require('../../rpc/whatsappMessage')};exports[_0x8e92('0x9')]=function(_0xe4eff3,_0x14811b){return function(_0x76e11){try{if(!_['isNil'](this[_0x8e92('0xa')]['UserId'])){logger[_0x8e92('0xb')](_0x8e92('0xc'),_0xe4eff3,_0x8e92('0xd'));return _0x76e11[_0x8e92('0xe')]();}var _0x45c1a4={'ContactId':this[_0x8e92('0xf')]['id'],'sentAt':moment()['format'](_0x8e92('0x10')),'direction':_0x8e92('0x11')};if(this[_0x8e92('0x12')]==='sms'||this[_0x8e92('0x12')]===_0x8e92('0x13')){_0x45c1a4[_0x8e92('0x14')]=this[_0x8e92('0xa')][_0x8e92('0x14')];}var _0x2fe37b=this[_0x8e92('0x12')];if(_0x2fe37b==='chat'){_0x45c1a4[_0x8e92('0x15')]=this['account']['id'];}else{_0x45c1a4[_[_0x8e92('0x16')](_0x2fe37b)+_0x8e92('0x17')]=this['account']['id'];}_0x45c1a4[_[_0x8e92('0x16')](_0x2fe37b)+'InteractionId']=this[_0x8e92('0xa')]['id'];if(this[_0x8e92('0xa')][_0x8e92('0x18')]){var _0x1380ef=_0x14811b[0x2];if(!_[_0x8e92('0x19')](_0x1380ef)){_0x45c1a4[_0x8e92('0x1a')]=utils[_0x8e92('0x1b')](_0x1380ef,this);return rpc[_0x2fe37b+_0x8e92('0x1c')]['create'](_0x45c1a4)[_0x8e92('0x1d')](function(_0x192b0b){logger[_0x8e92('0xb')](_0x8e92('0xc'),_0xe4eff3,_0x45c1a4[_0x8e92('0x1a')]);})['catch'](function(_0x261b07){logger[_0x8e92('0x1e')]('[%s][DIALOGFLOW]\x20%s',_0xe4eff3,JSON['stringify'](_0x261b07));})['finally'](function(){logger[_0x8e92('0xb')]('[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!',_0xe4eff3);_0x76e11[_0x8e92('0x1f')]();});}else{logger[_0x8e92('0xb')](_0x8e92('0x20'),_0xe4eff3);_0x76e11[_0x8e92('0x1f')]();}}else{var _0x368253=this;var _0x70f846=apiai(_0x14811b[0x0],{'language':_0x14811b[0x1]||'en'});return _0x70f846['textRequest'](this['message']['body'],{'sessionId':md5(this['interaction']['id'])})[_0x8e92('0x1d')](function(_0x3a86e4){_0x368253[_0x8e92('0x1a')][_0x8e92('0x21')]=_0x3a86e4;_0x45c1a4[_0x8e92('0x1a')]=_0x3a86e4[_0x8e92('0x22')]['fulfillment'][_0x8e92('0x23')];_0x45c1a4[_0x8e92('0x24')]=_0x8e92('0x21');_0x45c1a4[_0x8e92('0x25')]=JSON[_0x8e92('0x26')](_0x3a86e4);return rpc[_0x2fe37b+_0x8e92('0x1c')]['create'](_0x45c1a4)['then'](function(_0x510349){logger[_0x8e92('0xb')]('[%s][DIALOGFLOW]\x20%s',_0xe4eff3,_0x45c1a4[_0x8e92('0x1a')]);if(_0x3a86e4['result'][_0x8e92('0x27')]['endConversation']){_0x76e11[_0x8e92('0xe')]();}else{_0x76e11[_0x8e92('0x1f')]();}})[_0x8e92('0x28')](function(_0x3c8897){logger[_0x8e92('0x1e')](_0x8e92('0xc'),_0xe4eff3,JSON['stringify'](_0x3c8897));_0x76e11[_0x8e92('0xe')]();});})[_0x8e92('0x28')](function(_0x4c11ef){logger[_0x8e92('0x1e')]('[%s][DIALOGFLOW]\x20%s',_0xe4eff3,_0x4c11ef[_0x8e92('0x29')]);_0x76e11[_0x8e92('0xe')]();});}}catch(_0x4fb57b){logger[_0x8e92('0x1e')](_0x8e92('0xc'),_0xe4eff3,JSON[_0x8e92('0x26')](_0x4fb57b));_0x76e11[_0x8e92('0x1f')]();}};};
\ No newline at end of file