Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / services / routing / server / applications / amazonlex.js
index f8d85dd..4662f56 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb0f2=['../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','consequence','isNil','UserId','info','[%s][AMAZONLEX]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','contact','YYYY-MM-DD\x20HH:mm:ss','out','channel','sms','whatsapp','phone','interaction','chat','account','upperFirst','created','isEmpty','getMustacheRender','Message','then','body','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','postText','amazonlex','providerResponse','dialogState','Failed','catch','lodash','moment','aws-sdk','./utils'];(function(_0x55c947,_0x5e20a8){var _0x2556b3=function(_0x239288){while(--_0x239288){_0x55c947['push'](_0x55c947['shift']());}};_0x2556b3(++_0x5e20a8);}(_0xb0f2,0x1b5));var _0x2b0f=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xb0f2[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x2b0f('0x0'));var moment=require(_0x2b0f('0x1'));var AWS=require(_0x2b0f('0x2'));var utils=require(_0x2b0f('0x3'));var logger=require('../../../../config/logger')('routing');var rpc={'chatMessage':require(_0x2b0f('0x4')),'openchannelMessage':require(_0x2b0f('0x5')),'mailMessage':require(_0x2b0f('0x6')),'smsMessage':require(_0x2b0f('0x7')),'faxMessage':require(_0x2b0f('0x8')),'whatsappMessage':require(_0x2b0f('0x9'))};exports[_0x2b0f('0xa')]=function(_0x34d5fc,_0x2244c8){return function(_0x31836d){try{if(!_[_0x2b0f('0xb')](this['interaction'][_0x2b0f('0xc')])){logger[_0x2b0f('0xd')](_0x2b0f('0xe'),_0x34d5fc,_0x2b0f('0xf'));return _0x31836d[_0x2b0f('0x10')]();}var _0x3e5931={'ContactId':this[_0x2b0f('0x11')]['id'],'sentAt':moment()['format'](_0x2b0f('0x12')),'direction':_0x2b0f('0x13')};if(this[_0x2b0f('0x14')]===_0x2b0f('0x15')||this[_0x2b0f('0x14')]===_0x2b0f('0x16')){_0x3e5931[_0x2b0f('0x17')]=this[_0x2b0f('0x18')][_0x2b0f('0x17')];}var _0x13797f=this['channel'];if(_0x13797f===_0x2b0f('0x19')){_0x3e5931['ChatWebsiteId']=this[_0x2b0f('0x1a')]['id'];}else{_0x3e5931[_[_0x2b0f('0x1b')](_0x13797f)+'AccountId']=this[_0x2b0f('0x1a')]['id'];}_0x3e5931[_[_0x2b0f('0x1b')](_0x13797f)+'InteractionId']=this[_0x2b0f('0x18')]['id'];if(this['interaction'][_0x2b0f('0x1c')]){var _0x499335=_0x2244c8[0x4];if(!_[_0x2b0f('0x1d')](_0x499335)){_0x3e5931['body']=utils[_0x2b0f('0x1e')](_0x499335,this);return rpc[_0x13797f+_0x2b0f('0x1f')]['create'](_0x3e5931)[_0x2b0f('0x20')](function(_0xf16b03){logger[_0x2b0f('0xd')](_0x2b0f('0xe'),_0x34d5fc,_0x3e5931[_0x2b0f('0x21')]);})['catch'](function(_0x314ae3){logger[_0x2b0f('0x22')](_0x2b0f('0xe'),_0x34d5fc,JSON[_0x2b0f('0x23')](_0x314ae3));})[_0x2b0f('0x24')](function(){logger[_0x2b0f('0xd')](_0x2b0f('0x25'),_0x34d5fc);_0x31836d[_0x2b0f('0x26')]();});}else{logger[_0x2b0f('0xd')](_0x2b0f('0x27'),_0x34d5fc);_0x31836d['stop']();}}else{var _0x276c47=this;var _0x193060=new AWS[(_0x2b0f('0x28'))]({'accessKeyId':_0x2244c8[0x0],'secretAccessKey':_0x2244c8[0x1],'region':_0x2244c8[0x2]});var _0x3cfe4d={'botAlias':_0x2b0f('0x29'),'botName':_0x2244c8[0x3],'inputText':this[_0x2b0f('0x2a')][_0x2b0f('0x21')],'userId':this[_0x2b0f('0x14')]+':'+this[_0x2b0f('0x18')]['id']['toString']()};_0x193060[_0x2b0f('0x2b')](_0x3cfe4d,function(_0x5d53e8,_0x1bb908){if(_0x5d53e8){logger[_0x2b0f('0x22')](_0x2b0f('0xe'),_0x34d5fc,_0x5d53e8[_0x2b0f('0x2a')]);_0x31836d[_0x2b0f('0x10')]();}else if(_0x1bb908&&_0x1bb908['message']){_0x276c47[_0x2b0f('0x21')]['amazonlex']=_0x1bb908;_0x3e5931[_0x2b0f('0x21')]=_0x1bb908[_0x2b0f('0x2a')];_0x3e5931['providerName']=_0x2b0f('0x2c');_0x3e5931[_0x2b0f('0x2d')]=JSON['stringify'](_0x1bb908);return rpc[_0x13797f+_0x2b0f('0x1f')]['create'](_0x3e5931)[_0x2b0f('0x20')](function(_0x1dcfcb){logger[_0x2b0f('0xd')](_0x2b0f('0xe'),_0x34d5fc,_0x3e5931[_0x2b0f('0x21')]);if(_0x1bb908[_0x2b0f('0x2e')]==_0x2b0f('0x2f')){_0x31836d[_0x2b0f('0x10')]();}else{_0x31836d[_0x2b0f('0x26')]();}})[_0x2b0f('0x30')](function(_0x1747aa){logger[_0x2b0f('0x22')](_0x2b0f('0xe'),_0x34d5fc,JSON['stringify'](_0x1747aa));_0x31836d[_0x2b0f('0x10')]();});}else{_0x31836d[_0x2b0f('0x10')]();}});}}catch(_0x4d7ef4){logger[_0x2b0f('0x22')]('[%s][AMAZONLEX]\x20%s',_0x34d5fc,JSON[_0x2b0f('0x23')](_0x4d7ef4));_0x31836d[_0x2b0f('0x26')]();}};};
\ No newline at end of file
+var _0x8014=['upperFirst','AccountId','InteractionId','created','isEmpty','body','getMustacheRender','Message','create','then','[%s][AMAZONLEX]\x20%s','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','$LATEST','message','toString','postText','next','providerName','amazonlex','providerResponse','dialogState','Failed','catch','moment','aws-sdk','../../../../config/logger','../../rpc/chatMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','consequence','interaction','UserId','info','contact','format','YYYY-MM-DD\x20HH:mm:ss','out','channel','sms','phone','chat','ChatWebsiteId','account'];(function(_0x279d37,_0x14de3f){var _0x530173=function(_0x37fc79){while(--_0x37fc79){_0x279d37['push'](_0x279d37['shift']());}};_0x530173(++_0x14de3f);}(_0x8014,0xaf));var _0x4801=function(_0x220f3f,_0x11c540){_0x220f3f=_0x220f3f-0x0;var _0x1f170e=_0x8014[_0x220f3f];return _0x1f170e;};'use strict';var _=require('lodash');var moment=require(_0x4801('0x0'));var AWS=require(_0x4801('0x1'));var utils=require('./utils');var logger=require(_0x4801('0x2'))('routing');var rpc={'chatMessage':require(_0x4801('0x3')),'openchannelMessage':require('../../rpc/openchannelMessage'),'mailMessage':require('../../rpc/mailMessage'),'smsMessage':require(_0x4801('0x4')),'faxMessage':require(_0x4801('0x5')),'whatsappMessage':require(_0x4801('0x6'))};exports[_0x4801('0x7')]=function(_0x5a5a59,_0x462662){return function(_0x50a62b){try{if(!_['isNil'](this[_0x4801('0x8')][_0x4801('0x9')])){logger[_0x4801('0xa')]('[%s][AMAZONLEX]\x20%s',_0x5a5a59,'Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.');return _0x50a62b['next']();}var _0x214d7f={'ContactId':this[_0x4801('0xb')]['id'],'sentAt':moment()[_0x4801('0xc')](_0x4801('0xd')),'direction':_0x4801('0xe')};if(this[_0x4801('0xf')]===_0x4801('0x10')||this[_0x4801('0xf')]==='whatsapp'){_0x214d7f[_0x4801('0x11')]=this[_0x4801('0x8')]['phone'];}var _0x34b176=this[_0x4801('0xf')];if(_0x34b176===_0x4801('0x12')){_0x214d7f[_0x4801('0x13')]=this[_0x4801('0x14')]['id'];}else{_0x214d7f[_[_0x4801('0x15')](_0x34b176)+_0x4801('0x16')]=this['account']['id'];}_0x214d7f[_[_0x4801('0x15')](_0x34b176)+_0x4801('0x17')]=this[_0x4801('0x8')]['id'];if(this['interaction'][_0x4801('0x18')]){var _0x117be7=_0x462662[0x4];if(!_[_0x4801('0x19')](_0x117be7)){_0x214d7f[_0x4801('0x1a')]=utils[_0x4801('0x1b')](_0x117be7,this);return rpc[_0x34b176+_0x4801('0x1c')][_0x4801('0x1d')](_0x214d7f)[_0x4801('0x1e')](function(_0x1446c1){logger[_0x4801('0xa')](_0x4801('0x1f'),_0x5a5a59,_0x214d7f[_0x4801('0x1a')]);})['catch'](function(_0x21068e){logger[_0x4801('0x20')](_0x4801('0x1f'),_0x5a5a59,JSON[_0x4801('0x21')](_0x21068e));})['finally'](function(){logger[_0x4801('0xa')](_0x4801('0x22'),_0x5a5a59);_0x50a62b[_0x4801('0x23')]();});}else{logger[_0x4801('0xa')](_0x4801('0x24'),_0x5a5a59);_0x50a62b['stop']();}}else{var _0x2215bd=this;var _0x863d36=new AWS[(_0x4801('0x25'))]({'accessKeyId':_0x462662[0x0],'secretAccessKey':_0x462662[0x1],'region':_0x462662[0x2]});var _0x34a814={'botAlias':_0x4801('0x26'),'botName':_0x462662[0x3],'inputText':this[_0x4801('0x27')][_0x4801('0x1a')],'userId':this[_0x4801('0xf')]+':'+this[_0x4801('0x8')]['id'][_0x4801('0x28')]()};_0x863d36[_0x4801('0x29')](_0x34a814,function(_0xd8c0b3,_0x5c333d){if(_0xd8c0b3){logger[_0x4801('0x20')](_0x4801('0x1f'),_0x5a5a59,_0xd8c0b3[_0x4801('0x27')]);_0x50a62b[_0x4801('0x2a')]();}else if(_0x5c333d&&_0x5c333d[_0x4801('0x27')]){_0x2215bd['body']['amazonlex']=_0x5c333d;_0x214d7f[_0x4801('0x1a')]=_0x5c333d[_0x4801('0x27')];_0x214d7f[_0x4801('0x2b')]=_0x4801('0x2c');_0x214d7f[_0x4801('0x2d')]=JSON[_0x4801('0x21')](_0x5c333d);return rpc[_0x34b176+_0x4801('0x1c')][_0x4801('0x1d')](_0x214d7f)[_0x4801('0x1e')](function(_0x2c5455){logger[_0x4801('0xa')](_0x4801('0x1f'),_0x5a5a59,_0x214d7f[_0x4801('0x1a')]);if(_0x5c333d[_0x4801('0x2e')]==_0x4801('0x2f')){_0x50a62b['next']();}else{_0x50a62b[_0x4801('0x23')]();}})[_0x4801('0x30')](function(_0x2f84e2){logger[_0x4801('0x20')](_0x4801('0x1f'),_0x5a5a59,JSON[_0x4801('0x21')](_0x2f84e2));_0x50a62b['next']();});}else{_0x50a62b[_0x4801('0x2a')]();}});}}catch(_0xdf82c2){logger['error'](_0x4801('0x1f'),_0x5a5a59,JSON[_0x4801('0x21')](_0xdf82c2));_0x50a62b[_0x4801('0x23')]();}};};
\ No newline at end of file