Built motion from commit f738f9592c388b9f9eb3948f400a5c9d717a3561. Version 3.0.0...
[motion-next.git] / server / services / routing / server / applications / dialogflowV2.js
index bcf938f..86b62f6 100644 (file)
@@ -1 +1 @@
-const a1369_0x8271=['phone','clone','YYYY-MM-DD\x20HH:mm:ss','out','UserId','intentDetectionConfidence','error','SessionsClient','exports','message','info','lodash','end_conversation','account','[%s][DIALOGFLOWV2]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!','fields','channel','intent','projectAgentSessionPath','create','../../rpc/whatsappMessage','consequence','queryResult','../../rpc/smsMessage','boolValue','displayName','created','allRequiredParamsPresent','../../rpc/openchannelMessage','[%s][DIALOGFLOWV2]\x20Welcome\x20Message\x20has\x20been\x20sent!','../../rpc/faxMessage','detectIntent','../../rpc/chatMessage','name','dialogflowV2','../../../../config/logger','stop','contact','ChatWebsiteId','AccountId','Message','stringify','diagnosticInfo','interaction','isNil','filter','getMustacheRender','languageCode','next','@google-cloud/dialogflow','md5','fulfillmentText','sms','upperFirst','body','./utils','InteractionId','replace','[%s][DIALOGFLOWV2]\x20%s','routing','length','providerResponse'];(function(_0x1901a6,_0x26aa7){const _0x827171=function(_0x337195){while(--_0x337195){_0x1901a6['push'](_0x1901a6['shift']());}};_0x827171(++_0x26aa7);}(a1369_0x8271,0x9b));const a1369_0x3371=function(_0x1901a6,_0x26aa7){_0x1901a6=_0x1901a6-0x138;let _0x827171=a1369_0x8271[_0x1901a6];return _0x827171;};const a1369_0x20d901=a1369_0x3371;'use strict';const _=require(a1369_0x20d901(0x162)),dialogflow=require(a1369_0x20d901(0x14a)),md5=require(a1369_0x20d901(0x14b)),moment=require('moment'),logger=require(a1369_0x20d901(0x13c))(a1369_0x20d901(0x154)),utils=require(a1369_0x20d901(0x150)),rpc={'chatMessage':require(a1369_0x20d901(0x139)),'openchannelMessage':require(a1369_0x20d901(0x173)),'mailMessage':require('../../rpc/mailMessage'),'smsMessage':require(a1369_0x20d901(0x16e)),'faxMessage':require(a1369_0x20d901(0x175)),'whatsappMessage':require(a1369_0x20d901(0x16b))};async function createMessage(_0x52a9b8,_0x4d11a6,_0xf808b2,_0x346c50){const _0x2385fe=a1369_0x20d901,_0x1c814d=_[_0x2385fe(0x158)](_0xf808b2);_0x1c814d[_0x2385fe(0x14f)]=_0x346c50;try{const _0x27b170=await rpc[_0x4d11a6+'Message'][_0x2385fe(0x16a)](_0x1c814d);return logger[_0x2385fe(0x161)](_0x2385fe(0x153),_0x52a9b8,_0x27b170['body']),_0x27b170;}catch(_0x67282e){logger[_0x2385fe(0x15d)](_0x2385fe(0x153),_0x52a9b8,JSON['stringify'](_0x67282e));throw _0x67282e;}}function consequence(_0x45e194,_0x5960bd){async function _0x260051(_0x9bd924){const _0x552207=a1369_0x3371;try{if(!_[_0x552207(0x145)](this[_0x552207(0x144)][_0x552207(0x15b)]))return logger['info']('[%s][DIALOGFLOWV2]\x20%s',_0x45e194,'Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.'),_0x9bd924[_0x552207(0x149)]();let _0xbb80e0={'ContactId':this[_0x552207(0x13e)]['id'],'sentAt':moment()['format'](_0x552207(0x159)),'direction':_0x552207(0x15a)};(this[_0x552207(0x167)]===_0x552207(0x14d)||this[_0x552207(0x167)]==='whatsapp')&&(_0xbb80e0[_0x552207(0x157)]=this[_0x552207(0x144)]['phone']);const _0x187e0c=this['channel'];_0x187e0c==='chat'?_0xbb80e0[_0x552207(0x13f)]=this[_0x552207(0x164)]['id']:_0xbb80e0[_[_0x552207(0x14e)](_0x187e0c)+_0x552207(0x140)]=this[_0x552207(0x164)]['id'];_0xbb80e0[_[_0x552207(0x14e)](_0x187e0c)+_0x552207(0x151)]=this['interaction']['id'];if(this[_0x552207(0x144)][_0x552207(0x171)]){const _0x47e359=_0x5960bd[0x4];if(!_['isEmpty'](_0x47e359))try{_0xbb80e0[_0x552207(0x14f)]=utils[_0x552207(0x147)](_0x47e359,this),_0xbb80e0=await rpc[_0x187e0c+_0x552207(0x141)][_0x552207(0x16a)](_0xbb80e0),logger[_0x552207(0x161)]('[%s][DIALOGFLOWV2]\x20%s',_0x45e194,_0xbb80e0[_0x552207(0x14f)]);}catch(_0x230a3d){logger[_0x552207(0x15d)](_0x552207(0x153),_0x45e194,JSON['stringify'](_0x230a3d));}finally{logger[_0x552207(0x161)](_0x552207(0x174),_0x45e194),_0x9bd924['stop']();}else logger['info'](_0x552207(0x165),_0x45e194),_0x9bd924[_0x552207(0x13d)]();}else{const _0x5957fe=_0x5960bd[0x2][_0x552207(0x152)](/\\n/g,'\x0a'),_0x3cbe36={'credentials':{'private_key':_0x5957fe,'client_email':_0x5960bd[0x1]}},_0x5ddb3e=new dialogflow[(_0x552207(0x15e))](_0x3cbe36),_0x5c0b10=_0x5ddb3e[_0x552207(0x169)](_0x5960bd[0x0],md5(this[_0x552207(0x144)]['id'])),_0x32ec70={'session':_0x5c0b10,'queryInput':{'text':{'text':this[_0x552207(0x160)][_0x552207(0x14f)],'languageCode':_0x5960bd[0x3]||'en'}}};try{const _0x213536=await _0x5ddb3e[_0x552207(0x138)](_0x32ec70);if(_0x213536&&_0x213536[_0x552207(0x155)]){this[_0x552207(0x14f)][_0x552207(0x13b)]=_0x213536;const _0x551c83=_0x213536[0x0],_0x420bb3=_0x551c83[_0x552207(0x16d)][_0x552207(0x143)]&&_0x551c83[_0x552207(0x16d)][_0x552207(0x143)][_0x552207(0x166)]?_0x551c83['queryResult'][_0x552207(0x143)][_0x552207(0x166)][_0x552207(0x163)][_0x552207(0x16f)]:![];this[_0x552207(0x14f)]={...this[_0x552207(0x14f)],'DIALOGFLOWV2_ACTION':_0x551c83[_0x552207(0x16d)]['action'],'DIALOGFLOWV2_ALLREQUIREDPARAMSPRESENT':_0x551c83[_0x552207(0x16d)][_0x552207(0x172)],'DIALOGFLOWV2_ENDCONVERSATION':_0x551c83[_0x552207(0x16d)][_0x552207(0x143)]&&_0x551c83[_0x552207(0x16d)]['diagnosticInfo'][_0x552207(0x166)]?_0x551c83['queryResult']['diagnosticInfo'][_0x552207(0x166)][_0x552207(0x163)][_0x552207(0x16f)]:![],'DIALOGFLOWV2_INTENTNAME':_0x551c83[_0x552207(0x16d)]['intent'][_0x552207(0x13a)],'DIALOGFLOWV2_INTENTDISPLAYNAME':_0x551c83['queryResult'][_0x552207(0x168)][_0x552207(0x170)],'DIALOGFLOWV2_LANGUAGECODE':_0x551c83[_0x552207(0x16d)][_0x552207(0x148)],'DIALOGFLOWV2_QUERYTEXT':_0x551c83[_0x552207(0x16d)]['queryText'],'DIALOGFLOWV2_SCORE':_0x551c83[_0x552207(0x16d)][_0x552207(0x15c)]},_0xbb80e0['providerName']=_0x552207(0x13b),_0xbb80e0[_0x552207(0x156)]=JSON[_0x552207(0x142)](_0x213536);const _0x22344f=_0x213536['map'](_0x4bcec3=>{const _0x9dd788=_0x552207,_0x1de868=_0x4bcec3&&_0x4bcec3[_0x9dd788(0x16d)]&&_0x4bcec3['queryResult']['fulfillmentText'];return _0x1de868?createMessage(_0x45e194,_0x187e0c,_0xbb80e0,_0x4bcec3[_0x9dd788(0x16d)][_0x9dd788(0x14c)]):null;})[_0x552207(0x146)](_0x5862de=>_0x5862de!==null);await Promise['all'](_0x22344f),_0x420bb3?_0x9bd924[_0x552207(0x149)]():_0x9bd924[_0x552207(0x13d)]();}}catch(_0x3fb249){logger[_0x552207(0x15d)](_0x552207(0x153),_0x45e194,_0x3fb249[_0x552207(0x160)]),_0x9bd924[_0x552207(0x149)]();}}}catch(_0x40bcfa){logger[_0x552207(0x15d)]('[%s][DIALOGFLOWV2]\x20%s',_0x45e194,JSON[_0x552207(0x142)](_0x40bcfa)),_0x9bd924[_0x552207(0x13d)]();}}return _0x260051;}module[a1369_0x20d901(0x15f)][a1369_0x20d901(0x16c)]=consequence;
\ No newline at end of file
+const a1373_0x38e2=['Agent\x20is\x20managing\x20the\x20interaction.\x20Go\x20to\x20next\x20application.','ChatWebsiteId','AccountId','queryResult','[%s][DIALOGFLOWV2]\x20Welcome\x20Message\x20has\x20been\x20sent!','created','end_conversation','md5','exports','consequence','moment','languageCode','UserId','whatsapp','Message','phone','providerName','out','isNil','error','../../rpc/smsMessage','../../rpc/chatMessage','../../rpc/mailMessage','YYYY-MM-DD\x20HH:mm:ss','fields','chat','lodash','name','sms','detectIntent','intent','boolValue','interaction','dialogflowV2','../../rpc/openchannelMessage','queryText','@google-cloud/dialogflow','filter','info','../../rpc/whatsappMessage','clone','routing','contact','stop','displayName','account','fulfillmentText','stringify','[%s][DIALOGFLOWV2]\x20%s','upperFirst','create','../../../../config/logger','channel','message','getMustacheRender','./utils','body','projectAgentSessionPath','replace','diagnosticInfo','next','action','providerResponse','isEmpty','format','map','../../rpc/faxMessage'];(function(_0x361b4a,_0x68b769){const _0x38e2c2=function(_0x1fa5e4){while(--_0x1fa5e4){_0x361b4a['push'](_0x361b4a['shift']());}};_0x38e2c2(++_0x68b769);}(a1373_0x38e2,0x13d));const a1373_0x1fa5=function(_0x361b4a,_0x68b769){_0x361b4a=_0x361b4a-0xa8;let _0x38e2c2=a1373_0x38e2[_0x361b4a];return _0x38e2c2;};const a1373_0x156a4b=a1373_0x1fa5;'use strict';const _=require(a1373_0x156a4b(0xd4)),dialogflow=require(a1373_0x156a4b(0xde)),md5=require(a1373_0x156a4b(0xc1)),moment=require(a1373_0x156a4b(0xc4)),logger=require(a1373_0x156a4b(0xaa))(a1373_0x156a4b(0xe3)),utils=require(a1373_0x156a4b(0xae)),rpc={'chatMessage':require(a1373_0x156a4b(0xcf)),'openchannelMessage':require(a1373_0x156a4b(0xdc)),'mailMessage':require(a1373_0x156a4b(0xd0)),'smsMessage':require(a1373_0x156a4b(0xce)),'faxMessage':require(a1373_0x156a4b(0xb9)),'whatsappMessage':require(a1373_0x156a4b(0xe1))};async function createMessage(_0x5bf109,_0x197cbe,_0x4f34b4,_0x5ca33a){const _0x475978=a1373_0x156a4b,_0x5c72a4=_[_0x475978(0xe2)](_0x4f34b4);_0x5c72a4[_0x475978(0xaf)]=_0x5ca33a;try{const _0x702b50=await rpc[_0x197cbe+_0x475978(0xc8)][_0x475978(0xa9)](_0x5c72a4);return logger[_0x475978(0xe0)](_0x475978(0xea),_0x5bf109,_0x702b50['body']),_0x702b50;}catch(_0x2a0f48){logger['error'](_0x475978(0xea),_0x5bf109,JSON['stringify'](_0x2a0f48));throw _0x2a0f48;}}function consequence(_0x16db4a,_0x5e3429){async function _0x3f3f01(_0x125ceb){const _0x23546a=a1373_0x1fa5;try{if(!_[_0x23546a(0xcc)](this[_0x23546a(0xda)][_0x23546a(0xc6)]))return logger[_0x23546a(0xe0)]('[%s][DIALOGFLOWV2]\x20%s',_0x16db4a,_0x23546a(0xba)),_0x125ceb[_0x23546a(0xb3)]();let _0x105c40={'ContactId':this[_0x23546a(0xe4)]['id'],'sentAt':moment()[_0x23546a(0xb7)](_0x23546a(0xd1)),'direction':_0x23546a(0xcb)};(this[_0x23546a(0xab)]===_0x23546a(0xd6)||this[_0x23546a(0xab)]===_0x23546a(0xc7))&&(_0x105c40[_0x23546a(0xc9)]=this[_0x23546a(0xda)][_0x23546a(0xc9)]);const _0xcb1036=this[_0x23546a(0xab)];_0xcb1036===_0x23546a(0xd3)?_0x105c40[_0x23546a(0xbb)]=this[_0x23546a(0xe7)]['id']:_0x105c40[_[_0x23546a(0xa8)](_0xcb1036)+_0x23546a(0xbc)]=this[_0x23546a(0xe7)]['id'];_0x105c40[_[_0x23546a(0xa8)](_0xcb1036)+'InteractionId']=this[_0x23546a(0xda)]['id'];if(this[_0x23546a(0xda)][_0x23546a(0xbf)]){const _0x35eb72=_0x5e3429[0x4];if(!_[_0x23546a(0xb6)](_0x35eb72))try{_0x105c40[_0x23546a(0xaf)]=utils[_0x23546a(0xad)](_0x35eb72,this),_0x105c40=await rpc[_0xcb1036+_0x23546a(0xc8)][_0x23546a(0xa9)](_0x105c40),logger[_0x23546a(0xe0)](_0x23546a(0xea),_0x16db4a,_0x105c40[_0x23546a(0xaf)]);}catch(_0x531b8f){logger[_0x23546a(0xcd)]('[%s][DIALOGFLOWV2]\x20%s',_0x16db4a,JSON['stringify'](_0x531b8f));}finally{logger[_0x23546a(0xe0)](_0x23546a(0xbe),_0x16db4a),_0x125ceb[_0x23546a(0xe5)]();}else logger[_0x23546a(0xe0)]('[%s][DIALOGFLOWV2]\x20Welcome\x20Message\x20is\x20empty.\x20It\x20will\x20wait\x20for\x20a\x20message\x20from\x20customer!',_0x16db4a),_0x125ceb[_0x23546a(0xe5)]();}else{const _0x428c0b=_0x5e3429[0x2][_0x23546a(0xb1)](/\\n/g,'\x0a'),_0x51dcfa={'credentials':{'private_key':_0x428c0b,'client_email':_0x5e3429[0x1]}},_0x40a49f=new dialogflow['SessionsClient'](_0x51dcfa),_0x7f5d4c=_0x40a49f[_0x23546a(0xb0)](_0x5e3429[0x0],md5(this['interaction']['id'])),_0x17025b={'session':_0x7f5d4c,'queryInput':{'text':{'text':this[_0x23546a(0xac)][_0x23546a(0xaf)],'languageCode':_0x5e3429[0x3]||'en'}}};try{const _0x5a8066=await _0x40a49f[_0x23546a(0xd7)](_0x17025b);if(_0x5a8066&&_0x5a8066['length']){this[_0x23546a(0xaf)][_0x23546a(0xdb)]=_0x5a8066;const _0x459daf=_0x5a8066[0x0],_0x44de05=_0x459daf['queryResult'][_0x23546a(0xb2)]&&_0x459daf[_0x23546a(0xbd)][_0x23546a(0xb2)][_0x23546a(0xd2)]?_0x459daf[_0x23546a(0xbd)]['diagnosticInfo'][_0x23546a(0xd2)][_0x23546a(0xc0)][_0x23546a(0xd9)]:![];this['body']={...this['body'],'DIALOGFLOWV2_ACTION':_0x459daf[_0x23546a(0xbd)][_0x23546a(0xb4)],'DIALOGFLOWV2_ALLREQUIREDPARAMSPRESENT':_0x459daf[_0x23546a(0xbd)]['allRequiredParamsPresent'],'DIALOGFLOWV2_ENDCONVERSATION':_0x459daf[_0x23546a(0xbd)][_0x23546a(0xb2)]&&_0x459daf[_0x23546a(0xbd)]['diagnosticInfo'][_0x23546a(0xd2)]?_0x459daf[_0x23546a(0xbd)][_0x23546a(0xb2)][_0x23546a(0xd2)][_0x23546a(0xc0)]['boolValue']:![],'DIALOGFLOWV2_INTENTNAME':_0x459daf['queryResult'][_0x23546a(0xd8)][_0x23546a(0xd5)],'DIALOGFLOWV2_INTENTDISPLAYNAME':_0x459daf['queryResult'][_0x23546a(0xd8)][_0x23546a(0xe6)],'DIALOGFLOWV2_LANGUAGECODE':_0x459daf[_0x23546a(0xbd)][_0x23546a(0xc5)],'DIALOGFLOWV2_QUERYTEXT':_0x459daf['queryResult'][_0x23546a(0xdd)],'DIALOGFLOWV2_SCORE':_0x459daf[_0x23546a(0xbd)]['intentDetectionConfidence']},_0x105c40[_0x23546a(0xca)]='dialogflowV2',_0x105c40[_0x23546a(0xb5)]=JSON[_0x23546a(0xe9)](_0x5a8066);const _0x1a2a94=_0x5a8066[_0x23546a(0xb8)](_0x19f870=>{const _0xe8028=_0x23546a,_0x2d4f90=_0x19f870&&_0x19f870[_0xe8028(0xbd)]&&_0x19f870['queryResult'][_0xe8028(0xe8)];return _0x2d4f90?createMessage(_0x16db4a,_0xcb1036,_0x105c40,_0x19f870[_0xe8028(0xbd)][_0xe8028(0xe8)]):null;})[_0x23546a(0xdf)](_0x216d78=>_0x216d78!==null);await Promise['all'](_0x1a2a94),_0x44de05?_0x125ceb[_0x23546a(0xb3)]():_0x125ceb[_0x23546a(0xe5)]();}}catch(_0x2632a5){logger[_0x23546a(0xcd)](_0x23546a(0xea),_0x16db4a,_0x2632a5[_0x23546a(0xac)]),_0x125ceb['next']();}}}catch(_0x5308bc){logger[_0x23546a(0xcd)](_0x23546a(0xea),_0x16db4a,JSON['stringify'](_0x5308bc)),_0x125ceb['stop']();}}return _0x3f3f01;}module[a1373_0x156a4b(0xc2)][a1373_0x156a4b(0xc3)]=consequence;
\ No newline at end of file