Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / services / routing / server / applications / amazonlex.js
index 0066bab..6b1a029 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb4c3=['then','info','[%s][AMAZONLEX]\x20%s','catch','finally','[%s][AMAZONLEX]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','LexRuntime','$LATEST','message','toString','amazonlex','providerName','providerResponse','stringify','create','dialogState','Failed','stop','error','lodash','moment','aws-sdk','./utils','../../../../config/logger','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/whatsappMessage','consequence','isNil','interaction','UserId','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','contact','format','YYYY-MM-DD\x20HH:mm:ss','channel','sms','phone','chat','ChatWebsiteId','upperFirst','AccountId','InteractionId','created','isEmpty','body','getMustacheRender','Message'];(function(_0x407e24,_0x2a448c){var _0xed9d7c=function(_0xbb8070){while(--_0xbb8070){_0x407e24['push'](_0x407e24['shift']());}};_0xed9d7c(++_0x2a448c);}(_0xb4c3,0x1de));var _0x3b4c=function(_0x29afc1,_0x396b90){_0x29afc1=_0x29afc1-0x0;var _0x399d5b=_0xb4c3[_0x29afc1];return _0x399d5b;};'use strict';var _=require(_0x3b4c('0x0'));var moment=require(_0x3b4c('0x1'));var AWS=require(_0x3b4c('0x2'));var utils=require(_0x3b4c('0x3'));var logger=require(_0x3b4c('0x4'))('routing');var rpc={'chatMessage':require(_0x3b4c('0x5')),'openchannelMessage':require(_0x3b4c('0x6')),'mailMessage':require(_0x3b4c('0x7')),'smsMessage':require(_0x3b4c('0x8')),'faxMessage':require('../../rpc/faxMessage'),'whatsappMessage':require(_0x3b4c('0x9'))};exports[_0x3b4c('0xa')]=function(_0x332575,_0x344a4d){return function(_0x59a19c){try{if(!_[_0x3b4c('0xb')](this[_0x3b4c('0xc')][_0x3b4c('0xd')])){logger['info']('[%s][AMAZONLEX]\x20%s',_0x332575,_0x3b4c('0xe'));return _0x59a19c[_0x3b4c('0xf')]();}var _0x364491={'ContactId':this[_0x3b4c('0x10')]['id'],'sentAt':moment()[_0x3b4c('0x11')](_0x3b4c('0x12')),'direction':'out'};if(this[_0x3b4c('0x13')]===_0x3b4c('0x14')||this[_0x3b4c('0x13')]==='whatsapp'){_0x364491[_0x3b4c('0x15')]=this['interaction'][_0x3b4c('0x15')];}var _0x5aa0d9=this['channel'];if(_0x5aa0d9===_0x3b4c('0x16')){_0x364491[_0x3b4c('0x17')]=this['account']['id'];}else{_0x364491[_[_0x3b4c('0x18')](_0x5aa0d9)+_0x3b4c('0x19')]=this['account']['id'];}_0x364491[_[_0x3b4c('0x18')](_0x5aa0d9)+_0x3b4c('0x1a')]=this[_0x3b4c('0xc')]['id'];if(this[_0x3b4c('0xc')][_0x3b4c('0x1b')]){var _0x4ecf76=_0x344a4d[0x4];if(!_[_0x3b4c('0x1c')](_0x4ecf76)){_0x364491[_0x3b4c('0x1d')]=utils[_0x3b4c('0x1e')](_0x4ecf76,this);return rpc[_0x5aa0d9+_0x3b4c('0x1f')]['create'](_0x364491)[_0x3b4c('0x20')](function(_0x548e3c){logger[_0x3b4c('0x21')](_0x3b4c('0x22'),_0x332575,_0x364491[_0x3b4c('0x1d')]);})[_0x3b4c('0x23')](function(_0x236625){logger['error'](_0x3b4c('0x22'),_0x332575,JSON['stringify'](_0x236625));})[_0x3b4c('0x24')](function(){logger[_0x3b4c('0x21')]('[%s][AMAZONLEX]\x20Welcome\x20Message\x20has\x20been\x20sent!',_0x332575);_0x59a19c['stop']();});}else{logger[_0x3b4c('0x21')](_0x3b4c('0x25'),_0x332575);_0x59a19c['stop']();}}else{var _0x3dade5=this;var _0x45e329=new AWS[(_0x3b4c('0x26'))]({'accessKeyId':_0x344a4d[0x0],'secretAccessKey':_0x344a4d[0x1],'region':_0x344a4d[0x2]});var _0x212a72={'botAlias':_0x3b4c('0x27'),'botName':_0x344a4d[0x3],'inputText':this[_0x3b4c('0x28')][_0x3b4c('0x1d')],'userId':this[_0x3b4c('0x13')]+':'+this[_0x3b4c('0xc')]['id'][_0x3b4c('0x29')]()};_0x45e329['postText'](_0x212a72,function(_0x4d375b,_0x3f23b5){if(_0x4d375b){logger['error'](_0x3b4c('0x22'),_0x332575,_0x4d375b[_0x3b4c('0x28')]);_0x59a19c['next']();}else if(_0x3f23b5&&_0x3f23b5[_0x3b4c('0x28')]){_0x3dade5[_0x3b4c('0x1d')][_0x3b4c('0x2a')]=_0x3f23b5;_0x364491['body']=_0x3f23b5['message'];_0x364491[_0x3b4c('0x2b')]=_0x3b4c('0x2a');_0x364491[_0x3b4c('0x2c')]=JSON[_0x3b4c('0x2d')](_0x3f23b5);return rpc[_0x5aa0d9+'Message'][_0x3b4c('0x2e')](_0x364491)[_0x3b4c('0x20')](function(_0x5470f3){logger[_0x3b4c('0x21')](_0x3b4c('0x22'),_0x332575,_0x364491[_0x3b4c('0x1d')]);if(_0x3f23b5[_0x3b4c('0x2f')]==_0x3b4c('0x30')){_0x59a19c[_0x3b4c('0xf')]();}else{_0x59a19c[_0x3b4c('0x31')]();}})[_0x3b4c('0x23')](function(_0x5f0044){logger[_0x3b4c('0x32')](_0x3b4c('0x22'),_0x332575,JSON[_0x3b4c('0x2d')](_0x5f0044));_0x59a19c[_0x3b4c('0xf')]();});}else{_0x59a19c[_0x3b4c('0xf')]();}});}}catch(_0x39c5c7){logger[_0x3b4c('0x32')](_0x3b4c('0x22'),_0x332575,JSON[_0x3b4c('0x2d')](_0x39c5c7));_0x59a19c[_0x3b4c('0x31')]();}};};
\ No newline at end of file
+var _0xf4d9=['[%s][AMAZONLEX]\x20Welcome\x20Message\x20has\x20been\x20sent!','[%s][AMAZONLEX]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','stop','LexRuntime','message','toString','postText','amazonlex','providerName','Failed','lodash','moment','aws-sdk','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','isNil','interaction','UserId','info','[%s][AMAZONLEX]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','contact','format','out','channel','sms','whatsapp','phone','chat','ChatWebsiteId','account','AccountId','upperFirst','InteractionId','created','isEmpty','body','Message','create','then','catch','error','stringify','finally'];(function(_0x19e35c,_0x29cd1e){var _0x3e1fe8=function(_0x17258b){while(--_0x17258b){_0x19e35c['push'](_0x19e35c['shift']());}};_0x3e1fe8(++_0x29cd1e);}(_0xf4d9,0x19a));var _0x9f4d=function(_0x391942,_0x5a176d){_0x391942=_0x391942-0x0;var _0x20d5ce=_0xf4d9[_0x391942];return _0x20d5ce;};'use strict';var _=require(_0x9f4d('0x0'));var moment=require(_0x9f4d('0x1'));var AWS=require(_0x9f4d('0x2'));var utils=require('./utils');var logger=require(_0x9f4d('0x3'))(_0x9f4d('0x4'));var rpc={'chatMessage':require(_0x9f4d('0x5')),'openchannelMessage':require(_0x9f4d('0x6')),'mailMessage':require(_0x9f4d('0x7')),'smsMessage':require(_0x9f4d('0x8')),'faxMessage':require(_0x9f4d('0x9')),'whatsappMessage':require('../../rpc/whatsappMessage')};exports['consequence']=function(_0x113356,_0x2b0de5){return function(_0x16e8d5){try{if(!_[_0x9f4d('0xa')](this[_0x9f4d('0xb')][_0x9f4d('0xc')])){logger[_0x9f4d('0xd')](_0x9f4d('0xe'),_0x113356,_0x9f4d('0xf'));return _0x16e8d5[_0x9f4d('0x10')]();}var _0x29efac={'ContactId':this[_0x9f4d('0x11')]['id'],'sentAt':moment()[_0x9f4d('0x12')]('YYYY-MM-DD\x20HH:mm:ss'),'direction':_0x9f4d('0x13')};if(this[_0x9f4d('0x14')]===_0x9f4d('0x15')||this[_0x9f4d('0x14')]===_0x9f4d('0x16')){_0x29efac[_0x9f4d('0x17')]=this['interaction'][_0x9f4d('0x17')];}var _0x3ad127=this[_0x9f4d('0x14')];if(_0x3ad127===_0x9f4d('0x18')){_0x29efac[_0x9f4d('0x19')]=this[_0x9f4d('0x1a')]['id'];}else{_0x29efac[_['upperFirst'](_0x3ad127)+_0x9f4d('0x1b')]=this['account']['id'];}_0x29efac[_[_0x9f4d('0x1c')](_0x3ad127)+_0x9f4d('0x1d')]=this[_0x9f4d('0xb')]['id'];if(this[_0x9f4d('0xb')][_0x9f4d('0x1e')]){var _0x248ac1=_0x2b0de5[0x4];if(!_[_0x9f4d('0x1f')](_0x248ac1)){_0x29efac[_0x9f4d('0x20')]=utils['getMustacheRender'](_0x248ac1,this);return rpc[_0x3ad127+_0x9f4d('0x21')][_0x9f4d('0x22')](_0x29efac)[_0x9f4d('0x23')](function(_0x36ff7a){logger[_0x9f4d('0xd')]('[%s][AMAZONLEX]\x20%s',_0x113356,_0x29efac[_0x9f4d('0x20')]);})[_0x9f4d('0x24')](function(_0x3c7b0c){logger[_0x9f4d('0x25')](_0x9f4d('0xe'),_0x113356,JSON[_0x9f4d('0x26')](_0x3c7b0c));})[_0x9f4d('0x27')](function(){logger[_0x9f4d('0xd')](_0x9f4d('0x28'),_0x113356);_0x16e8d5['stop']();});}else{logger[_0x9f4d('0xd')](_0x9f4d('0x29'),_0x113356);_0x16e8d5[_0x9f4d('0x2a')]();}}else{var _0x2286e3=this;var _0x44ab=new AWS[(_0x9f4d('0x2b'))]({'accessKeyId':_0x2b0de5[0x0],'secretAccessKey':_0x2b0de5[0x1],'region':_0x2b0de5[0x2]});var _0x5ac2ea={'botAlias':'$LATEST','botName':_0x2b0de5[0x3],'inputText':this[_0x9f4d('0x2c')][_0x9f4d('0x20')],'userId':this[_0x9f4d('0x14')]+':'+this[_0x9f4d('0xb')]['id'][_0x9f4d('0x2d')]()};_0x44ab[_0x9f4d('0x2e')](_0x5ac2ea,function(_0xc76e8e,_0x5577f1){if(_0xc76e8e){logger[_0x9f4d('0x25')]('[%s][AMAZONLEX]\x20%s',_0x113356,_0xc76e8e[_0x9f4d('0x2c')]);_0x16e8d5[_0x9f4d('0x10')]();}else if(_0x5577f1&&_0x5577f1[_0x9f4d('0x2c')]){_0x2286e3[_0x9f4d('0x20')][_0x9f4d('0x2f')]=_0x5577f1;_0x29efac[_0x9f4d('0x20')]=_0x5577f1[_0x9f4d('0x2c')];_0x29efac[_0x9f4d('0x30')]=_0x9f4d('0x2f');_0x29efac['providerResponse']=JSON[_0x9f4d('0x26')](_0x5577f1);return rpc[_0x3ad127+'Message'][_0x9f4d('0x22')](_0x29efac)['then'](function(_0x4f1fc9){logger['info'](_0x9f4d('0xe'),_0x113356,_0x29efac[_0x9f4d('0x20')]);if(_0x5577f1['dialogState']==_0x9f4d('0x31')){_0x16e8d5[_0x9f4d('0x10')]();}else{_0x16e8d5[_0x9f4d('0x2a')]();}})[_0x9f4d('0x24')](function(_0x309e58){logger[_0x9f4d('0x25')](_0x9f4d('0xe'),_0x113356,JSON['stringify'](_0x309e58));_0x16e8d5[_0x9f4d('0x10')]();});}else{_0x16e8d5[_0x9f4d('0x10')]();}});}}catch(_0xee202c){logger[_0x9f4d('0x25')](_0x9f4d('0xe'),_0x113356,JSON[_0x9f4d('0x26')](_0xee202c));_0x16e8d5[_0x9f4d('0x2a')]();}};};
\ No newline at end of file