Built motion from commit 936e8062.|2.5.33
[motion2.git] / server / services / routing / server / applications / amazonlex.js
index 92db82a..255e7a3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x818f=['routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','consequence','isNil','interaction','UserId','info','[%s][AMAZONLEX]\x20%s','next','format','YYYY-MM-DD\x20HH:mm:ss','out','sms','channel','whatsapp','phone','chat','ChatWebsiteId','account','upperFirst','AccountId','InteractionId','created','body','Message','create','then','catch','stringify','finally','[%s][AMAZONLEX]\x20Welcome\x20Message\x20has\x20been\x20sent!','stop','[%s][AMAZONLEX]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','$LATEST','message','toString','error','providerName','amazonlex','providerResponse','dialogState','Failed','lodash','moment','aws-sdk','./utils','../../../../config/logger'];(function(_0x2af023,_0x382835){var _0x2b8a8a=function(_0x19d656){while(--_0x19d656){_0x2af023['push'](_0x2af023['shift']());}};_0x2b8a8a(++_0x382835);}(_0x818f,0x19b));var _0xf818=function(_0x5ab11d,_0x136cba){_0x5ab11d=_0x5ab11d-0x0;var _0x283078=_0x818f[_0x5ab11d];return _0x283078;};'use strict';var _=require(_0xf818('0x0'));var moment=require(_0xf818('0x1'));var AWS=require(_0xf818('0x2'));var utils=require(_0xf818('0x3'));var logger=require(_0xf818('0x4'))(_0xf818('0x5'));var rpc={'chatMessage':require(_0xf818('0x6')),'openchannelMessage':require(_0xf818('0x7')),'mailMessage':require(_0xf818('0x8')),'smsMessage':require(_0xf818('0x9')),'faxMessage':require(_0xf818('0xa')),'whatsappMessage':require(_0xf818('0xb'))};exports[_0xf818('0xc')]=function(_0x3a537a,_0x4e9817){return function(_0x2aaf5e){try{if(!_[_0xf818('0xd')](this[_0xf818('0xe')][_0xf818('0xf')])){logger[_0xf818('0x10')](_0xf818('0x11'),_0x3a537a,'Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.');return _0x2aaf5e[_0xf818('0x12')]();}var _0x10b599={'ContactId':this['contact']['id'],'sentAt':moment()[_0xf818('0x13')](_0xf818('0x14')),'direction':_0xf818('0x15')};if(this['channel']===_0xf818('0x16')||this[_0xf818('0x17')]===_0xf818('0x18')){_0x10b599[_0xf818('0x19')]=this[_0xf818('0xe')][_0xf818('0x19')];}var _0x1e2885=this[_0xf818('0x17')];if(_0x1e2885===_0xf818('0x1a')){_0x10b599[_0xf818('0x1b')]=this[_0xf818('0x1c')]['id'];}else{_0x10b599[_[_0xf818('0x1d')](_0x1e2885)+_0xf818('0x1e')]=this[_0xf818('0x1c')]['id'];}_0x10b599[_[_0xf818('0x1d')](_0x1e2885)+_0xf818('0x1f')]=this[_0xf818('0xe')]['id'];if(this[_0xf818('0xe')][_0xf818('0x20')]){var _0x22075c=_0x4e9817[0x4];if(!_['isEmpty'](_0x22075c)){_0x10b599[_0xf818('0x21')]=utils['getMustacheRender'](_0x22075c,this);return rpc[_0x1e2885+_0xf818('0x22')][_0xf818('0x23')](_0x10b599)[_0xf818('0x24')](function(_0x418857){logger[_0xf818('0x10')](_0xf818('0x11'),_0x3a537a,_0x10b599['body']);})[_0xf818('0x25')](function(_0x27f599){logger['error'](_0xf818('0x11'),_0x3a537a,JSON[_0xf818('0x26')](_0x27f599));})[_0xf818('0x27')](function(){logger[_0xf818('0x10')](_0xf818('0x28'),_0x3a537a);_0x2aaf5e[_0xf818('0x29')]();});}else{logger[_0xf818('0x10')](_0xf818('0x2a'),_0x3a537a);_0x2aaf5e[_0xf818('0x29')]();}}else{var _0xf7b257=this;var _0x9bc970=new AWS['LexRuntime']({'accessKeyId':_0x4e9817[0x0],'secretAccessKey':_0x4e9817[0x1],'region':_0x4e9817[0x2]});var _0x546735={'botAlias':_0xf818('0x2b'),'botName':_0x4e9817[0x3],'inputText':this[_0xf818('0x2c')][_0xf818('0x21')],'userId':this[_0xf818('0x17')]+':'+this['interaction']['id'][_0xf818('0x2d')]()};_0x9bc970['postText'](_0x546735,function(_0xfaeb29,_0x21a138){if(_0xfaeb29){logger[_0xf818('0x2e')](_0xf818('0x11'),_0x3a537a,_0xfaeb29[_0xf818('0x2c')]);_0x2aaf5e[_0xf818('0x12')]();}else if(_0x21a138&&_0x21a138[_0xf818('0x2c')]){_0xf7b257[_0xf818('0x21')]['amazonlex']=_0x21a138;_0x10b599['body']=_0x21a138[_0xf818('0x2c')];_0x10b599[_0xf818('0x2f')]=_0xf818('0x30');_0x10b599[_0xf818('0x31')]=JSON[_0xf818('0x26')](_0x21a138);return rpc[_0x1e2885+_0xf818('0x22')][_0xf818('0x23')](_0x10b599)[_0xf818('0x24')](function(_0x5aaf7d){logger['info']('[%s][AMAZONLEX]\x20%s',_0x3a537a,_0x10b599['body']);if(_0x21a138[_0xf818('0x32')]==_0xf818('0x33')){_0x2aaf5e[_0xf818('0x12')]();}else{_0x2aaf5e[_0xf818('0x29')]();}})['catch'](function(_0x231744){logger[_0xf818('0x2e')](_0xf818('0x11'),_0x3a537a,JSON[_0xf818('0x26')](_0x231744));_0x2aaf5e['next']();});}else{_0x2aaf5e[_0xf818('0x12')]();}});}}catch(_0x312180){logger['error'](_0xf818('0x11'),_0x3a537a,JSON[_0xf818('0x26')](_0x312180));_0x2aaf5e[_0xf818('0x29')]();}};};
\ No newline at end of file
+var _0x4c73=['../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','consequence','isNil','interaction','UserId','info','[%s][AMAZONLEX]\x20%s','next','contact','format','YYYY-MM-DD\x20HH:mm:ss','out','sms','channel','phone','chat','ChatWebsiteId','account','upperFirst','isEmpty','body','getMustacheRender','Message','create','then','catch','stringify','finally','stop','[%s][AMAZONLEX]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','$LATEST','message','toString','postText','error','amazonlex','providerName','providerResponse','dialogState','lodash','moment','./utils','../../../../config/logger','routing','../../rpc/chatMessage'];(function(_0x4bc876,_0x2a616c){var _0x28f176=function(_0x30108f){while(--_0x30108f){_0x4bc876['push'](_0x4bc876['shift']());}};_0x28f176(++_0x2a616c);}(_0x4c73,0xea));var _0x34c7=function(_0xdc1817,_0x3a934f){_0xdc1817=_0xdc1817-0x0;var _0x15d08d=_0x4c73[_0xdc1817];return _0x15d08d;};'use strict';var _=require(_0x34c7('0x0'));var moment=require(_0x34c7('0x1'));var AWS=require('aws-sdk');var utils=require(_0x34c7('0x2'));var logger=require(_0x34c7('0x3'))(_0x34c7('0x4'));var rpc={'chatMessage':require(_0x34c7('0x5')),'openchannelMessage':require(_0x34c7('0x6')),'mailMessage':require(_0x34c7('0x7')),'smsMessage':require('../../rpc/smsMessage'),'faxMessage':require(_0x34c7('0x8')),'whatsappMessage':require(_0x34c7('0x9'))};exports[_0x34c7('0xa')]=function(_0x73336d,_0x2a5e16){return function(_0x9ad9c9){try{if(!_[_0x34c7('0xb')](this[_0x34c7('0xc')][_0x34c7('0xd')])){logger[_0x34c7('0xe')](_0x34c7('0xf'),_0x73336d,'Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.');return _0x9ad9c9[_0x34c7('0x10')]();}var _0x3e5a6c={'ContactId':this[_0x34c7('0x11')]['id'],'sentAt':moment()[_0x34c7('0x12')](_0x34c7('0x13')),'direction':_0x34c7('0x14')};if(this['channel']===_0x34c7('0x15')||this[_0x34c7('0x16')]==='whatsapp'){_0x3e5a6c[_0x34c7('0x17')]=this[_0x34c7('0xc')][_0x34c7('0x17')];}var _0x471fcb=this[_0x34c7('0x16')];if(_0x471fcb===_0x34c7('0x18')){_0x3e5a6c[_0x34c7('0x19')]=this['account']['id'];}else{_0x3e5a6c[_['upperFirst'](_0x471fcb)+'AccountId']=this[_0x34c7('0x1a')]['id'];}_0x3e5a6c[_[_0x34c7('0x1b')](_0x471fcb)+'InteractionId']=this[_0x34c7('0xc')]['id'];if(this[_0x34c7('0xc')]['created']){var _0x13796e=_0x2a5e16[0x4];if(!_[_0x34c7('0x1c')](_0x13796e)){_0x3e5a6c[_0x34c7('0x1d')]=utils[_0x34c7('0x1e')](_0x13796e,this);return rpc[_0x471fcb+_0x34c7('0x1f')][_0x34c7('0x20')](_0x3e5a6c)[_0x34c7('0x21')](function(_0x13b573){logger['info'](_0x34c7('0xf'),_0x73336d,_0x3e5a6c[_0x34c7('0x1d')]);})[_0x34c7('0x22')](function(_0x31f2df){logger['error']('[%s][AMAZONLEX]\x20%s',_0x73336d,JSON[_0x34c7('0x23')](_0x31f2df));})[_0x34c7('0x24')](function(){logger[_0x34c7('0xe')]('[%s][AMAZONLEX]\x20Welcome\x20Message\x20has\x20been\x20sent!',_0x73336d);_0x9ad9c9[_0x34c7('0x25')]();});}else{logger['info'](_0x34c7('0x26'),_0x73336d);_0x9ad9c9['stop']();}}else{var _0x485c35=this;var _0x5d62ba=new AWS['LexRuntime']({'accessKeyId':_0x2a5e16[0x0],'secretAccessKey':_0x2a5e16[0x1],'region':_0x2a5e16[0x2]});var _0x583c42={'botAlias':_0x34c7('0x27'),'botName':_0x2a5e16[0x3],'inputText':this[_0x34c7('0x28')][_0x34c7('0x1d')],'userId':this[_0x34c7('0x16')]+':'+this['interaction']['id'][_0x34c7('0x29')]()};_0x5d62ba[_0x34c7('0x2a')](_0x583c42,function(_0x2caa9b,_0x5bde2e){if(_0x2caa9b){logger[_0x34c7('0x2b')](_0x34c7('0xf'),_0x73336d,_0x2caa9b[_0x34c7('0x28')]);_0x9ad9c9['next']();}else if(_0x5bde2e&&_0x5bde2e['message']){_0x485c35['body'][_0x34c7('0x2c')]=_0x5bde2e;_0x3e5a6c[_0x34c7('0x1d')]=_0x5bde2e[_0x34c7('0x28')];_0x3e5a6c[_0x34c7('0x2d')]=_0x34c7('0x2c');_0x3e5a6c[_0x34c7('0x2e')]=JSON['stringify'](_0x5bde2e);return rpc[_0x471fcb+_0x34c7('0x1f')]['create'](_0x3e5a6c)[_0x34c7('0x21')](function(_0x4c646c){logger[_0x34c7('0xe')](_0x34c7('0xf'),_0x73336d,_0x3e5a6c[_0x34c7('0x1d')]);if(_0x5bde2e[_0x34c7('0x2f')]=='Failed'){_0x9ad9c9[_0x34c7('0x10')]();}else{_0x9ad9c9[_0x34c7('0x25')]();}})[_0x34c7('0x22')](function(_0x4f33ae){logger['error'](_0x34c7('0xf'),_0x73336d,JSON[_0x34c7('0x23')](_0x4f33ae));_0x9ad9c9[_0x34c7('0x10')]();});}else{_0x9ad9c9[_0x34c7('0x10')]();}});}}catch(_0x15542f){logger[_0x34c7('0x2b')]('[%s][AMAZONLEX]\x20%s',_0x73336d,JSON[_0x34c7('0x23')](_0x15542f));_0x9ad9c9[_0x34c7('0x25')]();}};};
\ No newline at end of file