Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / services / routing / server / applications / amazonlex.js
index 9f5897e..6ddf91f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xff76=['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','message','amazonlex','providerName','dialogState','lodash','moment','aws-sdk','./utils','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','consequence','isNil','interaction','UserId','info','[%s][AMAZONLEX]\x20%s','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','YYYY-MM-DD\x20HH:mm:ss','out','channel','sms','phone','chat','ChatWebsiteId','upperFirst','AccountId','InteractionId','isEmpty','body','getMustacheRender','Message','create','then','catch'];(function(_0xdfd552,_0x5f39a0){var _0x598335=function(_0x1dc924){while(--_0x1dc924){_0xdfd552['push'](_0xdfd552['shift']());}};_0x598335(++_0x5f39a0);}(_0xff76,0xc7));var _0x6ff7=function(_0x2d8fc2,_0x1c461d){_0x2d8fc2=_0x2d8fc2-0x0;var _0x3a9e53=_0xff76[_0x2d8fc2];return _0x3a9e53;};'use strict';var _=require(_0x6ff7('0x0'));var moment=require(_0x6ff7('0x1'));var AWS=require(_0x6ff7('0x2'));var utils=require(_0x6ff7('0x3'));var logger=require(_0x6ff7('0x4'))(_0x6ff7('0x5'));var rpc={'chatMessage':require(_0x6ff7('0x6')),'openchannelMessage':require(_0x6ff7('0x7')),'mailMessage':require(_0x6ff7('0x8')),'smsMessage':require(_0x6ff7('0x9')),'faxMessage':require(_0x6ff7('0xa')),'whatsappMessage':require('../../rpc/whatsappMessage')};exports[_0x6ff7('0xb')]=function(_0x16f050,_0xec1ac4){return function(_0x410ab2){try{if(!_[_0x6ff7('0xc')](this[_0x6ff7('0xd')][_0x6ff7('0xe')])){logger[_0x6ff7('0xf')](_0x6ff7('0x10'),_0x16f050,_0x6ff7('0x11'));return _0x410ab2[_0x6ff7('0x12')]();}var _0x34374b={'ContactId':this['contact']['id'],'sentAt':moment()['format'](_0x6ff7('0x13')),'direction':_0x6ff7('0x14')};if(this[_0x6ff7('0x15')]===_0x6ff7('0x16')||this[_0x6ff7('0x15')]==='whatsapp'){_0x34374b[_0x6ff7('0x17')]=this[_0x6ff7('0xd')][_0x6ff7('0x17')];}var _0x260831=this[_0x6ff7('0x15')];if(_0x260831===_0x6ff7('0x18')){_0x34374b[_0x6ff7('0x19')]=this['account']['id'];}else{_0x34374b[_[_0x6ff7('0x1a')](_0x260831)+_0x6ff7('0x1b')]=this['account']['id'];}_0x34374b[_['upperFirst'](_0x260831)+_0x6ff7('0x1c')]=this[_0x6ff7('0xd')]['id'];if(this[_0x6ff7('0xd')]['created']){var _0x42bef5=_0xec1ac4[0x4];if(!_[_0x6ff7('0x1d')](_0x42bef5)){_0x34374b[_0x6ff7('0x1e')]=utils[_0x6ff7('0x1f')](_0x42bef5,this);return rpc[_0x260831+_0x6ff7('0x20')][_0x6ff7('0x21')](_0x34374b)[_0x6ff7('0x22')](function(_0x53f266){logger['info'](_0x6ff7('0x10'),_0x16f050,_0x34374b['body']);})[_0x6ff7('0x23')](function(_0x2877ab){logger[_0x6ff7('0x24')]('[%s][AMAZONLEX]\x20%s',_0x16f050,JSON[_0x6ff7('0x25')](_0x2877ab));})[_0x6ff7('0x26')](function(){logger[_0x6ff7('0xf')](_0x6ff7('0x27'),_0x16f050);_0x410ab2[_0x6ff7('0x28')]();});}else{logger['info'](_0x6ff7('0x29'),_0x16f050);_0x410ab2[_0x6ff7('0x28')]();}}else{var _0x3094b3=this;var _0x200806=new AWS[(_0x6ff7('0x2a'))]({'accessKeyId':_0xec1ac4[0x0],'secretAccessKey':_0xec1ac4[0x1],'region':_0xec1ac4[0x2]});var _0xca8aea={'botAlias':'$LATEST','botName':_0xec1ac4[0x3],'inputText':this[_0x6ff7('0x2b')][_0x6ff7('0x1e')],'userId':this[_0x6ff7('0x15')]+':'+this[_0x6ff7('0xd')]['id']['toString']()};_0x200806['postText'](_0xca8aea,function(_0x5e511c,_0x1bdb51){if(_0x5e511c){logger['error'](_0x6ff7('0x10'),_0x16f050,_0x5e511c[_0x6ff7('0x2b')]);_0x410ab2[_0x6ff7('0x12')]();}else if(_0x1bdb51&&_0x1bdb51[_0x6ff7('0x2b')]){_0x3094b3[_0x6ff7('0x1e')][_0x6ff7('0x2c')]=_0x1bdb51;_0x34374b[_0x6ff7('0x1e')]=_0x1bdb51['message'];_0x34374b[_0x6ff7('0x2d')]=_0x6ff7('0x2c');_0x34374b['providerResponse']=JSON[_0x6ff7('0x25')](_0x1bdb51);return rpc[_0x260831+_0x6ff7('0x20')]['create'](_0x34374b)[_0x6ff7('0x22')](function(_0x4e7049){logger['info']('[%s][AMAZONLEX]\x20%s',_0x16f050,_0x34374b['body']);if(_0x1bdb51[_0x6ff7('0x2e')]=='Failed'){_0x410ab2[_0x6ff7('0x12')]();}else{_0x410ab2[_0x6ff7('0x28')]();}})[_0x6ff7('0x23')](function(_0xceba19){logger[_0x6ff7('0x24')](_0x6ff7('0x10'),_0x16f050,JSON['stringify'](_0xceba19));_0x410ab2[_0x6ff7('0x12')]();});}else{_0x410ab2['next']();}});}}catch(_0xd476d8){logger[_0x6ff7('0x24')](_0x6ff7('0x10'),_0x16f050,JSON[_0x6ff7('0x25')](_0xd476d8));_0x410ab2[_0x6ff7('0x28')]();}};};
\ 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