Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / services / ami / trigger / integration / freshdesk.js
index 3ea1395..7fb331b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x72cf=['Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','Authorization','The\x20User\x20ID\x20is:','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','trigger:browser:url','%s/helpdesk/tickets/%d','error','outbound','recordingFormat','none','destcalleridname','destcalleridnum','catch','abandoned','[ABANDONED]','lodash','request-promise','md5','util','../../../../config/environment','../../../../config/logger','freshdesk','redis','defaults','socket.io-emitter','application/json','emit','info','Creating\x20new\x20ticket...','format','calleridname','calleridnum','getString','Subjects','Descriptions','<br>','Tags','name','Fields','custom_fields','mapValues','keyBy','value','remoteUri','Ticket\x20created!','validateEmail','%s/api/v2/agents','then','length','find','email','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!','Admin\x20account\x20selected.','Searching\x20enduser\x20with\x20phone','%s/api/v2/contacts','Enduser\x20found!','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','Enduser\x20created.','Basic\x20%s','apiKey','toString','debug','[HTTP]','stringify','GET','map','forEach','type','string','customField','nameField','content','idField','push','variableName','Variable','toLowerCase','queue','stripTrailingSlash','serverUrl','monitor_format','[QUEUE]'];(function(_0x13d07a,_0x41efc3){var _0x5ee0ee=function(_0x4ca94a){while(--_0x4ca94a){_0x13d07a['push'](_0x13d07a['shift']());}};_0x5ee0ee(++_0x41efc3);}(_0x72cf,0x1d2));var _0xf72c=function(_0x394fbc,_0xa36212){_0x394fbc=_0x394fbc-0x0;var _0x4ee2d1=_0x72cf[_0x394fbc];return _0x4ee2d1;};'use strict';var _=require(_0xf72c('0x0'));var rp=require(_0xf72c('0x1'));var md5=require(_0xf72c('0x2'));var util=require(_0xf72c('0x3'));var Redis=require('ioredis');var intUtil=require('./util');var config=require(_0xf72c('0x4'));var logger=require(_0xf72c('0x5'))(_0xf72c('0x6'));config[_0xf72c('0x7')]=_[_0xf72c('0x8')](config[_0xf72c('0x7')],{'host':'localhost','port':0x18eb});var io=require(_0xf72c('0x9'))(new Redis(config[_0xf72c('0x7')]));var headers={'Content-Type':_0xf72c('0xa'),'Accept':_0xf72c('0xa')};function emit(_0x2a2d7f,_0xb38bcb,_0x57b7f1){io['to'](_0x2a2d7f)[_0xf72c('0xb')](_0xb38bcb,_0x57b7f1);}function getTicket(_0x6b36e8,_0x2b9d20,_0x182d72,_0x89af3d,_0x1c8cd6){logger[_0xf72c('0xc')](_0xf72c('0xd'));var _0xd3732b=_['merge']({'responder_id':_0x2b9d20['id'],'requester_id':_0x182d72['id'],'name':util[_0xf72c('0xe')]('Caller\x20-\x20%s',_0x1c8cd6[_0xf72c('0xf')]),'phone':_0x1c8cd6[_0xf72c('0x10')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0xf72c('0x11')](_0x89af3d[_0xf72c('0x12')],_0x1c8cd6,'\x20'),'description':intUtil[_0xf72c('0x11')](_0x89af3d[_0xf72c('0x13')],_0x1c8cd6,_0xf72c('0x14')),'tags':getTags(_0x89af3d[_0xf72c('0x15')],_0xf72c('0x16'))},getCustomFields(_0x89af3d[_0xf72c('0x17')],_0x1c8cd6));_0xd3732b[_0xf72c('0x18')]=_[_0xf72c('0x19')](_[_0xf72c('0x1a')](_0xd3732b[_0xf72c('0x18')],'id'),_0xf72c('0x1b'));return request({'uri':util[_0xf72c('0xe')]('%s/api/v2/tickets',_0x6b36e8[_0xf72c('0x1c')]),'method':'POST','body':_0xd3732b})['then'](function(_0x5b65f2){logger['info'](_0xf72c('0x1d'));return _0x5b65f2;});}function getUser(_0x297371,_0x53344f){if(intUtil[_0xf72c('0x1e')](_0x53344f)){return request({'uri':util['format'](_0xf72c('0x1f'),_0x297371['remoteUri']),'qs':{'email':_0x53344f}})[_0xf72c('0x20')](function(_0x4f41cb){if(_0x4f41cb[_0xf72c('0x21')]){logger[_0xf72c('0xc')]('Agent\x20found!');return _[_0xf72c('0x22')](_0x4f41cb,function(_0x47481e){return _0x47481e['contact'][_0xf72c('0x23')]===_0x53344f;});}else{logger['info'](_0xf72c('0x24'));return request({'uri':util[_0xf72c('0xe')]('%s/api/v2/agents/me',_0x297371[_0xf72c('0x1c')])})[_0xf72c('0x20')](function(_0x391784){logger[_0xf72c('0xc')]('Admin\x20account\x20selected.');return _0x391784;});}});}else{logger[_0xf72c('0xc')](_0xf72c('0x25'));return request({'uri':util[_0xf72c('0xe')]('%s/api/v2/agents/me',_0x297371[_0xf72c('0x1c')])})[_0xf72c('0x20')](function(_0x174644){logger[_0xf72c('0xc')](_0xf72c('0x26'));return _0x174644;});}}function getEndUser(_0x57756c,_0xa24a73,_0x500fb3){logger['info'](_0xf72c('0x27'),_0x500fb3);return request({'uri':util[_0xf72c('0xe')](_0xf72c('0x28'),_0x57756c['remoteUri']),'qs':{'phone':_0x500fb3}})[_0xf72c('0x20')](function(_0x40345e){if(_0x40345e['length']){logger[_0xf72c('0xc')](_0xf72c('0x29'));return _[_0xf72c('0x22')](_0x40345e,{'phone':_0x500fb3});}else{logger[_0xf72c('0xc')](_0xf72c('0x2a'));return request({'uri':util[_0xf72c('0xe')](_0xf72c('0x28'),_0x57756c['remoteUri']),'method':'POST','body':{'name':_0xa24a73,'phone':_0x500fb3}})[_0xf72c('0x20')](function(_0x56c9fe){logger[_0xf72c('0xc')](_0xf72c('0x2b'));return _0x56c9fe;});}});}function getAuth(_0xc81c53){return util[_0xf72c('0xe')](_0xf72c('0x2c'),new Buffer(_0xc81c53[_0xf72c('0x2d')]+':X')[_0xf72c('0x2e')]('base64'));}function request(_0x17691e){logger[_0xf72c('0x2f')](_0xf72c('0x30'),JSON[_0xf72c('0x31')](_0x17691e));return rp(_['defaults'](_0x17691e,{'method':_0xf72c('0x32'),'headers':headers,'json':!![]}));}function getTags(_0x421f89,_0x425227){var _0x591152=[];if(_0x421f89&&_0x421f89[_0xf72c('0x21')]>0x0){_0x591152=_[_0xf72c('0x33')](_0x421f89,_0x425227);}return _0x591152;}function getCustomFields(_0x9ef7d1,_0x555707){var _0x20f649=[];var _0x3dd98f={'custom_fields':[]};if(_0x9ef7d1[_0xf72c('0x21')]>0x0){_[_0xf72c('0x34')](_0x9ef7d1,function(_0x465297){if(_0x465297[_0xf72c('0x35')]===_0xf72c('0x36')&&_0x465297['nameField']&&!_0x465297[_0xf72c('0x37')]){_0x3dd98f[_0x465297[_0xf72c('0x38')]['toLowerCase']()]=_0x465297[_0xf72c('0x39')]['toString']();}else if(_0x465297[_0xf72c('0x35')]==='string'&&_0x465297[_0xf72c('0x3a')]&&_0x465297[_0xf72c('0x37')]){_0x3dd98f['custom_fields'][_0xf72c('0x3b')]({'id':_0x465297['idField'],'value':_0x465297[_0xf72c('0x39')][_0xf72c('0x2e')]()});}else if(_0x465297[_0xf72c('0x35')]==='variable'&&_0x465297[_0xf72c('0x3c')]&&_0x465297['idField']&&_0x465297[_0xf72c('0x37')]){_0x555707[_0x465297[_0xf72c('0x3c')]]&&_0x3dd98f[_0xf72c('0x18')][_0xf72c('0x3b')]({'id':_0x465297[_0xf72c('0x3a')],'value':_0x555707[_0x465297[_0xf72c('0x3c')]]['toString']()});}else if(_0x465297[_0xf72c('0x35')]==='customVariable'&&_0x465297[_0xf72c('0x3d')]&&_0x465297[_0xf72c('0x3d')][_0xf72c('0x16')]&&_0x465297['idField']&&_0x465297[_0xf72c('0x37')]){_0x555707[_0x465297[_0xf72c('0x3d')][_0xf72c('0x16')]['toLowerCase']()]&&_0x3dd98f[_0xf72c('0x18')][_0xf72c('0x3b')]({'id':_0x465297[_0xf72c('0x3a')],'value':_0x555707[_0x465297[_0xf72c('0x3d')][_0xf72c('0x16')][_0xf72c('0x3e')]()][_0xf72c('0x2e')]()});}});}return _0x3dd98f;}exports[_0xf72c('0x3f')]=function(_0x2343a5,_0x30a418,_0x46ce0a,_0x1bbc94,_0x4efb1c,_0x26c174){var _0xd5281c,_0x1947be;_0x26c174[_0xf72c('0x1c')]=intUtil[_0xf72c('0x40')](_0x26c174[_0xf72c('0x1c')]);_0x26c174[_0xf72c('0x41')]=intUtil[_0xf72c('0x40')](_0x26c174['serverUrl']);if(_0x4efb1c&&_0x4efb1c[_0xf72c('0x42')]){logger[_0xf72c('0xc')](_0xf72c('0x43'),_0xf72c('0x44'));_0x30a418[_0xf72c('0x45')]=util[_0xf72c('0xe')](_0xf72c('0x46'),_0x26c174[_0xf72c('0x41')],_0x30a418[_0xf72c('0x47')],md5(_0x30a418[_0xf72c('0x47')]));}else{_0x30a418['recordingURL']='';}headers[_0xf72c('0x48')]=getAuth(_0x26c174);return getUser(_0x26c174,_0x1bbc94['email'])[_0xf72c('0x20')](function(_0x198228){_0xd5281c=_0x198228;logger[_0xf72c('0xc')](_0xf72c('0x49'),_0xd5281c['id']);return getEndUser(_0x26c174,_0x30a418[_0xf72c('0xf')],_0x30a418[_0xf72c('0x10')]);})[_0xf72c('0x20')](function(_0x1e76ba){_0x1947be=_0x1e76ba;logger[_0xf72c('0xc')](_0xf72c('0x4a'),_0x1947be['id']);return getTicket(_0x26c174,_0xd5281c,_0x1947be,_0x46ce0a,_0x30a418);})['then'](function(_0x986ace){if(_0x986ace&&_0x986ace['id']){logger[_0xf72c('0xc')]('Ticket\x20created!');logger[_0xf72c('0xc')](_0xf72c('0x4b'),_0x986ace['id']);logger[_0xf72c('0xc')]('[QUEUE]',_0xf72c('0x4c'));emit(util[_0xf72c('0xe')](_0xf72c('0x4d'),_0x1bbc94[_0xf72c('0x16')]),_0xf72c('0x4e'),{'uri':util[_0xf72c('0xe')](_0xf72c('0x4f'),_0x26c174[_0xf72c('0x1c')],_0x986ace['id'])});}})['catch'](function(_0x5821a2){logger[_0xf72c('0x50')](_0xf72c('0x43'),JSON['stringify'](_0x5821a2));});};exports[_0xf72c('0x51')]=function(_0x2c1566,_0x40d0c0,_0x419f46,_0x558e55,_0x175587,_0x21be5a,_0x2a16b3){var _0x3ae001,_0x247226;_0x21be5a[_0xf72c('0x1c')]=intUtil[_0xf72c('0x40')](_0x21be5a[_0xf72c('0x1c')]);_0x21be5a['serverUrl']=intUtil[_0xf72c('0x40')](_0x21be5a[_0xf72c('0x41')]);if(_0x2a16b3&&_0x2a16b3[_0xf72c('0x52')]&&_0x2a16b3[_0xf72c('0x52')]!==_0xf72c('0x53')){logger[_0xf72c('0xc')]('[OUTBOUND]',_0xf72c('0x44'));_0x40d0c0['recordingURL']=util[_0xf72c('0xe')](_0xf72c('0x46'),_0x21be5a[_0xf72c('0x41')],_0x40d0c0[_0xf72c('0x47')],md5(_0x40d0c0[_0xf72c('0x47')]));}headers['Authorization']=getAuth(_0x21be5a);return getUser(_0x21be5a,_0x558e55['email'])[_0xf72c('0x20')](function(_0x52d271){_0x3ae001=_0x52d271;logger[_0xf72c('0xc')](_0xf72c('0x49'),_0x3ae001['id']);return getEndUser(_0x21be5a,_0x40d0c0[_0xf72c('0x54')],_0x40d0c0[_0xf72c('0x55')]);})['then'](function(_0x151652){_0x247226=_0x151652;logger[_0xf72c('0xc')](_0xf72c('0x4a'),_0x247226['id']);return getTicket(_0x21be5a,_0x3ae001,_0x247226,_0x419f46,_0x40d0c0);})[_0xf72c('0x20')](function(_0x525366){if(_0x525366&&_0x525366['id']){logger[_0xf72c('0xc')](_0xf72c('0x1d'));logger['info']('The\x20Ticket\x20ID\x20is:',_0x525366['id']);logger['info']('[OUTBOUND]',_0xf72c('0x4c'));emit(util[_0xf72c('0xe')](_0xf72c('0x4d'),_0x558e55[_0xf72c('0x16')]),_0xf72c('0x4e'),{'uri':util['format'](_0xf72c('0x4f'),_0x21be5a['remoteUri'],_0x525366['id'])});}})[_0xf72c('0x56')](function(_0x2f55ee){logger[_0xf72c('0x50')]('[OUTBOUND]',JSON['stringify'](_0x2f55ee));});};exports[_0xf72c('0x57')]=function(_0x4a4e90,_0x44d98f,_0x28bbf2,_0x48d3f2,_0x325866,_0x57a956){var _0x4dd134,_0x21cf8a;_0x57a956['remoteUri']=intUtil[_0xf72c('0x40')](_0x57a956[_0xf72c('0x1c')]);_0x57a956[_0xf72c('0x41')]=intUtil[_0xf72c('0x40')](_0x57a956[_0xf72c('0x41')]);if(_0x325866&&_0x325866[_0xf72c('0x42')]){logger[_0xf72c('0xc')](_0xf72c('0x58'),_0xf72c('0x44'));_0x44d98f['recordingURL']=util[_0xf72c('0xe')](_0xf72c('0x46'),_0x57a956[_0xf72c('0x41')],_0x44d98f[_0xf72c('0x47')],md5(_0x44d98f[_0xf72c('0x47')]));}else{_0x44d98f[_0xf72c('0x45')]='';}headers[_0xf72c('0x48')]=getAuth(_0x57a956);return getUser(_0x57a956,'')['then'](function(_0x22b19b){_0x4dd134=_0x22b19b;logger[_0xf72c('0xc')](_0xf72c('0x49'),_0x4dd134['id']);return getEndUser(_0x57a956,_0x44d98f[_0xf72c('0xf')],_0x44d98f[_0xf72c('0x10')]);})['then'](function(_0x388223){_0x21cf8a=_0x388223;logger[_0xf72c('0xc')](_0xf72c('0x4a'),_0x21cf8a['id']);return getTicket(_0x57a956,_0x4dd134,_0x21cf8a,_0x28bbf2,_0x44d98f);})[_0xf72c('0x20')](function(_0x3bc746){if(_0x3bc746){logger['info']('Ticket\x20created!');logger['info']('The\x20Ticket\x20ID\x20is:',_0x3bc746['id']);}})[_0xf72c('0x56')](function(_0x2c867e){logger[_0xf72c('0x50')]('[ABANDONED]',JSON[_0xf72c('0x31')](_0x2c867e));});};
\ No newline at end of file
+var _0x2c01=['Fields','custom_fields','mapValues','keyBy','format','remoteUri','Ticket\x20created!','validateEmail','length','Agent\x20found!','contact','email','%s/api/v2/agents/me','then','%s/api/v2/contacts','Enduser\x20found!','find','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','POST','Enduser\x20created.','Basic\x20%s','apiKey','base64','[HTTP]','GET','map','forEach','includes','string','type','nameField','toLowerCase','picklist','idField','customField','push','content','toString','variable','variableName','customVariable','Variable','name','queue','stripTrailingSlash','serverUrl','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','Authorization','calleridnum','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','%s/helpdesk/tickets/%d','catch','error','stringify','outbound','recordingFormat','none','[OUTBOUND]','The\x20User\x20ID\x20is:','trigger:browser:url','unmanaged','monitor_format','lastevent','toUpperCase','lodash','request-promise','md5','util','ioredis','./util','../../../../config/environment','../../../../config/logger','freshdesk','redis','defaults','localhost','socket.io-emitter','application/json','emit','info','Creating\x20new\x20ticket...','Caller\x20-\x20%s','calleridname','getString','Subjects','Descriptions','<br>','Tags'];(function(_0x390cea,_0x43c078){var _0x14bf80=function(_0x196f3c){while(--_0x196f3c){_0x390cea['push'](_0x390cea['shift']());}};_0x14bf80(++_0x43c078);}(_0x2c01,0xff));var _0x12c0=function(_0x18c037,_0x26dbba){_0x18c037=_0x18c037-0x0;var _0x667212=_0x2c01[_0x18c037];return _0x667212;};'use strict';var _=require(_0x12c0('0x0'));var rp=require(_0x12c0('0x1'));var md5=require(_0x12c0('0x2'));var util=require(_0x12c0('0x3'));var Redis=require(_0x12c0('0x4'));var intUtil=require(_0x12c0('0x5'));var config=require(_0x12c0('0x6'));var logger=require(_0x12c0('0x7'))(_0x12c0('0x8'));config[_0x12c0('0x9')]=_[_0x12c0('0xa')](config[_0x12c0('0x9')],{'host':_0x12c0('0xb'),'port':0x18eb});var io=require(_0x12c0('0xc'))(new Redis(config[_0x12c0('0x9')]));var headers={'Content-Type':_0x12c0('0xd'),'Accept':_0x12c0('0xd')};function emit(_0x24c85f,_0x3cfdd7,_0x8afb17){io['to'](_0x24c85f)[_0x12c0('0xe')](_0x3cfdd7,_0x8afb17);}function getTicket(_0x93152b,_0x21f363,_0x354f,_0xc80a62,_0x31a90a){logger[_0x12c0('0xf')](_0x12c0('0x10'));var _0x29ad39=_['merge']({'responder_id':_0x21f363['id'],'requester_id':_0x354f['id'],'name':util['format'](_0x12c0('0x11'),_0x31a90a[_0x12c0('0x12')]),'phone':_0x31a90a['calleridnum'],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0x12c0('0x13')](_0xc80a62[_0x12c0('0x14')],_0x31a90a,'\x20'),'description':intUtil['getString'](_0xc80a62[_0x12c0('0x15')],_0x31a90a,_0x12c0('0x16')),'tags':getTags(_0xc80a62[_0x12c0('0x17')],'name')},getCustomFields(_0xc80a62[_0x12c0('0x18')],_0x31a90a));_0x29ad39[_0x12c0('0x19')]=_[_0x12c0('0x1a')](_[_0x12c0('0x1b')](_0x29ad39[_0x12c0('0x19')],'id'),'value');return request({'uri':util[_0x12c0('0x1c')]('%s/api/v2/tickets',_0x93152b[_0x12c0('0x1d')]),'method':'POST','body':_0x29ad39})['then'](function(_0x2c17f2){logger[_0x12c0('0xf')](_0x12c0('0x1e'));return _0x2c17f2;});}function getUser(_0x4e5786,_0x2b0645){if(intUtil[_0x12c0('0x1f')](_0x2b0645)){return request({'uri':util[_0x12c0('0x1c')]('%s/api/v2/agents',_0x4e5786[_0x12c0('0x1d')]),'qs':{'email':_0x2b0645}})['then'](function(_0x3512ff){if(_0x3512ff[_0x12c0('0x20')]){logger[_0x12c0('0xf')](_0x12c0('0x21'));return _['find'](_0x3512ff,function(_0x8a035){return _0x8a035[_0x12c0('0x22')][_0x12c0('0x23')]===_0x2b0645;});}else{logger[_0x12c0('0xf')]('Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!');return request({'uri':util['format'](_0x12c0('0x24'),_0x4e5786[_0x12c0('0x1d')])})[_0x12c0('0x25')](function(_0x261d92){logger[_0x12c0('0xf')]('Admin\x20account\x20selected.');return _0x261d92;});}});}else{logger[_0x12c0('0xf')]('Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0x12c0('0x1c')](_0x12c0('0x24'),_0x4e5786[_0x12c0('0x1d')])})[_0x12c0('0x25')](function(_0x3feacf){logger[_0x12c0('0xf')]('Admin\x20account\x20selected.');return _0x3feacf;});}}function getEndUser(_0x3159f8,_0x5d66a2,_0x4fd91c){logger[_0x12c0('0xf')]('Searching\x20enduser\x20with\x20phone',_0x4fd91c);return request({'uri':util[_0x12c0('0x1c')](_0x12c0('0x26'),_0x3159f8[_0x12c0('0x1d')]),'qs':{'phone':_0x4fd91c}})[_0x12c0('0x25')](function(_0x8ea144){if(_0x8ea144[_0x12c0('0x20')]){logger[_0x12c0('0xf')](_0x12c0('0x27'));return _[_0x12c0('0x28')](_0x8ea144,{'phone':_0x4fd91c});}else{logger[_0x12c0('0xf')](_0x12c0('0x29'));return request({'uri':util[_0x12c0('0x1c')](_0x12c0('0x26'),_0x3159f8[_0x12c0('0x1d')]),'method':_0x12c0('0x2a'),'body':{'name':_0x5d66a2,'phone':_0x4fd91c}})[_0x12c0('0x25')](function(_0x3c47f7){logger[_0x12c0('0xf')](_0x12c0('0x2b'));return _0x3c47f7;});}});}function getAuth(_0x18a706){return util[_0x12c0('0x1c')](_0x12c0('0x2c'),new Buffer(_0x18a706[_0x12c0('0x2d')]+':X')['toString'](_0x12c0('0x2e')));}function request(_0x31d86f){logger['debug'](_0x12c0('0x2f'),JSON['stringify'](_0x31d86f));return rp(_[_0x12c0('0xa')](_0x31d86f,{'method':_0x12c0('0x30'),'headers':headers,'json':!![]}));}function getTags(_0x388170,_0x20434b){var _0x53cf06=[];if(_0x388170&&_0x388170['length']>0x0){_0x53cf06=_[_0x12c0('0x31')](_0x388170,_0x20434b);}return _0x53cf06;}function getCustomFields(_0x58bc08,_0x39d75e){var _0x3aa2ac=[];var _0x31af47={'custom_fields':[]};if(_0x58bc08[_0x12c0('0x20')]>0x0){_[_0x12c0('0x32')](_0x58bc08,function(_0x516c64){if(_[_0x12c0('0x33')]([_0x12c0('0x34'),'picklist'],_0x516c64[_0x12c0('0x35')])&&_0x516c64['nameField']&&!_0x516c64['customField']){_0x31af47[_0x516c64[_0x12c0('0x36')][_0x12c0('0x37')]()]=_0x516c64['content']['toString']();}else if(_[_0x12c0('0x33')]([_0x12c0('0x34'),_0x12c0('0x38')],_0x516c64[_0x12c0('0x35')])&&_0x516c64[_0x12c0('0x39')]&&_0x516c64[_0x12c0('0x3a')]){_0x31af47[_0x12c0('0x19')][_0x12c0('0x3b')]({'id':_0x516c64[_0x12c0('0x39')],'value':_0x516c64[_0x12c0('0x3c')][_0x12c0('0x3d')]()});}else if(_0x516c64['type']===_0x12c0('0x3e')&&_0x516c64[_0x12c0('0x3f')]&&_0x516c64[_0x12c0('0x39')]&&_0x516c64[_0x12c0('0x3a')]){_0x39d75e[_0x516c64[_0x12c0('0x3f')]]&&_0x31af47[_0x12c0('0x19')][_0x12c0('0x3b')]({'id':_0x516c64['idField'],'value':_0x39d75e[_0x516c64['variableName']][_0x12c0('0x3d')]()});}else if(_0x516c64[_0x12c0('0x35')]===_0x12c0('0x40')&&_0x516c64[_0x12c0('0x41')]&&_0x516c64[_0x12c0('0x41')][_0x12c0('0x42')]&&_0x516c64['idField']&&_0x516c64[_0x12c0('0x3a')]){_0x39d75e[_0x516c64['Variable'][_0x12c0('0x42')][_0x12c0('0x37')]()]&&_0x31af47[_0x12c0('0x19')]['push']({'id':_0x516c64[_0x12c0('0x39')],'value':_0x39d75e[_0x516c64[_0x12c0('0x41')][_0x12c0('0x42')][_0x12c0('0x37')]()][_0x12c0('0x3d')]()});}});}return _0x31af47;}exports[_0x12c0('0x43')]=function(_0x5a3214,_0x2d8ecf,_0x2709c0,_0x53007d,_0x2aba7f,_0xdb1da5){var _0x47abfa,_0x31b94c;_0xdb1da5[_0x12c0('0x1d')]=intUtil[_0x12c0('0x44')](_0xdb1da5[_0x12c0('0x1d')]);_0xdb1da5['serverUrl']=intUtil[_0x12c0('0x44')](_0xdb1da5[_0x12c0('0x45')]);if(_0x2aba7f&&_0x2aba7f['monitor_format']){logger[_0x12c0('0xf')](_0x12c0('0x46'),_0x12c0('0x47'));_0x2d8ecf[_0x12c0('0x48')]=util[_0x12c0('0x1c')](_0x12c0('0x49'),_0xdb1da5[_0x12c0('0x45')],_0x2d8ecf[_0x12c0('0x4a')],md5(_0x2d8ecf[_0x12c0('0x4a')]));}else{_0x2d8ecf[_0x12c0('0x48')]='';}headers[_0x12c0('0x4b')]=getAuth(_0xdb1da5);return getUser(_0xdb1da5,_0x53007d[_0x12c0('0x23')])[_0x12c0('0x25')](function(_0x2a315f){_0x47abfa=_0x2a315f;logger[_0x12c0('0xf')]('The\x20User\x20ID\x20is:',_0x47abfa['id']);return getEndUser(_0xdb1da5,_0x2d8ecf[_0x12c0('0x12')],_0x2d8ecf[_0x12c0('0x4c')]);})[_0x12c0('0x25')](function(_0x25523a){_0x31b94c=_0x25523a;logger[_0x12c0('0xf')](_0x12c0('0x4d'),_0x31b94c['id']);return getTicket(_0xdb1da5,_0x47abfa,_0x31b94c,_0x2709c0,_0x2d8ecf);})['then'](function(_0x596dcc){if(_0x596dcc&&_0x596dcc['id']){logger['info'](_0x12c0('0x1e'));logger['info'](_0x12c0('0x4e'),_0x596dcc['id']);logger[_0x12c0('0xf')]('[QUEUE]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util['format']('user:%s',_0x53007d[_0x12c0('0x42')]),'trigger:browser:url',{'uri':util[_0x12c0('0x1c')](_0x12c0('0x4f'),_0xdb1da5['remoteUri'],_0x596dcc['id'])});}})[_0x12c0('0x50')](function(_0x21dbc6){logger[_0x12c0('0x51')](_0x12c0('0x46'),JSON[_0x12c0('0x52')](_0x21dbc6));});};exports[_0x12c0('0x53')]=function(_0x809f40,_0x3e127e,_0xe50c3e,_0x1a5295,_0x415912,_0x20b905,_0x4497f4){var _0x4f2fa8,_0x524e84;_0x20b905[_0x12c0('0x1d')]=intUtil[_0x12c0('0x44')](_0x20b905[_0x12c0('0x1d')]);_0x20b905[_0x12c0('0x45')]=intUtil[_0x12c0('0x44')](_0x20b905[_0x12c0('0x45')]);if(_0x4497f4&&_0x4497f4[_0x12c0('0x54')]&&_0x4497f4['recordingFormat']!==_0x12c0('0x55')){logger['info'](_0x12c0('0x56'),_0x12c0('0x47'));_0x3e127e[_0x12c0('0x48')]=util[_0x12c0('0x1c')](_0x12c0('0x49'),_0x20b905['serverUrl'],_0x3e127e[_0x12c0('0x4a')],md5(_0x3e127e[_0x12c0('0x4a')]));}headers['Authorization']=getAuth(_0x20b905);return getUser(_0x20b905,_0x1a5295['email'])[_0x12c0('0x25')](function(_0x3f5063){_0x4f2fa8=_0x3f5063;logger[_0x12c0('0xf')](_0x12c0('0x57'),_0x4f2fa8['id']);return getEndUser(_0x20b905,_0x3e127e['destcalleridname'],_0x3e127e['destcalleridnum']);})[_0x12c0('0x25')](function(_0x193c4d){_0x524e84=_0x193c4d;logger[_0x12c0('0xf')](_0x12c0('0x4d'),_0x524e84['id']);return getTicket(_0x20b905,_0x4f2fa8,_0x524e84,_0xe50c3e,_0x3e127e);})[_0x12c0('0x25')](function(_0x26cc9f){if(_0x26cc9f&&_0x26cc9f['id']){logger['info'](_0x12c0('0x1e'));logger[_0x12c0('0xf')](_0x12c0('0x4e'),_0x26cc9f['id']);logger['info']('[OUTBOUND]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x12c0('0x1c')]('user:%s',_0x1a5295[_0x12c0('0x42')]),_0x12c0('0x58'),{'uri':util[_0x12c0('0x1c')](_0x12c0('0x4f'),_0x20b905[_0x12c0('0x1d')],_0x26cc9f['id'])});}})[_0x12c0('0x50')](function(_0x23f8b3){logger[_0x12c0('0x51')](_0x12c0('0x56'),JSON[_0x12c0('0x52')](_0x23f8b3));});};exports[_0x12c0('0x59')]=function(_0x458e5f,_0x11627c,_0x1994b4,_0x7cad53,_0x245dc8,_0x30a362){var _0xc21361,_0x359955;_0x30a362[_0x12c0('0x1d')]=intUtil[_0x12c0('0x44')](_0x30a362[_0x12c0('0x1d')]);_0x30a362[_0x12c0('0x45')]=intUtil[_0x12c0('0x44')](_0x30a362[_0x12c0('0x45')]);if(_0x245dc8&&_0x245dc8[_0x12c0('0x5a')]){logger[_0x12c0('0xf')]('['+_0x11627c[_0x12c0('0x5b')][_0x12c0('0x5c')]()+']',_0x12c0('0x47'));_0x11627c['recordingURL']=util['format'](_0x12c0('0x49'),_0x30a362[_0x12c0('0x45')],_0x11627c[_0x12c0('0x4a')],md5(_0x11627c[_0x12c0('0x4a')]));}else{_0x11627c['recordingURL']='';}headers[_0x12c0('0x4b')]=getAuth(_0x30a362);return getUser(_0x30a362,'')['then'](function(_0x2dc651){_0xc21361=_0x2dc651;logger[_0x12c0('0xf')](_0x12c0('0x57'),_0xc21361['id']);return getEndUser(_0x30a362,_0x11627c['calleridname'],_0x11627c['calleridnum']);})[_0x12c0('0x25')](function(_0x2effce){_0x359955=_0x2effce;logger[_0x12c0('0xf')](_0x12c0('0x4d'),_0x359955['id']);return getTicket(_0x30a362,_0xc21361,_0x359955,_0x1994b4,_0x11627c);})[_0x12c0('0x25')](function(_0x3c4d65){if(_0x3c4d65){logger[_0x12c0('0xf')](_0x12c0('0x1e'));logger[_0x12c0('0xf')](_0x12c0('0x4e'),_0x3c4d65['id']);}})['catch'](function(_0x5788ac){logger[_0x12c0('0x51')]('['+_0x11627c[_0x12c0('0x5b')][_0x12c0('0x5c')]()+']',JSON[_0x12c0('0x52')](_0x5788ac));});};
\ No newline at end of file