Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / services / routing / server / applications / amazonlex.js
index 42d6897..0efc21e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbc4c=['isEmpty','getMustacheRender','body','catch','error','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','postText','next','providerName','amazonlex','Message','create','dialogState','Failed','lodash','moment','aws-sdk','./utils','../../../../config/logger','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/smsMessage','../../rpc/faxMessage','consequence','interaction','UserId','info','[%s][AMAZONLEX]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','contact','format','channel','sms','phone','chat','account','upperFirst','AccountId','InteractionId'];(function(_0x2da4c5,_0x44a410){var _0x3d3903=function(_0x2004e3){while(--_0x2004e3){_0x2da4c5['push'](_0x2da4c5['shift']());}};_0x3d3903(++_0x44a410);}(_0xbc4c,0xcd));var _0xcbc4=function(_0x53f897,_0x539857){_0x53f897=_0x53f897-0x0;var _0x6879f8=_0xbc4c[_0x53f897];return _0x6879f8;};'use strict';var _=require(_0xcbc4('0x0'));var moment=require(_0xcbc4('0x1'));var AWS=require(_0xcbc4('0x2'));var utils=require(_0xcbc4('0x3'));var logger=require(_0xcbc4('0x4'))('routing');var rpc={'chatMessage':require(_0xcbc4('0x5')),'openchannelMessage':require(_0xcbc4('0x6')),'mailMessage':require('../../rpc/mailMessage'),'smsMessage':require(_0xcbc4('0x7')),'faxMessage':require(_0xcbc4('0x8')),'whatsappMessage':require('../../rpc/whatsappMessage')};exports[_0xcbc4('0x9')]=function(_0x2f5d56,_0x22b6e3){return function(_0x1d7893){try{if(!_['isNil'](this[_0xcbc4('0xa')][_0xcbc4('0xb')])){logger[_0xcbc4('0xc')](_0xcbc4('0xd'),_0x2f5d56,_0xcbc4('0xe'));return _0x1d7893['next']();}var _0x2342d7={'ContactId':this[_0xcbc4('0xf')]['id'],'sentAt':moment()[_0xcbc4('0x10')]('YYYY-MM-DD\x20HH:mm:ss'),'direction':'out'};if(this[_0xcbc4('0x11')]===_0xcbc4('0x12')||this['channel']==='whatsapp'){_0x2342d7[_0xcbc4('0x13')]=this[_0xcbc4('0xa')][_0xcbc4('0x13')];}var _0x8612b2=this[_0xcbc4('0x11')];if(_0x8612b2===_0xcbc4('0x14')){_0x2342d7['ChatWebsiteId']=this[_0xcbc4('0x15')]['id'];}else{_0x2342d7[_[_0xcbc4('0x16')](_0x8612b2)+_0xcbc4('0x17')]=this['account']['id'];}_0x2342d7[_[_0xcbc4('0x16')](_0x8612b2)+_0xcbc4('0x18')]=this[_0xcbc4('0xa')]['id'];if(this[_0xcbc4('0xa')]['created']){var _0x21908f=_0x22b6e3[0x4];if(!_[_0xcbc4('0x19')](_0x21908f)){_0x2342d7['body']=utils[_0xcbc4('0x1a')](_0x21908f,this);return rpc[_0x8612b2+'Message']['create'](_0x2342d7)['then'](function(_0x2fe6c3){logger[_0xcbc4('0xc')](_0xcbc4('0xd'),_0x2f5d56,_0x2342d7[_0xcbc4('0x1b')]);})[_0xcbc4('0x1c')](function(_0x391ccf){logger[_0xcbc4('0x1d')](_0xcbc4('0xd'),_0x2f5d56,JSON[_0xcbc4('0x1e')](_0x391ccf));})[_0xcbc4('0x1f')](function(){logger[_0xcbc4('0xc')](_0xcbc4('0x20'),_0x2f5d56);_0x1d7893[_0xcbc4('0x21')]();});}else{logger[_0xcbc4('0xc')](_0xcbc4('0x22'),_0x2f5d56);_0x1d7893[_0xcbc4('0x21')]();}}else{var _0xe4bfe6=this;var _0x15b69b=new AWS['LexRuntime']({'accessKeyId':_0x22b6e3[0x0],'secretAccessKey':_0x22b6e3[0x1],'region':_0x22b6e3[0x2]});var _0xe2262e={'botAlias':_0xcbc4('0x23'),'botName':_0x22b6e3[0x3],'inputText':this[_0xcbc4('0x24')][_0xcbc4('0x1b')],'userId':this[_0xcbc4('0x11')]+':'+this['interaction']['id'][_0xcbc4('0x25')]()};_0x15b69b[_0xcbc4('0x26')](_0xe2262e,function(_0x542591,_0x44b542){if(_0x542591){logger[_0xcbc4('0x1d')](_0xcbc4('0xd'),_0x2f5d56,_0x542591['message']);_0x1d7893[_0xcbc4('0x27')]();}else if(_0x44b542&&_0x44b542['message']){_0xe4bfe6[_0xcbc4('0x1b')]['amazonlex']=_0x44b542;_0x2342d7[_0xcbc4('0x1b')]=_0x44b542[_0xcbc4('0x24')];_0x2342d7[_0xcbc4('0x28')]=_0xcbc4('0x29');_0x2342d7['providerResponse']=JSON[_0xcbc4('0x1e')](_0x44b542);return rpc[_0x8612b2+_0xcbc4('0x2a')][_0xcbc4('0x2b')](_0x2342d7)['then'](function(_0x3df64a){logger[_0xcbc4('0xc')]('[%s][AMAZONLEX]\x20%s',_0x2f5d56,_0x2342d7[_0xcbc4('0x1b')]);if(_0x44b542[_0xcbc4('0x2c')]==_0xcbc4('0x2d')){_0x1d7893[_0xcbc4('0x27')]();}else{_0x1d7893[_0xcbc4('0x21')]();}})[_0xcbc4('0x1c')](function(_0x3162b9){logger['error'](_0xcbc4('0xd'),_0x2f5d56,JSON[_0xcbc4('0x1e')](_0x3162b9));_0x1d7893['next']();});}else{_0x1d7893[_0xcbc4('0x27')]();}});}}catch(_0x5d6890){logger[_0xcbc4('0x1d')](_0xcbc4('0xd'),_0x2f5d56,JSON[_0xcbc4('0x1e')](_0x5d6890));_0x1d7893['stop']();}};};
\ No newline at end of file
+var _0x6ff0=['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','postText','error','next','providerName','amazonlex','providerResponse','Failed','lodash','moment','aws-sdk','./utils','../../../../config/logger','routing','../../rpc/openchannelMessage','../../rpc/smsMessage','../../rpc/whatsappMessage','isNil','interaction','info','[%s][AMAZONLEX]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','contact','YYYY-MM-DD\x20HH:mm:ss','channel','sms','phone','chat','ChatWebsiteId','account','upperFirst','AccountId','InteractionId','created','isEmpty','body','Message','create'];(function(_0x25c03e,_0xc6224d){var _0x1b121b=function(_0x5061c4){while(--_0x5061c4){_0x25c03e['push'](_0x25c03e['shift']());}};_0x1b121b(++_0xc6224d);}(_0x6ff0,0x9a));var _0x06ff=function(_0x3d7fb5,_0x16eb5c){_0x3d7fb5=_0x3d7fb5-0x0;var _0x3a9642=_0x6ff0[_0x3d7fb5];return _0x3a9642;};'use strict';var _=require(_0x06ff('0x0'));var moment=require(_0x06ff('0x1'));var AWS=require(_0x06ff('0x2'));var utils=require(_0x06ff('0x3'));var logger=require(_0x06ff('0x4'))(_0x06ff('0x5'));var rpc={'chatMessage':require('../../rpc/chatMessage'),'openchannelMessage':require(_0x06ff('0x6')),'mailMessage':require('../../rpc/mailMessage'),'smsMessage':require(_0x06ff('0x7')),'faxMessage':require('../../rpc/faxMessage'),'whatsappMessage':require(_0x06ff('0x8'))};exports['consequence']=function(_0x22fd3,_0x58fa7f){return function(_0x4ad272){try{if(!_[_0x06ff('0x9')](this[_0x06ff('0xa')]['UserId'])){logger[_0x06ff('0xb')](_0x06ff('0xc'),_0x22fd3,_0x06ff('0xd'));return _0x4ad272['next']();}var _0x1f3a82={'ContactId':this[_0x06ff('0xe')]['id'],'sentAt':moment()['format'](_0x06ff('0xf')),'direction':'out'};if(this[_0x06ff('0x10')]===_0x06ff('0x11')||this['channel']==='whatsapp'){_0x1f3a82[_0x06ff('0x12')]=this[_0x06ff('0xa')][_0x06ff('0x12')];}var _0x503536=this[_0x06ff('0x10')];if(_0x503536===_0x06ff('0x13')){_0x1f3a82[_0x06ff('0x14')]=this[_0x06ff('0x15')]['id'];}else{_0x1f3a82[_[_0x06ff('0x16')](_0x503536)+_0x06ff('0x17')]=this['account']['id'];}_0x1f3a82[_[_0x06ff('0x16')](_0x503536)+_0x06ff('0x18')]=this[_0x06ff('0xa')]['id'];if(this[_0x06ff('0xa')][_0x06ff('0x19')]){var _0x639b61=_0x58fa7f[0x4];if(!_[_0x06ff('0x1a')](_0x639b61)){_0x1f3a82[_0x06ff('0x1b')]=utils['getMustacheRender'](_0x639b61,this);return rpc[_0x503536+_0x06ff('0x1c')][_0x06ff('0x1d')](_0x1f3a82)[_0x06ff('0x1e')](function(_0x30a570){logger[_0x06ff('0xb')]('[%s][AMAZONLEX]\x20%s',_0x22fd3,_0x1f3a82[_0x06ff('0x1b')]);})[_0x06ff('0x1f')](function(_0x3becd7){logger['error']('[%s][AMAZONLEX]\x20%s',_0x22fd3,JSON[_0x06ff('0x20')](_0x3becd7));})[_0x06ff('0x21')](function(){logger[_0x06ff('0xb')](_0x06ff('0x22'),_0x22fd3);_0x4ad272[_0x06ff('0x23')]();});}else{logger[_0x06ff('0xb')](_0x06ff('0x24'),_0x22fd3);_0x4ad272[_0x06ff('0x23')]();}}else{var _0x25e784=this;var _0x37802b=new AWS['LexRuntime']({'accessKeyId':_0x58fa7f[0x0],'secretAccessKey':_0x58fa7f[0x1],'region':_0x58fa7f[0x2]});var _0x259f80={'botAlias':_0x06ff('0x25'),'botName':_0x58fa7f[0x3],'inputText':this[_0x06ff('0x26')][_0x06ff('0x1b')],'userId':this[_0x06ff('0x10')]+':'+this[_0x06ff('0xa')]['id']['toString']()};_0x37802b[_0x06ff('0x27')](_0x259f80,function(_0x3b3109,_0x4d4552){if(_0x3b3109){logger[_0x06ff('0x28')]('[%s][AMAZONLEX]\x20%s',_0x22fd3,_0x3b3109[_0x06ff('0x26')]);_0x4ad272[_0x06ff('0x29')]();}else if(_0x4d4552&&_0x4d4552[_0x06ff('0x26')]){_0x25e784[_0x06ff('0x1b')]['amazonlex']=_0x4d4552;_0x1f3a82['body']=_0x4d4552[_0x06ff('0x26')];_0x1f3a82[_0x06ff('0x2a')]=_0x06ff('0x2b');_0x1f3a82[_0x06ff('0x2c')]=JSON['stringify'](_0x4d4552);return rpc[_0x503536+'Message'][_0x06ff('0x1d')](_0x1f3a82)[_0x06ff('0x1e')](function(_0x5d20fe){logger[_0x06ff('0xb')](_0x06ff('0xc'),_0x22fd3,_0x1f3a82[_0x06ff('0x1b')]);if(_0x4d4552['dialogState']==_0x06ff('0x2d')){_0x4ad272['next']();}else{_0x4ad272['stop']();}})[_0x06ff('0x1f')](function(_0x512eb3){logger[_0x06ff('0x28')](_0x06ff('0xc'),_0x22fd3,JSON['stringify'](_0x512eb3));_0x4ad272[_0x06ff('0x29')]();});}else{_0x4ad272[_0x06ff('0x29')]();}});}}catch(_0x5e0a07){logger[_0x06ff('0x28')](_0x06ff('0xc'),_0x22fd3,JSON['stringify'](_0x5e0a07));_0x4ad272[_0x06ff('0x23')]();}};};
\ No newline at end of file