Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / services / routing / server / applications / dialogflow.js
index 22e8509..1cc777b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc1fc=['../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','isNil','interaction','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','contact','format','YYYY-MM-DD\x20HH:mm:ss','out','channel','sms','whatsapp','phone','chat','account','upperFirst','AccountId','InteractionId','created','getMustacheRender','Message','create','body','catch','error','[%s][DIALOGFLOW]\x20%s','stringify','finally','info','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!','stop','textRequest','then','dialogflow','fulfillment','speech','providerName','providerResponse','result','metadata','message','moment','apiai-promise','./utils'];(function(_0x4775da,_0x1fc72a){var _0x1352ab=function(_0x345b76){while(--_0x345b76){_0x4775da['push'](_0x4775da['shift']());}};_0x1352ab(++_0x1fc72a);}(_0xc1fc,0x93));var _0xcc1f=function(_0x59b86f,_0x58a8d7){_0x59b86f=_0x59b86f-0x0;var _0x35d545=_0xc1fc[_0x59b86f];return _0x35d545;};'use strict';var _=require('lodash');var moment=require(_0xcc1f('0x0'));var apiai=require(_0xcc1f('0x1'));var md5=require('md5');var utils=require(_0xcc1f('0x2'));var logger=require(_0xcc1f('0x3'))(_0xcc1f('0x4'));var rpc={'chatMessage':require(_0xcc1f('0x5')),'openchannelMessage':require(_0xcc1f('0x6')),'mailMessage':require(_0xcc1f('0x7')),'smsMessage':require(_0xcc1f('0x8')),'faxMessage':require(_0xcc1f('0x9')),'whatsappMessage':require('../../rpc/whatsappMessage')};exports['consequence']=function(_0x376348,_0x4516e3){return function(_0x431ca8){try{if(!_[_0xcc1f('0xa')](this[_0xcc1f('0xb')]['UserId'])){logger['info']('[%s][DIALOGFLOW]\x20%s',_0x376348,_0xcc1f('0xc'));return _0x431ca8[_0xcc1f('0xd')]();}var _0x256283={'ContactId':this[_0xcc1f('0xe')]['id'],'sentAt':moment()[_0xcc1f('0xf')](_0xcc1f('0x10')),'direction':_0xcc1f('0x11')};if(this[_0xcc1f('0x12')]===_0xcc1f('0x13')||this['channel']===_0xcc1f('0x14')){_0x256283[_0xcc1f('0x15')]=this[_0xcc1f('0xb')][_0xcc1f('0x15')];}var _0x9842de=this[_0xcc1f('0x12')];if(_0x9842de===_0xcc1f('0x16')){_0x256283['ChatWebsiteId']=this[_0xcc1f('0x17')]['id'];}else{_0x256283[_[_0xcc1f('0x18')](_0x9842de)+_0xcc1f('0x19')]=this[_0xcc1f('0x17')]['id'];}_0x256283[_[_0xcc1f('0x18')](_0x9842de)+_0xcc1f('0x1a')]=this[_0xcc1f('0xb')]['id'];if(this[_0xcc1f('0xb')][_0xcc1f('0x1b')]){var _0x7bad52=_0x4516e3[0x2];if(!_['isEmpty'](_0x7bad52)){_0x256283['body']=utils[_0xcc1f('0x1c')](_0x7bad52,this);return rpc[_0x9842de+_0xcc1f('0x1d')][_0xcc1f('0x1e')](_0x256283)['then'](function(_0x314d9d){logger['info']('[%s][DIALOGFLOW]\x20%s',_0x376348,_0x256283[_0xcc1f('0x1f')]);})[_0xcc1f('0x20')](function(_0x5ed11c){logger[_0xcc1f('0x21')](_0xcc1f('0x22'),_0x376348,JSON[_0xcc1f('0x23')](_0x5ed11c));})[_0xcc1f('0x24')](function(){logger[_0xcc1f('0x25')](_0xcc1f('0x26'),_0x376348);_0x431ca8['stop']();});}else{logger[_0xcc1f('0x25')]('[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!',_0x376348);_0x431ca8[_0xcc1f('0x27')]();}}else{var _0x310c2e=this;var _0x1a00d4=apiai(_0x4516e3[0x0],{'language':_0x4516e3[0x1]||'en'});return _0x1a00d4[_0xcc1f('0x28')](this['message'][_0xcc1f('0x1f')],{'sessionId':md5(this[_0xcc1f('0xb')]['id'])})[_0xcc1f('0x29')](function(_0x257e7f){_0x310c2e[_0xcc1f('0x1f')][_0xcc1f('0x2a')]=_0x257e7f;_0x256283[_0xcc1f('0x1f')]=_0x257e7f['result'][_0xcc1f('0x2b')][_0xcc1f('0x2c')];_0x256283[_0xcc1f('0x2d')]=_0xcc1f('0x2a');_0x256283[_0xcc1f('0x2e')]=JSON[_0xcc1f('0x23')](_0x257e7f);return rpc[_0x9842de+_0xcc1f('0x1d')][_0xcc1f('0x1e')](_0x256283)['then'](function(_0x4461d5){logger[_0xcc1f('0x25')](_0xcc1f('0x22'),_0x376348,_0x256283[_0xcc1f('0x1f')]);if(_0x257e7f[_0xcc1f('0x2f')][_0xcc1f('0x30')]['endConversation']){_0x431ca8[_0xcc1f('0xd')]();}else{_0x431ca8[_0xcc1f('0x27')]();}})['catch'](function(_0x3bd35c){logger['error'](_0xcc1f('0x22'),_0x376348,JSON[_0xcc1f('0x23')](_0x3bd35c));_0x431ca8[_0xcc1f('0xd')]();});})[_0xcc1f('0x20')](function(_0x54211b){logger['error'](_0xcc1f('0x22'),_0x376348,_0x54211b[_0xcc1f('0x31')]);_0x431ca8[_0xcc1f('0xd')]();});}}catch(_0x53220d){logger[_0xcc1f('0x21')](_0xcc1f('0x22'),_0x376348,JSON[_0xcc1f('0x23')](_0x53220d));_0x431ca8['stop']();}};};
\ No newline at end of file
+var _0x31af=['info','Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','next','contact','format','out','channel','sms','phone','chat','ChatWebsiteId','account','upperFirst','AccountId','InteractionId','created','isEmpty','getMustacheRender','Message','create','then','[%s][DIALOGFLOW]\x20%s','body','catch','stringify','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20has\x20been\x20sent!','[%s][DIALOGFLOW]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','textRequest','message','result','fulfillment','endConversation','error','stop','lodash','moment','apiai-promise','../../../../config/logger','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/whatsappMessage','consequence','isNil','interaction','UserId'];(function(_0x3ebe02,_0x1d0d72){var _0x9e3bda=function(_0x3b4434){while(--_0x3b4434){_0x3ebe02['push'](_0x3ebe02['shift']());}};_0x9e3bda(++_0x1d0d72);}(_0x31af,0xde));var _0xf31a=function(_0x3395b1,_0x3dc307){_0x3395b1=_0x3395b1-0x0;var _0x5836b3=_0x31af[_0x3395b1];return _0x5836b3;};'use strict';var _=require(_0xf31a('0x0'));var moment=require(_0xf31a('0x1'));var apiai=require(_0xf31a('0x2'));var md5=require('md5');var utils=require('./utils');var logger=require(_0xf31a('0x3'))('routing');var rpc={'chatMessage':require(_0xf31a('0x4')),'openchannelMessage':require(_0xf31a('0x5')),'mailMessage':require(_0xf31a('0x6')),'smsMessage':require(_0xf31a('0x7')),'faxMessage':require('../../rpc/faxMessage'),'whatsappMessage':require(_0xf31a('0x8'))};exports[_0xf31a('0x9')]=function(_0x405926,_0x1dc7cc){return function(_0x47b7a1){try{if(!_[_0xf31a('0xa')](this[_0xf31a('0xb')][_0xf31a('0xc')])){logger[_0xf31a('0xd')]('[%s][DIALOGFLOW]\x20%s',_0x405926,_0xf31a('0xe'));return _0x47b7a1[_0xf31a('0xf')]();}var _0xcff55c={'ContactId':this[_0xf31a('0x10')]['id'],'sentAt':moment()[_0xf31a('0x11')]('YYYY-MM-DD\x20HH:mm:ss'),'direction':_0xf31a('0x12')};if(this[_0xf31a('0x13')]===_0xf31a('0x14')||this[_0xf31a('0x13')]==='whatsapp'){_0xcff55c[_0xf31a('0x15')]=this[_0xf31a('0xb')]['phone'];}var _0x355f32=this[_0xf31a('0x13')];if(_0x355f32===_0xf31a('0x16')){_0xcff55c[_0xf31a('0x17')]=this[_0xf31a('0x18')]['id'];}else{_0xcff55c[_[_0xf31a('0x19')](_0x355f32)+_0xf31a('0x1a')]=this[_0xf31a('0x18')]['id'];}_0xcff55c[_[_0xf31a('0x19')](_0x355f32)+_0xf31a('0x1b')]=this[_0xf31a('0xb')]['id'];if(this[_0xf31a('0xb')][_0xf31a('0x1c')]){var _0xccfd8b=_0x1dc7cc[0x2];if(!_[_0xf31a('0x1d')](_0xccfd8b)){_0xcff55c['body']=utils[_0xf31a('0x1e')](_0xccfd8b,this);return rpc[_0x355f32+_0xf31a('0x1f')][_0xf31a('0x20')](_0xcff55c)[_0xf31a('0x21')](function(_0x4c3589){logger[_0xf31a('0xd')](_0xf31a('0x22'),_0x405926,_0xcff55c[_0xf31a('0x23')]);})[_0xf31a('0x24')](function(_0x18a97c){logger['error'](_0xf31a('0x22'),_0x405926,JSON[_0xf31a('0x25')](_0x18a97c));})['finally'](function(){logger[_0xf31a('0xd')](_0xf31a('0x26'),_0x405926);_0x47b7a1['stop']();});}else{logger[_0xf31a('0xd')](_0xf31a('0x27'),_0x405926);_0x47b7a1['stop']();}}else{var _0x5724b3=this;var _0x534317=apiai(_0x1dc7cc[0x0],{'language':_0x1dc7cc[0x1]||'en'});return _0x534317[_0xf31a('0x28')](this[_0xf31a('0x29')]['body'],{'sessionId':md5(this[_0xf31a('0xb')]['id'])})[_0xf31a('0x21')](function(_0x5d08ee){_0x5724b3[_0xf31a('0x23')]['dialogflow']=_0x5d08ee;_0xcff55c['body']=_0x5d08ee[_0xf31a('0x2a')][_0xf31a('0x2b')]['speech'];_0xcff55c['providerName']='dialogflow';_0xcff55c['providerResponse']=JSON[_0xf31a('0x25')](_0x5d08ee);return rpc[_0x355f32+_0xf31a('0x1f')][_0xf31a('0x20')](_0xcff55c)['then'](function(_0x2281c5){logger[_0xf31a('0xd')](_0xf31a('0x22'),_0x405926,_0xcff55c[_0xf31a('0x23')]);if(_0x5d08ee[_0xf31a('0x2a')]['metadata'][_0xf31a('0x2c')]){_0x47b7a1[_0xf31a('0xf')]();}else{_0x47b7a1['stop']();}})['catch'](function(_0x203f28){logger[_0xf31a('0x2d')]('[%s][DIALOGFLOW]\x20%s',_0x405926,JSON[_0xf31a('0x25')](_0x203f28));_0x47b7a1[_0xf31a('0xf')]();});})[_0xf31a('0x24')](function(_0x5385ba){logger[_0xf31a('0x2d')](_0xf31a('0x22'),_0x405926,_0x5385ba[_0xf31a('0x29')]);_0x47b7a1[_0xf31a('0xf')]();});}}catch(_0xbddc3b){logger[_0xf31a('0x2d')]('[%s][DIALOGFLOW]\x20%s',_0x405926,JSON[_0xf31a('0x25')](_0xbddc3b));_0x47b7a1[_0xf31a('0x2e')]();}};};
\ No newline at end of file