Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / services / routing / server / applications / amazonlex.js
index 9913441..6ddf91f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x06fb=['phone','ChatWebsiteId','account','upperFirst','AccountId','InteractionId','isEmpty','Message','create','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!','LexRuntime','$LATEST','message','body','toString','postText','providerName','amazonlex','then','dialogState','Failed','next','lodash','moment','aws-sdk','./utils','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','consequence','isNil','interaction','UserId','info','[%s][AMAZONLEX]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','contact','format','YYYY-MM-DD\x20HH:mm:ss','out','channel','whatsapp'];(function(_0x3568bf,_0x33c3ba){var _0xc93b4d=function(_0x14d1b5){while(--_0x14d1b5){_0x3568bf['push'](_0x3568bf['shift']());}};_0xc93b4d(++_0x33c3ba);}(_0x06fb,0x1b4));var _0xb06f=function(_0x2c55d1,_0x558f3d){_0x2c55d1=_0x2c55d1-0x0;var _0x5de2dd=_0x06fb[_0x2c55d1];return _0x5de2dd;};'use strict';var _=require(_0xb06f('0x0'));var moment=require(_0xb06f('0x1'));var AWS=require(_0xb06f('0x2'));var utils=require(_0xb06f('0x3'));var logger=require('../../../../config/logger')(_0xb06f('0x4'));var rpc={'chatMessage':require(_0xb06f('0x5')),'openchannelMessage':require(_0xb06f('0x6')),'mailMessage':require(_0xb06f('0x7')),'smsMessage':require('../../rpc/smsMessage'),'faxMessage':require(_0xb06f('0x8')),'whatsappMessage':require(_0xb06f('0x9'))};exports[_0xb06f('0xa')]=function(_0x124154,_0xd27a8){return function(_0x7059e){try{if(!_[_0xb06f('0xb')](this[_0xb06f('0xc')][_0xb06f('0xd')])){logger[_0xb06f('0xe')](_0xb06f('0xf'),_0x124154,_0xb06f('0x10'));return _0x7059e['next']();}var _0x255eaf={'ContactId':this[_0xb06f('0x11')]['id'],'sentAt':moment()[_0xb06f('0x12')](_0xb06f('0x13')),'direction':_0xb06f('0x14')};if(this[_0xb06f('0x15')]==='sms'||this[_0xb06f('0x15')]===_0xb06f('0x16')){_0x255eaf['phone']=this[_0xb06f('0xc')][_0xb06f('0x17')];}var _0x57de11=this['channel'];if(_0x57de11==='chat'){_0x255eaf[_0xb06f('0x18')]=this[_0xb06f('0x19')]['id'];}else{_0x255eaf[_[_0xb06f('0x1a')](_0x57de11)+_0xb06f('0x1b')]=this[_0xb06f('0x19')]['id'];}_0x255eaf[_[_0xb06f('0x1a')](_0x57de11)+_0xb06f('0x1c')]=this['interaction']['id'];if(this['interaction']['created']){var _0x471af5=_0xd27a8[0x4];if(!_[_0xb06f('0x1d')](_0x471af5)){_0x255eaf['body']=utils['getMustacheRender'](_0x471af5,this);return rpc[_0x57de11+_0xb06f('0x1e')][_0xb06f('0x1f')](_0x255eaf)['then'](function(_0x4d04ac){logger['info']('[%s][AMAZONLEX]\x20%s',_0x124154,_0x255eaf['body']);})[_0xb06f('0x20')](function(_0x208947){logger[_0xb06f('0x21')](_0xb06f('0xf'),_0x124154,JSON[_0xb06f('0x22')](_0x208947));})[_0xb06f('0x23')](function(){logger[_0xb06f('0xe')](_0xb06f('0x24'),_0x124154);_0x7059e[_0xb06f('0x25')]();});}else{logger[_0xb06f('0xe')](_0xb06f('0x26'),_0x124154);_0x7059e[_0xb06f('0x25')]();}}else{var _0x262808=this;var _0x1a37ca=new AWS[(_0xb06f('0x27'))]({'accessKeyId':_0xd27a8[0x0],'secretAccessKey':_0xd27a8[0x1],'region':_0xd27a8[0x2]});var _0x2001d4={'botAlias':_0xb06f('0x28'),'botName':_0xd27a8[0x3],'inputText':this[_0xb06f('0x29')][_0xb06f('0x2a')],'userId':this[_0xb06f('0x15')]+':'+this['interaction']['id'][_0xb06f('0x2b')]()};_0x1a37ca[_0xb06f('0x2c')](_0x2001d4,function(_0x20f4f0,_0x3f37eb){if(_0x20f4f0){logger['error'](_0xb06f('0xf'),_0x124154,_0x20f4f0[_0xb06f('0x29')]);_0x7059e['next']();}else if(_0x3f37eb&&_0x3f37eb[_0xb06f('0x29')]){_0x262808[_0xb06f('0x2a')]['amazonlex']=_0x3f37eb;_0x255eaf[_0xb06f('0x2a')]=_0x3f37eb['message'];_0x255eaf[_0xb06f('0x2d')]=_0xb06f('0x2e');_0x255eaf['providerResponse']=JSON['stringify'](_0x3f37eb);return rpc[_0x57de11+_0xb06f('0x1e')][_0xb06f('0x1f')](_0x255eaf)[_0xb06f('0x2f')](function(_0x32e923){logger[_0xb06f('0xe')](_0xb06f('0xf'),_0x124154,_0x255eaf[_0xb06f('0x2a')]);if(_0x3f37eb[_0xb06f('0x30')]==_0xb06f('0x31')){_0x7059e[_0xb06f('0x32')]();}else{_0x7059e['stop']();}})[_0xb06f('0x20')](function(_0x349c48){logger[_0xb06f('0x21')]('[%s][AMAZONLEX]\x20%s',_0x124154,JSON[_0xb06f('0x22')](_0x349c48));_0x7059e['next']();});}else{_0x7059e[_0xb06f('0x32')]();}});}}catch(_0x572308){logger['error']('[%s][AMAZONLEX]\x20%s',_0x124154,JSON[_0xb06f('0x22')](_0x572308));_0x7059e[_0xb06f('0x25')]();}};};
\ No newline at end of file
+var _0x7c5f=['ChatWebsiteId','account','AccountId','InteractionId','isEmpty','body','create','catch','error','stringify','[%s][AMAZONLEX]\x20Welcome\x20Message\x20has\x20been\x20sent!','stop','[%s][AMAZONLEX]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','LexRuntime','message','toString','postText','next','amazonlex','providerResponse','Message','then','dialogState','Failed','moment','aws-sdk','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','isNil','interaction','UserId','info','[%s][AMAZONLEX]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','channel','sms','whatsapp','phone','chat'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x7c5f,0x126));var _0xf7c5=function(_0x54683e,_0x3ceff7){_0x54683e=_0x54683e-0x0;var _0x53543=_0x7c5f[_0x54683e];return _0x53543;};'use strict';var _=require('lodash');var moment=require(_0xf7c5('0x0'));var AWS=require(_0xf7c5('0x1'));var utils=require('./utils');var logger=require(_0xf7c5('0x2'))(_0xf7c5('0x3'));var rpc={'chatMessage':require(_0xf7c5('0x4')),'openchannelMessage':require(_0xf7c5('0x5')),'mailMessage':require(_0xf7c5('0x6')),'smsMessage':require(_0xf7c5('0x7')),'faxMessage':require(_0xf7c5('0x8')),'whatsappMessage':require(_0xf7c5('0x9'))};exports['consequence']=function(_0x2a1340,_0x5eaa7f){return function(_0x5b5b94){try{if(!_[_0xf7c5('0xa')](this[_0xf7c5('0xb')][_0xf7c5('0xc')])){logger[_0xf7c5('0xd')](_0xf7c5('0xe'),_0x2a1340,_0xf7c5('0xf'));return _0x5b5b94['next']();}var _0xcb15bb={'ContactId':this['contact']['id'],'sentAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'direction':'out'};if(this[_0xf7c5('0x10')]===_0xf7c5('0x11')||this[_0xf7c5('0x10')]===_0xf7c5('0x12')){_0xcb15bb[_0xf7c5('0x13')]=this[_0xf7c5('0xb')][_0xf7c5('0x13')];}var _0x3db3a2=this[_0xf7c5('0x10')];if(_0x3db3a2===_0xf7c5('0x14')){_0xcb15bb[_0xf7c5('0x15')]=this[_0xf7c5('0x16')]['id'];}else{_0xcb15bb[_['upperFirst'](_0x3db3a2)+_0xf7c5('0x17')]=this[_0xf7c5('0x16')]['id'];}_0xcb15bb[_['upperFirst'](_0x3db3a2)+_0xf7c5('0x18')]=this[_0xf7c5('0xb')]['id'];if(this[_0xf7c5('0xb')]['created']){var _0x5c06d5=_0x5eaa7f[0x4];if(!_[_0xf7c5('0x19')](_0x5c06d5)){_0xcb15bb[_0xf7c5('0x1a')]=utils['getMustacheRender'](_0x5c06d5,this);return rpc[_0x3db3a2+'Message'][_0xf7c5('0x1b')](_0xcb15bb)['then'](function(_0x4478d9){logger[_0xf7c5('0xd')]('[%s][AMAZONLEX]\x20%s',_0x2a1340,_0xcb15bb[_0xf7c5('0x1a')]);})[_0xf7c5('0x1c')](function(_0x1983ce){logger[_0xf7c5('0x1d')](_0xf7c5('0xe'),_0x2a1340,JSON[_0xf7c5('0x1e')](_0x1983ce));})['finally'](function(){logger['info'](_0xf7c5('0x1f'),_0x2a1340);_0x5b5b94[_0xf7c5('0x20')]();});}else{logger[_0xf7c5('0xd')](_0xf7c5('0x21'),_0x2a1340);_0x5b5b94[_0xf7c5('0x20')]();}}else{var _0xc792ad=this;var _0x14e920=new AWS[(_0xf7c5('0x22'))]({'accessKeyId':_0x5eaa7f[0x0],'secretAccessKey':_0x5eaa7f[0x1],'region':_0x5eaa7f[0x2]});var _0x1fcbe4={'botAlias':'$LATEST','botName':_0x5eaa7f[0x3],'inputText':this[_0xf7c5('0x23')][_0xf7c5('0x1a')],'userId':this['channel']+':'+this[_0xf7c5('0xb')]['id'][_0xf7c5('0x24')]()};_0x14e920[_0xf7c5('0x25')](_0x1fcbe4,function(_0x55546b,_0x300242){if(_0x55546b){logger[_0xf7c5('0x1d')](_0xf7c5('0xe'),_0x2a1340,_0x55546b[_0xf7c5('0x23')]);_0x5b5b94[_0xf7c5('0x26')]();}else if(_0x300242&&_0x300242['message']){_0xc792ad[_0xf7c5('0x1a')][_0xf7c5('0x27')]=_0x300242;_0xcb15bb['body']=_0x300242[_0xf7c5('0x23')];_0xcb15bb['providerName']=_0xf7c5('0x27');_0xcb15bb[_0xf7c5('0x28')]=JSON[_0xf7c5('0x1e')](_0x300242);return rpc[_0x3db3a2+_0xf7c5('0x29')]['create'](_0xcb15bb)[_0xf7c5('0x2a')](function(_0x58e27c){logger[_0xf7c5('0xd')](_0xf7c5('0xe'),_0x2a1340,_0xcb15bb['body']);if(_0x300242[_0xf7c5('0x2b')]==_0xf7c5('0x2c')){_0x5b5b94[_0xf7c5('0x26')]();}else{_0x5b5b94[_0xf7c5('0x20')]();}})['catch'](function(_0x1fdce1){logger['error'](_0xf7c5('0xe'),_0x2a1340,JSON[_0xf7c5('0x1e')](_0x1fdce1));_0x5b5b94[_0xf7c5('0x26')]();});}else{_0x5b5b94[_0xf7c5('0x26')]();}});}}catch(_0x3a91af){logger[_0xf7c5('0x1d')](_0xf7c5('0xe'),_0x2a1340,JSON[_0xf7c5('0x1e')](_0x3a91af));_0x5b5b94[_0xf7c5('0x20')]();}};};
\ No newline at end of file