Built motion from commit (unavailable).|2.5.5
[motion2.git] / server / services / routing / server / applications / dialogflow.js
index 1065e02..97472df 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbb3d=['moment','md5','./utils','../../../../config/logger','routing','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','consequence','interaction','UserId','info','[%s][DIALOGFLOW]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','format','out','channel','account','upperFirst','InteractionId','created','body','create','error','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!','stop','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','textRequest','then','result','fulfillment','speech','metadata','catch','stringify','message','lodash'];(function(_0x444cd2,_0xd8a7fd){var _0x1cc07f=function(_0x3487dd){while(--_0x3487dd){_0x444cd2['push'](_0x444cd2['shift']());}};_0x1cc07f(++_0xd8a7fd);}(_0xbb3d,0x71));var _0xdbb3=function(_0x1f75d4,_0x183581){_0x1f75d4=_0x1f75d4-0x0;var _0x72f2ca=_0xbb3d[_0x1f75d4];return _0x72f2ca;};'use strict';var _=require(_0xdbb3('0x0'));var moment=require(_0xdbb3('0x1'));var apiai=require('apiai-promise');var md5=require(_0xdbb3('0x2'));var utils=require(_0xdbb3('0x3'));var logger=require(_0xdbb3('0x4'))(_0xdbb3('0x5'));var rpc={'chatMessage':require('../../rpc/chatMessage'),'openchannelMessage':require(_0xdbb3('0x6')),'mailMessage':require(_0xdbb3('0x7')),'smsMessage':require(_0xdbb3('0x8')),'faxMessage':require('../../rpc/faxMessage')};exports[_0xdbb3('0x9')]=function(_0x1de197,_0xaa486c){return function(_0x21a0fc){try{if(!_['isNil'](this[_0xdbb3('0xa')][_0xdbb3('0xb')])){logger[_0xdbb3('0xc')](_0xdbb3('0xd'),_0x1de197,_0xdbb3('0xe'));return _0x21a0fc[_0xdbb3('0xf')]();}var _0x43bc68={'ContactId':this['contact']['id'],'sentAt':moment()[_0xdbb3('0x10')]('YYYY-MM-DD\x20HH:mm:ss'),'direction':_0xdbb3('0x11')};var _0x34a4d2=this[_0xdbb3('0x12')];if(_0x34a4d2==='chat'){_0x43bc68['ChatWebsiteId']=this['account']['id'];}else{_0x43bc68[_['upperFirst'](_0x34a4d2)+'AccountId']=this[_0xdbb3('0x13')]['id'];}_0x43bc68[_[_0xdbb3('0x14')](_0x34a4d2)+_0xdbb3('0x15')]=this[_0xdbb3('0xa')]['id'];if(this[_0xdbb3('0xa')][_0xdbb3('0x16')]){var _0x16a2a3=_0xaa486c[0x2];if(!_['isEmpty'](_0x16a2a3)){_0x43bc68[_0xdbb3('0x17')]=utils['getMustacheRender'](_0x16a2a3,this);return rpc[_0x34a4d2+'Message'][_0xdbb3('0x18')](_0x43bc68)['then'](function(_0x2b5243){logger[_0xdbb3('0xc')](_0xdbb3('0xd'),_0x1de197,_0x43bc68['body']);})['catch'](function(_0x2ee9a3){logger[_0xdbb3('0x19')]('[%s][DIALOGFLOW]\x20%s',_0x1de197,JSON['stringify'](_0x2ee9a3));})['finally'](function(){logger[_0xdbb3('0xc')](_0xdbb3('0x1a'),_0x1de197);_0x21a0fc[_0xdbb3('0x1b')]();});}else{logger[_0xdbb3('0xc')](_0xdbb3('0x1c'),_0x1de197);_0x21a0fc['stop']();}}else{var _0x11c9ba=this;var _0x4847=apiai(_0xaa486c[0x0],{'language':_0xaa486c[0x1]||'en'});return _0x4847[_0xdbb3('0x1d')](this['message']['body'],{'sessionId':md5(this[_0xdbb3('0xa')]['id'])})[_0xdbb3('0x1e')](function(_0x32126a){_0x11c9ba[_0xdbb3('0x17')]['dialogflow']=_0x32126a;_0x43bc68['body']=_0x32126a[_0xdbb3('0x1f')][_0xdbb3('0x20')][_0xdbb3('0x21')];return rpc[_0x34a4d2+'Message']['create'](_0x43bc68)[_0xdbb3('0x1e')](function(_0x17b5ed){logger[_0xdbb3('0xc')](_0xdbb3('0xd'),_0x1de197,_0x43bc68[_0xdbb3('0x17')]);if(_0x32126a[_0xdbb3('0x1f')][_0xdbb3('0x22')]['endConversation']){_0x21a0fc[_0xdbb3('0xf')]();}else{_0x21a0fc[_0xdbb3('0x1b')]();}})[_0xdbb3('0x23')](function(_0x28a7fd){logger['error'](_0xdbb3('0xd'),_0x1de197,JSON[_0xdbb3('0x24')](_0x28a7fd));_0x21a0fc['next']();});})[_0xdbb3('0x23')](function(_0x4e91ca){logger['error'](_0xdbb3('0xd'),_0x1de197,_0x4e91ca[_0xdbb3('0x25')]);_0x21a0fc[_0xdbb3('0xf')]();});}}catch(_0x314d88){logger[_0xdbb3('0x19')]('[%s][DIALOGFLOW]\x20%s',_0x1de197,JSON[_0xdbb3('0x24')](_0x314d88));_0x21a0fc[_0xdbb3('0x1b')]();}};};
\ No newline at end of file
+var _0x3ff4=['stop','textRequest','message','dialogflow','fulfillment','speech','result','metadata','endConversation','stringify','lodash','moment','apiai-promise','./utils','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','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','chat','account','upperFirst','AccountId','InteractionId','interaction','created','body','getMustacheRender','Message','create','then','catch','error','finally'];(function(_0x1d6dea,_0x1f8978){var _0x1b5967=function(_0x4a95f6){while(--_0x4a95f6){_0x1d6dea['push'](_0x1d6dea['shift']());}};_0x1b5967(++_0x1f8978);}(_0x3ff4,0x1ba));var _0x43ff=function(_0x36eaaa,_0x326732){_0x36eaaa=_0x36eaaa-0x0;var _0x461349=_0x3ff4[_0x36eaaa];return _0x461349;};'use strict';var _=require(_0x43ff('0x0'));var moment=require(_0x43ff('0x1'));var apiai=require(_0x43ff('0x2'));var md5=require('md5');var utils=require(_0x43ff('0x3'));var logger=require(_0x43ff('0x4'))(_0x43ff('0x5'));var rpc={'chatMessage':require(_0x43ff('0x6')),'openchannelMessage':require(_0x43ff('0x7')),'mailMessage':require(_0x43ff('0x8')),'smsMessage':require(_0x43ff('0x9')),'faxMessage':require(_0x43ff('0xa')),'whatsappMessage':require(_0x43ff('0xb'))};exports['consequence']=function(_0x5727f3,_0x5f48f9){return function(_0x389b9c){try{if(!_[_0x43ff('0xc')](this['interaction'][_0x43ff('0xd')])){logger[_0x43ff('0xe')](_0x43ff('0xf'),_0x5727f3,_0x43ff('0x10'));return _0x389b9c[_0x43ff('0x11')]();}var _0x326fc2={'ContactId':this[_0x43ff('0x12')]['id'],'sentAt':moment()[_0x43ff('0x13')](_0x43ff('0x14')),'direction':_0x43ff('0x15')};var _0xcfaf02=this[_0x43ff('0x16')];if(_0xcfaf02===_0x43ff('0x17')){_0x326fc2['ChatWebsiteId']=this[_0x43ff('0x18')]['id'];}else{_0x326fc2[_[_0x43ff('0x19')](_0xcfaf02)+_0x43ff('0x1a')]=this['account']['id'];}_0x326fc2[_[_0x43ff('0x19')](_0xcfaf02)+_0x43ff('0x1b')]=this[_0x43ff('0x1c')]['id'];if(this[_0x43ff('0x1c')][_0x43ff('0x1d')]){var _0x383500=_0x5f48f9[0x2];if(!_['isEmpty'](_0x383500)){_0x326fc2[_0x43ff('0x1e')]=utils[_0x43ff('0x1f')](_0x383500,this);return rpc[_0xcfaf02+_0x43ff('0x20')][_0x43ff('0x21')](_0x326fc2)[_0x43ff('0x22')](function(_0x505997){logger[_0x43ff('0xe')](_0x43ff('0xf'),_0x5727f3,_0x326fc2[_0x43ff('0x1e')]);})[_0x43ff('0x23')](function(_0x4b85eb){logger[_0x43ff('0x24')]('[%s][DIALOGFLOW]\x20%s',_0x5727f3,JSON['stringify'](_0x4b85eb));})[_0x43ff('0x25')](function(){logger[_0x43ff('0xe')]('[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!',_0x5727f3);_0x389b9c[_0x43ff('0x26')]();});}else{logger[_0x43ff('0xe')]('[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!',_0x5727f3);_0x389b9c[_0x43ff('0x26')]();}}else{var _0x3ecf33=this;var _0x686447=apiai(_0x5f48f9[0x0],{'language':_0x5f48f9[0x1]||'en'});return _0x686447[_0x43ff('0x27')](this[_0x43ff('0x28')]['body'],{'sessionId':md5(this[_0x43ff('0x1c')]['id'])})[_0x43ff('0x22')](function(_0x572bf1){_0x3ecf33['body'][_0x43ff('0x29')]=_0x572bf1;_0x326fc2['body']=_0x572bf1['result'][_0x43ff('0x2a')][_0x43ff('0x2b')];return rpc[_0xcfaf02+_0x43ff('0x20')][_0x43ff('0x21')](_0x326fc2)[_0x43ff('0x22')](function(_0x5d5179){logger[_0x43ff('0xe')](_0x43ff('0xf'),_0x5727f3,_0x326fc2[_0x43ff('0x1e')]);if(_0x572bf1[_0x43ff('0x2c')][_0x43ff('0x2d')][_0x43ff('0x2e')]){_0x389b9c[_0x43ff('0x11')]();}else{_0x389b9c[_0x43ff('0x26')]();}})['catch'](function(_0x38f1aa){logger['error'](_0x43ff('0xf'),_0x5727f3,JSON[_0x43ff('0x2f')](_0x38f1aa));_0x389b9c['next']();});})[_0x43ff('0x23')](function(_0x22347f){logger[_0x43ff('0x24')](_0x43ff('0xf'),_0x5727f3,_0x22347f[_0x43ff('0x28')]);_0x389b9c[_0x43ff('0x11')]();});}}catch(_0x31545e){logger[_0x43ff('0x24')](_0x43ff('0xf'),_0x5727f3,JSON['stringify'](_0x31545e));_0x389b9c[_0x43ff('0x26')]();}};};
\ No newline at end of file