Built motion from commit c49361c37b5f784889c8087ac6e0e91b7e6b561a. Version 3.0.0...
[motion-next.git] / server / services / routing / server / applications / dialogflow.js
1 const a1203_0x4764=['upperFirst','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','finally','../../rpc/mailMessage','isNil','YYYY-MM-DD\x20HH:mm:ss','InteractionId','message','AccountId','getMustacheRender','isEmpty','account','result','[%s][DIALOGFLOW]\x20%s','moment','textRequest','channel','UserId','consequence','./utils','Message','create','format','contact','../../rpc/openchannelMessage','../../rpc/smsMessage','routing','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','../../rpc/chatMessage','speech','info','error','then','../../rpc/faxMessage','stringify','interaction','lodash','catch','stop','../../rpc/whatsappMessage','endConversation','chat','../../../../config/logger','body','apiai-promise','ChatWebsiteId','out','next'];(function(_0x33d01d,_0x47643c){const _0x4634c6=function(_0x417f0d){while(--_0x417f0d){_0x33d01d['push'](_0x33d01d['shift']());}};_0x4634c6(++_0x47643c);}(a1203_0x4764,0x151));const a1203_0x4634=function(_0x33d01d,_0x47643c){_0x33d01d=_0x33d01d-0x0;let _0x4634c6=a1203_0x4764[_0x33d01d];return _0x4634c6;};const _0x51579a=a1203_0x4634;'use strict';const _=require(_0x51579a('0x23')),moment=require(_0x51579a('0xd')),apiai=require(_0x51579a('0x2b')),md5=require('md5'),utils=require(_0x51579a('0x12')),logger=require(_0x51579a('0x29'))(_0x51579a('0x19')),rpc={'chatMessage':require(_0x51579a('0x1b')),'openchannelMessage':require(_0x51579a('0x17')),'mailMessage':require(_0x51579a('0x2')),'smsMessage':require(_0x51579a('0x18')),'faxMessage':require(_0x51579a('0x20')),'whatsappMessage':require(_0x51579a('0x26'))};exports[_0x51579a('0x11')]=function(_0x417f0d,_0x770523){return function(_0x3d46ac){const _0xa4d124=a1203_0x4634;try{if(!_[_0xa4d124('0x3')](this[_0xa4d124('0x22')][_0xa4d124('0x10')]))return logger[_0xa4d124('0x1d')](_0xa4d124('0xc'),_0x417f0d,_0xa4d124('0x0')),_0x3d46ac[_0xa4d124('0x2e')]();const _0x4ce1e5={'ContactId':this[_0xa4d124('0x16')]['id'],'sentAt':moment()[_0xa4d124('0x15')](_0xa4d124('0x4')),'direction':_0xa4d124('0x2d')},_0x418b66=this[_0xa4d124('0xf')];_0x418b66===_0xa4d124('0x28')?_0x4ce1e5[_0xa4d124('0x2c')]=this[_0xa4d124('0xa')]['id']:_0x4ce1e5[_[_0xa4d124('0x2f')](_0x418b66)+_0xa4d124('0x7')]=this[_0xa4d124('0xa')]['id'];_0x4ce1e5[_[_0xa4d124('0x2f')](_0x418b66)+_0xa4d124('0x5')]=this[_0xa4d124('0x22')]['id'];if(this[_0xa4d124('0x22')]['created']){const _0x2dbba5=_0x770523[0x2];if(!_[_0xa4d124('0x9')](_0x2dbba5))return _0x4ce1e5[_0xa4d124('0x2a')]=utils[_0xa4d124('0x8')](_0x2dbba5,this),rpc[_0x418b66+_0xa4d124('0x13')][_0xa4d124('0x14')](_0x4ce1e5)[_0xa4d124('0x1f')](function(){const _0x2ca888=_0xa4d124;logger[_0x2ca888('0x1d')](_0x2ca888('0xc'),_0x417f0d,_0x4ce1e5[_0x2ca888('0x2a')]);})[_0xa4d124('0x24')](function(_0x5bf5c9){const _0x477b48=_0xa4d124;logger[_0x477b48('0x1e')](_0x477b48('0xc'),_0x417f0d,JSON[_0x477b48('0x21')](_0x5bf5c9));})[_0xa4d124('0x1')](function(){const _0x711cc3=_0xa4d124;logger[_0x711cc3('0x1d')]('[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!',_0x417f0d),_0x3d46ac[_0x711cc3('0x25')]();});else logger[_0xa4d124('0x1d')](_0xa4d124('0x1a'),_0x417f0d),_0x3d46ac['stop']();}else{const _0x5609fc=this,_0x4cea95=apiai(_0x770523[0x0],{'language':_0x770523[0x1]||'en'});return _0x4cea95[_0xa4d124('0xe')](this[_0xa4d124('0x6')][_0xa4d124('0x2a')],{'sessionId':md5(this[_0xa4d124('0x22')]['id'])})[_0xa4d124('0x1f')](function(_0x31dcfe){const _0x18ae82=_0xa4d124;return _0x5609fc[_0x18ae82('0x2a')]['dialogflow']=_0x31dcfe,_0x4ce1e5['body']=_0x31dcfe[_0x18ae82('0xb')]['fulfillment'][_0x18ae82('0x1c')],rpc[_0x418b66+_0x18ae82('0x13')]['create'](_0x4ce1e5)[_0x18ae82('0x1f')](function(){const _0x2d7db7=_0x18ae82;logger['info'](_0x2d7db7('0xc'),_0x417f0d,_0x4ce1e5[_0x2d7db7('0x2a')]),_0x31dcfe[_0x2d7db7('0xb')]['metadata'][_0x2d7db7('0x27')]?_0x3d46ac[_0x2d7db7('0x2e')]():_0x3d46ac[_0x2d7db7('0x25')]();})[_0x18ae82('0x24')](function(_0x709cb1){const _0x4114e4=_0x18ae82;logger[_0x4114e4('0x1e')](_0x4114e4('0xc'),_0x417f0d,JSON[_0x4114e4('0x21')](_0x709cb1)),_0x3d46ac[_0x4114e4('0x2e')]();});})[_0xa4d124('0x24')](function(_0x5eadf6){const _0x555b27=_0xa4d124;logger[_0x555b27('0x1e')](_0x555b27('0xc'),_0x417f0d,_0x5eadf6['message']),_0x3d46ac[_0x555b27('0x2e')]();});}}catch(_0x1acc7b){logger[_0xa4d124('0x1e')]('[%s][DIALOGFLOW]\x20%s',_0x417f0d,JSON['stringify'](_0x1acc7b)),_0x3d46ac['stop']();}};};