Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / services / routing / server / applications / amazonlex.js
index 247aad3..0efc21e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa66f=['isEmpty','Message','create','then','[%s][AMAZONLEX]\x20%s','catch','error','finally','[%s][AMAZONLEX]\x20Welcome\x20Message\x20has\x20been\x20sent!','stop','$LATEST','message','body','postText','providerName','providerResponse','stringify','dialogState','Failed','moment','aws-sdk','./utils','../../../../config/logger','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','consequence','isNil','UserId','info','next','contact','YYYY-MM-DD\x20HH:mm:ss','channel','whatsapp','interaction','phone','chat','account','upperFirst','InteractionId','created'];(function(_0x56cf36,_0xd22434){var _0x48d6b7=function(_0x15c19a){while(--_0x15c19a){_0x56cf36['push'](_0x56cf36['shift']());}};_0x48d6b7(++_0xd22434);}(_0xa66f,0x1a8));var _0xfa66=function(_0x25d0f0,_0x470f42){_0x25d0f0=_0x25d0f0-0x0;var _0x1d5c30=_0xa66f[_0x25d0f0];return _0x1d5c30;};'use strict';var _=require('lodash');var moment=require(_0xfa66('0x0'));var AWS=require(_0xfa66('0x1'));var utils=require(_0xfa66('0x2'));var logger=require(_0xfa66('0x3'))('routing');var rpc={'chatMessage':require(_0xfa66('0x4')),'openchannelMessage':require(_0xfa66('0x5')),'mailMessage':require(_0xfa66('0x6')),'smsMessage':require(_0xfa66('0x7')),'faxMessage':require(_0xfa66('0x8')),'whatsappMessage':require(_0xfa66('0x9'))};exports[_0xfa66('0xa')]=function(_0x21cb23,_0x5670db){return function(_0x2417d2){try{if(!_[_0xfa66('0xb')](this['interaction'][_0xfa66('0xc')])){logger[_0xfa66('0xd')]('[%s][AMAZONLEX]\x20%s',_0x21cb23,'Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.');return _0x2417d2[_0xfa66('0xe')]();}var _0x1802fe={'ContactId':this[_0xfa66('0xf')]['id'],'sentAt':moment()['format'](_0xfa66('0x10')),'direction':'out'};if(this['channel']==='sms'||this[_0xfa66('0x11')]===_0xfa66('0x12')){_0x1802fe['phone']=this[_0xfa66('0x13')][_0xfa66('0x14')];}var _0x3d28aa=this['channel'];if(_0x3d28aa===_0xfa66('0x15')){_0x1802fe['ChatWebsiteId']=this[_0xfa66('0x16')]['id'];}else{_0x1802fe[_[_0xfa66('0x17')](_0x3d28aa)+'AccountId']=this[_0xfa66('0x16')]['id'];}_0x1802fe[_[_0xfa66('0x17')](_0x3d28aa)+_0xfa66('0x18')]=this[_0xfa66('0x13')]['id'];if(this[_0xfa66('0x13')][_0xfa66('0x19')]){var _0x20790e=_0x5670db[0x4];if(!_[_0xfa66('0x1a')](_0x20790e)){_0x1802fe['body']=utils['getMustacheRender'](_0x20790e,this);return rpc[_0x3d28aa+_0xfa66('0x1b')][_0xfa66('0x1c')](_0x1802fe)[_0xfa66('0x1d')](function(_0x279fe1){logger[_0xfa66('0xd')](_0xfa66('0x1e'),_0x21cb23,_0x1802fe['body']);})[_0xfa66('0x1f')](function(_0xbea519){logger[_0xfa66('0x20')](_0xfa66('0x1e'),_0x21cb23,JSON['stringify'](_0xbea519));})[_0xfa66('0x21')](function(){logger['info'](_0xfa66('0x22'),_0x21cb23);_0x2417d2['stop']();});}else{logger[_0xfa66('0xd')]('[%s][AMAZONLEX]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!',_0x21cb23);_0x2417d2[_0xfa66('0x23')]();}}else{var _0x5a933d=this;var _0x342df8=new AWS['LexRuntime']({'accessKeyId':_0x5670db[0x0],'secretAccessKey':_0x5670db[0x1],'region':_0x5670db[0x2]});var _0x41cb65={'botAlias':_0xfa66('0x24'),'botName':_0x5670db[0x3],'inputText':this[_0xfa66('0x25')][_0xfa66('0x26')],'userId':this['channel']+':'+this[_0xfa66('0x13')]['id']['toString']()};_0x342df8[_0xfa66('0x27')](_0x41cb65,function(_0x43614a,_0x18e4cc){if(_0x43614a){logger[_0xfa66('0x20')](_0xfa66('0x1e'),_0x21cb23,_0x43614a[_0xfa66('0x25')]);_0x2417d2[_0xfa66('0xe')]();}else if(_0x18e4cc&&_0x18e4cc[_0xfa66('0x25')]){_0x5a933d['body']['amazonlex']=_0x18e4cc;_0x1802fe[_0xfa66('0x26')]=_0x18e4cc[_0xfa66('0x25')];_0x1802fe[_0xfa66('0x28')]='amazonlex';_0x1802fe[_0xfa66('0x29')]=JSON[_0xfa66('0x2a')](_0x18e4cc);return rpc[_0x3d28aa+'Message'][_0xfa66('0x1c')](_0x1802fe)[_0xfa66('0x1d')](function(_0x3e2e39){logger[_0xfa66('0xd')](_0xfa66('0x1e'),_0x21cb23,_0x1802fe[_0xfa66('0x26')]);if(_0x18e4cc[_0xfa66('0x2b')]==_0xfa66('0x2c')){_0x2417d2['next']();}else{_0x2417d2[_0xfa66('0x23')]();}})[_0xfa66('0x1f')](function(_0x1e9ea4){logger[_0xfa66('0x20')](_0xfa66('0x1e'),_0x21cb23,JSON[_0xfa66('0x2a')](_0x1e9ea4));_0x2417d2[_0xfa66('0xe')]();});}else{_0x2417d2[_0xfa66('0xe')]();}});}}catch(_0x2ed043){logger[_0xfa66('0x20')](_0xfa66('0x1e'),_0x21cb23,JSON['stringify'](_0x2ed043));_0x2417d2['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