Built motion from commit 42801a18.|2.6.28
[motion2.git] / server / services / routing / server / applications / dialogflow.js
index 1daa485..f2e8aad 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4312=['isNil','interaction','UserId','[%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','chat','ChatWebsiteId','account','upperFirst','AccountId','created','isEmpty','body','getMustacheRender','Message','create','then','info','error','stringify','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!','textRequest','message','dialogflow','result','fulfillment','speech','metadata','stop','catch','apiai-promise','md5','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/whatsappMessage'];(function(_0x50e51f,_0x4064ff){var _0x1bd707=function(_0x5f39e9){while(--_0x5f39e9){_0x50e51f['push'](_0x50e51f['shift']());}};_0x1bd707(++_0x4064ff);}(_0x4312,0xaf));var _0x2431=function(_0x3d91fd,_0x3a768b){_0x3d91fd=_0x3d91fd-0x0;var _0x137a3a=_0x4312[_0x3d91fd];return _0x137a3a;};'use strict';var _=require('lodash');var moment=require('moment');var apiai=require(_0x2431('0x0'));var md5=require(_0x2431('0x1'));var utils=require('./utils');var logger=require(_0x2431('0x2'))(_0x2431('0x3'));var rpc={'chatMessage':require(_0x2431('0x4')),'openchannelMessage':require(_0x2431('0x5')),'mailMessage':require(_0x2431('0x6')),'smsMessage':require(_0x2431('0x7')),'faxMessage':require('../../rpc/faxMessage'),'whatsappMessage':require(_0x2431('0x8'))};exports['consequence']=function(_0xa2cabe,_0x147562){return function(_0x4e2eb2){try{if(!_[_0x2431('0x9')](this[_0x2431('0xa')][_0x2431('0xb')])){logger['info'](_0x2431('0xc'),_0xa2cabe,_0x2431('0xd'));return _0x4e2eb2[_0x2431('0xe')]();}var _0x568a96={'ContactId':this[_0x2431('0xf')]['id'],'sentAt':moment()['format'](_0x2431('0x10')),'direction':_0x2431('0x11')};if(this[_0x2431('0x12')]==='sms'||this[_0x2431('0x12')]===_0x2431('0x13')){_0x568a96[_0x2431('0x14')]=this[_0x2431('0xa')]['phone'];}var _0x4691cd=this[_0x2431('0x12')];if(_0x4691cd===_0x2431('0x15')){_0x568a96[_0x2431('0x16')]=this[_0x2431('0x17')]['id'];}else{_0x568a96[_[_0x2431('0x18')](_0x4691cd)+_0x2431('0x19')]=this[_0x2431('0x17')]['id'];}_0x568a96[_[_0x2431('0x18')](_0x4691cd)+'InteractionId']=this[_0x2431('0xa')]['id'];if(this[_0x2431('0xa')][_0x2431('0x1a')]){var _0x30f370=_0x147562[0x2];if(!_[_0x2431('0x1b')](_0x30f370)){_0x568a96[_0x2431('0x1c')]=utils[_0x2431('0x1d')](_0x30f370,this);return rpc[_0x4691cd+_0x2431('0x1e')][_0x2431('0x1f')](_0x568a96)[_0x2431('0x20')](function(_0x3521a8){logger[_0x2431('0x21')](_0x2431('0xc'),_0xa2cabe,_0x568a96[_0x2431('0x1c')]);})['catch'](function(_0x5eca20){logger[_0x2431('0x22')](_0x2431('0xc'),_0xa2cabe,JSON[_0x2431('0x23')](_0x5eca20));})['finally'](function(){logger[_0x2431('0x21')](_0x2431('0x24'),_0xa2cabe);_0x4e2eb2['stop']();});}else{logger['info']('[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!',_0xa2cabe);_0x4e2eb2['stop']();}}else{var _0x13860f=this;var _0x4199cf=apiai(_0x147562[0x0],{'language':_0x147562[0x1]||'en'});return _0x4199cf[_0x2431('0x25')](this[_0x2431('0x26')]['body'],{'sessionId':md5(this[_0x2431('0xa')]['id'])})['then'](function(_0x296c49){_0x13860f[_0x2431('0x1c')][_0x2431('0x27')]=_0x296c49;_0x568a96['body']=_0x296c49[_0x2431('0x28')][_0x2431('0x29')][_0x2431('0x2a')];_0x568a96['providerName']='dialogflow';_0x568a96['providerResponse']=JSON[_0x2431('0x23')](_0x296c49);return rpc[_0x4691cd+'Message'][_0x2431('0x1f')](_0x568a96)[_0x2431('0x20')](function(_0x35c847){logger[_0x2431('0x21')]('[%s][DIALOGFLOW]\x20%s',_0xa2cabe,_0x568a96['body']);if(_0x296c49[_0x2431('0x28')][_0x2431('0x2b')]['endConversation']){_0x4e2eb2[_0x2431('0xe')]();}else{_0x4e2eb2[_0x2431('0x2c')]();}})['catch'](function(_0x27520c){logger[_0x2431('0x22')]('[%s][DIALOGFLOW]\x20%s',_0xa2cabe,JSON[_0x2431('0x23')](_0x27520c));_0x4e2eb2[_0x2431('0xe')]();});})[_0x2431('0x2d')](function(_0x141478){logger[_0x2431('0x22')](_0x2431('0xc'),_0xa2cabe,_0x141478[_0x2431('0x26')]);_0x4e2eb2[_0x2431('0xe')]();});}}catch(_0x2bd7e8){logger[_0x2431('0x22')](_0x2431('0xc'),_0xa2cabe,JSON[_0x2431('0x23')](_0x2bd7e8));_0x4e2eb2[_0x2431('0x2c')]();}};};
\ No newline at end of file
+var _0xafc4=['[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','textRequest','dialogflow','result','fulfillment','speech','providerName','providerResponse','stringify','metadata','endConversation','lodash','apiai-promise','./utils','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','consequence','interaction','UserId','info','[%s][DIALOGFLOW]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','format','out','channel','whatsapp','phone','chat','account','upperFirst','AccountId','created','isEmpty','body','getMustacheRender','Message','create','then','catch','error','finally','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!','stop'];(function(_0xd5528c,_0x403650){var _0x29a585=function(_0x588103){while(--_0x588103){_0xd5528c['push'](_0xd5528c['shift']());}};_0x29a585(++_0x403650);}(_0xafc4,0x69));var _0x4afc=function(_0x187f9c,_0x42964d){_0x187f9c=_0x187f9c-0x0;var _0xad1bbd=_0xafc4[_0x187f9c];return _0xad1bbd;};'use strict';var _=require(_0x4afc('0x0'));var moment=require('moment');var apiai=require(_0x4afc('0x1'));var md5=require('md5');var utils=require(_0x4afc('0x2'));var logger=require(_0x4afc('0x3'))(_0x4afc('0x4'));var rpc={'chatMessage':require(_0x4afc('0x5')),'openchannelMessage':require('../../rpc/openchannelMessage'),'mailMessage':require('../../rpc/mailMessage'),'smsMessage':require('../../rpc/smsMessage'),'faxMessage':require(_0x4afc('0x6')),'whatsappMessage':require(_0x4afc('0x7'))};exports[_0x4afc('0x8')]=function(_0x1bb281,_0xc828d9){return function(_0xaf053d){try{if(!_['isNil'](this[_0x4afc('0x9')][_0x4afc('0xa')])){logger[_0x4afc('0xb')](_0x4afc('0xc'),_0x1bb281,_0x4afc('0xd'));return _0xaf053d[_0x4afc('0xe')]();}var _0x5542ec={'ContactId':this['contact']['id'],'sentAt':moment()[_0x4afc('0xf')]('YYYY-MM-DD\x20HH:mm:ss'),'direction':_0x4afc('0x10')};if(this[_0x4afc('0x11')]==='sms'||this[_0x4afc('0x11')]===_0x4afc('0x12')){_0x5542ec[_0x4afc('0x13')]=this[_0x4afc('0x9')][_0x4afc('0x13')];}var _0x2f1c59=this[_0x4afc('0x11')];if(_0x2f1c59===_0x4afc('0x14')){_0x5542ec['ChatWebsiteId']=this[_0x4afc('0x15')]['id'];}else{_0x5542ec[_[_0x4afc('0x16')](_0x2f1c59)+_0x4afc('0x17')]=this[_0x4afc('0x15')]['id'];}_0x5542ec[_['upperFirst'](_0x2f1c59)+'InteractionId']=this[_0x4afc('0x9')]['id'];if(this['interaction'][_0x4afc('0x18')]){var _0x24ed6d=_0xc828d9[0x2];if(!_[_0x4afc('0x19')](_0x24ed6d)){_0x5542ec[_0x4afc('0x1a')]=utils[_0x4afc('0x1b')](_0x24ed6d,this);return rpc[_0x2f1c59+_0x4afc('0x1c')][_0x4afc('0x1d')](_0x5542ec)[_0x4afc('0x1e')](function(_0x16365f){logger[_0x4afc('0xb')](_0x4afc('0xc'),_0x1bb281,_0x5542ec['body']);})[_0x4afc('0x1f')](function(_0x25603b){logger[_0x4afc('0x20')](_0x4afc('0xc'),_0x1bb281,JSON['stringify'](_0x25603b));})[_0x4afc('0x21')](function(){logger[_0x4afc('0xb')](_0x4afc('0x22'),_0x1bb281);_0xaf053d[_0x4afc('0x23')]();});}else{logger[_0x4afc('0xb')](_0x4afc('0x24'),_0x1bb281);_0xaf053d[_0x4afc('0x23')]();}}else{var _0x573a75=this;var _0x5403e4=apiai(_0xc828d9[0x0],{'language':_0xc828d9[0x1]||'en'});return _0x5403e4[_0x4afc('0x25')](this['message'][_0x4afc('0x1a')],{'sessionId':md5(this['interaction']['id'])})[_0x4afc('0x1e')](function(_0x2a0314){_0x573a75[_0x4afc('0x1a')][_0x4afc('0x26')]=_0x2a0314;_0x5542ec[_0x4afc('0x1a')]=_0x2a0314[_0x4afc('0x27')][_0x4afc('0x28')][_0x4afc('0x29')];_0x5542ec[_0x4afc('0x2a')]=_0x4afc('0x26');_0x5542ec[_0x4afc('0x2b')]=JSON[_0x4afc('0x2c')](_0x2a0314);return rpc[_0x2f1c59+_0x4afc('0x1c')]['create'](_0x5542ec)[_0x4afc('0x1e')](function(_0x244f6c){logger[_0x4afc('0xb')]('[%s][DIALOGFLOW]\x20%s',_0x1bb281,_0x5542ec['body']);if(_0x2a0314['result'][_0x4afc('0x2d')][_0x4afc('0x2e')]){_0xaf053d['next']();}else{_0xaf053d[_0x4afc('0x23')]();}})[_0x4afc('0x1f')](function(_0x494fe7){logger['error']('[%s][DIALOGFLOW]\x20%s',_0x1bb281,JSON[_0x4afc('0x2c')](_0x494fe7));_0xaf053d[_0x4afc('0xe')]();});})[_0x4afc('0x1f')](function(_0x46357b){logger[_0x4afc('0x20')](_0x4afc('0xc'),_0x1bb281,_0x46357b['message']);_0xaf053d[_0x4afc('0xe')]();});}}catch(_0x3d1693){logger[_0x4afc('0x20')](_0x4afc('0xc'),_0x1bb281,JSON[_0x4afc('0x2c')](_0x3d1693));_0xaf053d[_0x4afc('0x23')]();}};};
\ No newline at end of file