Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / services / ami / trigger / integration / zoho.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x4965=['/crm/v2/Leads/search?criteria=((Phone:equals:','Creating\x20new\x20call...','Owner','administrator','Subject','getString','Subjects','Descriptions','Full_Name','First_Name','Last_Name','What_Id','talktime','Call_Duration','utc','mm:ss','answertime','endtime','YYYY-MM-DDTHH:mm:ss','diff','starttime','format','lastevent','called','Called','Call_Result','Answered','rejected','Rejected','Abandoned','Timeout','Call_Start_Time','outbound','Call_Type','Inbound','merge','Fields','POST','/crm/v2/Calls','err','queue','host','stripTrailingSlash','serverUrl','Recording\x20is\x20enabled!','recordingURL','/api/voice/recordings/','uniqueid','zoho.eu','com','The\x20User\x20ID\x20is:','calleridnum','The\x20Call\x20ID\x20is:','[QUEUE]','Displaying\x20call\x20to\x20agent\x20in\x20a\x20new\x20tab...','trigger:browser:url','https://crm.','recordingFormat','[OUTBOUND]','destcalleridname','destcalleridnum','Outbound','user:%s','/crm/EntityInfo.do?module=Calls&id=','calleridname','toUpperCase','lodash','request-promise','md5','ioredis','../../../../config/environment','../../../../config/logger','zoho','defaults','redis','localhost','socket.io-emitter','emit','[HTTP]','stringify','length','forEach','type','string','idField','content','toString','variableName','customVariable','name','Variable','toLowerCase','indexOf','split','isNil','access_token','isBefore','expires_in','zone','https://accounts.zoho.com','https://accounts.zoho.com.au','https://accounts.zoho.eu','https://accounts.zoho.in','https://accounts.zoho.com.cn','/oauth/v2/token','refresh_token','then','add','seconds','catch','Failing\x20creating\x20the\x20access_token','stack','https://www.zohoapis.%s/crm/v2/users','ActiveUsers','Zoho-oauthtoken\x20','users','isArrayLikeObject','findIndex','email','info','Using\x20the\x20admin\x20account!','profile','user','Administrator','The\x20failing\x20result\x20is','Unable\x20to\x20retrieve\x20zoho\x20account\x20users:\x20','error','data','https://www.zohoapis.','/crm/v2/','moduleCreate','role','first_name','last_name','code','SUCCESS','details','enduserType','startCase','Error:\x20','log','GET','moduleSearch','contact_lead','uri','/crm/v2/Contacts/search?criteria=((Phone:equals:','Contacts','Leads','nothing','contact'];(function(_0x3c5f8d,_0x39891f){var _0x3b7beb=function(_0x44d6c9){while(--_0x44d6c9){_0x3c5f8d['push'](_0x3c5f8d['shift']());}};_0x3b7beb(++_0x39891f);}(_0x4965,0x16e));var _0x5496=function(_0x499227,_0x3a8c2c){_0x499227=_0x499227-0x0;var _0xec1c0a=_0x4965[_0x499227];return _0xec1c0a;};'use strict';var _=require(_0x5496('0x0'));var rp=require(_0x5496('0x1'));var md5=require(_0x5496('0x2'));var util=require('util');var intUtil=require('./util');var moment=require('moment');var Redis=require(_0x5496('0x3'));var BPromise=require('bluebird');var config=require(_0x5496('0x4'));var logger=require(_0x5496('0x5'))(_0x5496('0x6'));config['redis']=_[_0x5496('0x7')](config[_0x5496('0x8')],{'host':_0x5496('0x9'),'port':0x18eb});var io=require(_0x5496('0xa'))(new Redis(config['redis']));function emit(_0x3086c8,_0x4d0e7a,_0xfe89fe){io['to'](_0x3086c8)[_0x5496('0xb')](_0x4d0e7a,_0xfe89fe);}function request(_0x3c100f){logger['debug'](_0x5496('0xc'),JSON[_0x5496('0xd')](_0x3c100f));return rp(_0x3c100f);}function getCustomFields(_0x42f073,_0x13f202){var _0x3b1818={};if(_0x42f073[_0x5496('0xe')]>0x0){_[_0x5496('0xf')](_0x42f073,function(_0x22b366){if(_0x22b366[_0x5496('0x10')]===_0x5496('0x11')&&_0x22b366[_0x5496('0x12')]){_0x3b1818[_0x22b366[_0x5496('0x12')]]=_0x22b366[_0x5496('0x13')][_0x5496('0x14')]();}else if(_0x22b366[_0x5496('0x10')]==='variable'&&_0x22b366[_0x5496('0x15')]&&_0x22b366[_0x5496('0x12')]&&_0x13f202[_0x22b366[_0x5496('0x15')]]){_0x3b1818[_0x22b366[_0x5496('0x12')]]=_0x13f202[_0x22b366[_0x5496('0x15')]][_0x5496('0x14')]();}else if(_0x22b366[_0x5496('0x10')]===_0x5496('0x16')&&_0x22b366['Variable']&&_0x22b366['Variable'][_0x5496('0x17')]&&_0x22b366[_0x5496('0x12')]&&_0x13f202[_0x22b366[_0x5496('0x18')][_0x5496('0x17')][_0x5496('0x19')]()]){_0x3b1818[_0x22b366[_0x5496('0x12')]]=_0x13f202[_0x22b366[_0x5496('0x18')][_0x5496('0x17')][_0x5496('0x19')]()]['toString']();}});}return _0x3b1818;}function getName(_0x49ad94){if(_0x49ad94[_0x5496('0x1a')]('\x20')>0x0){var _0x1258f8=_0x49ad94[_0x5496('0x1b')](/ (.+)/);if(_0x1258f8[0x1]){return _0x1258f8;}}return[_0x49ad94,_0x49ad94];}var accountsTokens={};function getAccessToken(_0x2cd842){return new Promise(function(_0x4d2a9d,_0x701eca){if(!_[_0x5496('0x1c')](accountsTokens[_0x2cd842['id']])&&!_['isNil'](accountsTokens[_0x2cd842['id']][_0x5496('0x1d')])){if(moment()[_0x5496('0x1e')](accountsTokens[_0x2cd842['id']][_0x5496('0x1f')])){_0x4d2a9d(accountsTokens[_0x2cd842['id']][_0x5496('0x1d')]);}}var _0x23bd12;switch(_0x2cd842[_0x5496('0x20')]){case'US':_0x23bd12=_0x5496('0x21');break;case'AU':_0x23bd12=_0x5496('0x22');break;case'EU':_0x23bd12=_0x5496('0x23');break;case'IN':_0x23bd12=_0x5496('0x24');break;case'CN':_0x23bd12=_0x5496('0x25');break;default:_0x23bd12=_0x5496('0x23');break;}var _0x385134={'method':'POST','uri':_0x23bd12+_0x5496('0x26'),'qs':{'refresh_token':_0x2cd842['refreshToken'],'client_id':_0x2cd842['clientId'],'client_secret':_0x2cd842['clientSecret'],'grant_type':_0x5496('0x27')},'json':!![]};return rp(_0x385134)[_0x5496('0x28')](function(_0x4067de){accountsTokens[_0x2cd842['id']]={'access_token':_0x4067de[_0x5496('0x1d')],'expires_in':moment()[_0x5496('0x29')](_0x4067de[_0x5496('0x1f')],_0x5496('0x2a'))};_0x4d2a9d(_0x4067de[_0x5496('0x1d')]);})[_0x5496('0x2b')](function(_0x2c7a37){logger['error'](_0x5496('0x2c'),_0x2c7a37[_0x5496('0x2d')]);_0x701eca(_0x2c7a37);});});}function getUser(_0x519bd7,_0x802f78,_0x1ff1a0,_0x119a56){logger['info']('Search\x20user');return request({'method':'GET','uri':util['format'](_0x5496('0x2e'),_0x802f78),'qs':{'type':_0x5496('0x2f')},'headers':{'Authorization':_0x5496('0x30')+_0x519bd7},'json':!![]})[_0x5496('0x28')](function(_0x87702b){if(_0x87702b[_0x5496('0x31')]){var _0x59811c=-0x1;if(_[_0x5496('0x32')](_0x87702b[_0x5496('0x31')])){if(!_['isNil'](_0x119a56)){_0x59811c=_[_0x5496('0x33')](_0x87702b[_0x5496('0x31')],function(_0xf1b3cf){return _0xf1b3cf[_0x5496('0x34')]===_0x119a56;});}if(_0x59811c>=0x0){logger['info']('Agent\x20found!');}else{logger[_0x5496('0x35')](_0x5496('0x36'));_0x59811c=_[_0x5496('0x33')](_0x87702b[_0x5496('0x31')],function(_0x21e431){return _0x21e431[_0x5496('0x37')][_0x5496('0x17')]==='Administrator';});}return _0x87702b['users'][_0x59811c];}else{if(_0x87702b[_0x5496('0x38')]['profile'][_0x5496('0x17')]===_0x5496('0x39')){logger[_0x5496('0x35')](_0x5496('0x36'));user=_0x87702b[_0x5496('0x38')];return user;}else{logger['error'](_0x5496('0x3a'),JSON['stringify'](_0x87702b));throw new Error(_0x5496('0x3b')+JSON[_0x5496('0xd')](_0x87702b));}}}else{logger['error'](_0x5496('0x3a'),JSON[_0x5496('0xd')](_0x87702b));throw new Error('Unable\x20to\x20retrieve\x20zoho\x20account\x20users:\x20'+JSON[_0x5496('0xd')](_0x87702b));}})[_0x5496('0x2b')](function(_0xd0ed63){console[_0x5496('0x3c')](_0xd0ed63);});}function getZohoUser(_0x539fc0,_0x505d9b){return new BPromise(function(_0x48bfbe,_0x410a0e){request(_0x539fc0)['then'](function(_0x5a0d30){var _0x121279=null;if(_0x5a0d30){_0x121279=_0x5a0d30[_0x5496('0x3d')][0x0];_0x121279['enduserType']=_0x505d9b;}_0x48bfbe(_0x121279);})[_0x5496('0x2b')](function(_0x2426b8){_0x410a0e(_0x2426b8);});});}function createEndUser(_0x54e727,_0x3d3eb8,_0x20a1a4,_0x46332e,_0x3d86c6,_0x1af21b){var _0x20a1a4=getName(_0x20a1a4);return request({'method':'POST','uri':_0x5496('0x3e')+_0x3d3eb8+_0x5496('0x3f')+_['startCase'](_0x1af21b[_0x5496('0x40')])+'s','body':{'data':[{'Last_Name':_0x20a1a4[0x1],'First_Name':_0x20a1a4[0x0],'Phone':_0x46332e,'Owner':{'name':!_[_0x5496('0x1c')](_0x3d86c6['role'][_0x5496('0x17')])?_0x3d86c6[_0x5496('0x41')][_0x5496('0x17')]:!_[_0x5496('0x1c')](_0x3d86c6[_0x5496('0x42')])?_0x3d86c6[_0x5496('0x42')]+'\x20'+_0x3d86c6[_0x5496('0x43')]:_0x3d86c6['last_name'],'id':_0x3d86c6['id']}}]},'headers':{'Authorization':'Zoho-oauthtoken\x20'+_0x54e727},'json':!![]})[_0x5496('0x28')](function(_0x4314b1){if(_0x4314b1&&_0x4314b1[_0x5496('0x3d')][0x0][_0x5496('0x44')]===_0x5496('0x45')){var _0x1578fb=_0x4314b1[_0x5496('0x3d')][0x0][_0x5496('0x46')];_0x1578fb[_0x5496('0x47')]=_[_0x5496('0x48')](_0x1af21b[_0x5496('0x40')])+'s';return _0x1578fb;}logger['error'](_0x5496('0x3a'),JSON[_0x5496('0xd')](data));throw new Error(_0x5496('0x49')+JSON[_0x5496('0xd')](data));})[_0x5496('0x2b')](function(_0x1e83ea){console[_0x5496('0x4a')]('CREATE\x20ERROR',_0x1e83ea);});}function getEndUser(_0x5c7f03,_0x101aff,_0x13a04c,_0x44ab7c,_0x3b9e02,_0x47a5ed,_0x3d6bff){var _0x2e82e0={'method':_0x5496('0x4b'),'uri':'','headers':{'Authorization':'Zoho-oauthtoken\x20'+_0x5c7f03},'json':!![]};switch(_0x3d6bff[_0x5496('0x4c')]){case _0x5496('0x4d'):_0x2e82e0[_0x5496('0x4e')]=_0x5496('0x3e')+_0x101aff+_0x5496('0x4f')+_0x3b9e02+'))';return getZohoUser(_0x2e82e0,_0x5496('0x50'))[_0x5496('0x28')](function(_0x2f2648){if(_0x2f2648)return _0x2f2648;_0x2e82e0[_0x5496('0x4e')]=_0x5496('0x3e')+_0x101aff+'/crm/v2/Leads/search?criteria=((Phone:equals:'+_0x3b9e02+'))';return getZohoUser(_0x2e82e0,_0x5496('0x51'))[_0x5496('0x28')](function(_0xf5011a){if(_0xf5011a)return _0xf5011a;if(_0x3d6bff[_0x5496('0x40')]!=_0x5496('0x52')){return createEndUser(_0x5c7f03,_0x101aff,_0x44ab7c,_0x3b9e02,_0x47a5ed,_0x3d6bff);}else{return{};}});});break;case _0x5496('0x53'):_0x2e82e0[_0x5496('0x4e')]=_0x5496('0x3e')+_0x101aff+'/crm/v2/Contacts/search?criteria=((Phone:equals:'+_0x3b9e02+'))';return getZohoUser(_0x2e82e0,'Contacts')[_0x5496('0x28')](function(_0x22a79f){if(_0x22a79f)return _0x22a79f;if(_0x3d6bff[_0x5496('0x40')]!=_0x5496('0x52')){return createEndUser(_0x5c7f03,_0x101aff,_0x44ab7c,_0x3b9e02,_0x47a5ed,_0x3d6bff);}else{return{};}});break;case'lead':_0x2e82e0[_0x5496('0x4e')]=_0x5496('0x3e')+_0x101aff+_0x5496('0x54')+_0x3b9e02+'))';return getZohoUser(_0x2e82e0,_0x5496('0x51'))[_0x5496('0x28')](function(_0xa3701c){if(_0xa3701c)return _0xa3701c;if(_0x3d6bff[_0x5496('0x40')]!=_0x5496('0x52')){return createEndUser(_0x5c7f03,_0x101aff,_0x44ab7c,_0x3b9e02,_0x47a5ed,_0x3d6bff);}else{return{};}});break;}}function getCall(_0x132674,_0x1b5e4a,_0x1ffbc5,_0x1445b3,_0x5df52b,_0x12e603,_0x383be3,_0x16486f){logger[_0x5496('0x35')](_0x5496('0x55'));var _0x43268c={};_0x43268c[_0x5496('0x56')]={'name':!_['isNil'](_0x1445b3[_0x5496('0x41')][_0x5496('0x17')])&&!_['isNil'](_0x1445b3[_0x5496('0x37')][_0x5496('0x17')])&&_0x1445b3[_0x5496('0x37')][_0x5496('0x17')]===_0x5496('0x57')?_0x1445b3[_0x5496('0x41')][_0x5496('0x17')]:!_[_0x5496('0x1c')](_0x1445b3[_0x5496('0x42')])?_0x1445b3[_0x5496('0x42')]+'\x20'+_0x1445b3[_0x5496('0x43')]:_0x1445b3[_0x5496('0x43')],'id':_0x1445b3['id']};_0x43268c[_0x5496('0x58')]=intUtil[_0x5496('0x59')](_0x12e603[_0x5496('0x5a')],_0x383be3,'\x20');_0x43268c['Description']=intUtil[_0x5496('0x59')](_0x12e603[_0x5496('0x5b')],_0x383be3,'\x0a');if(_0x5df52b[_0x5496('0x47')]===_0x5496('0x50')){_0x43268c['Who_Id']={'name':!_['isNil'](_0x5df52b[_0x5496('0x5c')])?_0x5df52b[_0x5496('0x5c')]:!_[_0x5496('0x1c')](_0x5df52b[_0x5496('0x5d')])?_0x5df52b[_0x5496('0x5d')]+'\x20'+_0x5df52b[_0x5496('0x5e')]:_0x5df52b[_0x5496('0x5e')],'id':_0x5df52b['id']};}if(_0x5df52b['enduserType']===_0x5496('0x51')){_0x43268c[_0x5496('0x5f')]={'name':!_[_0x5496('0x1c')](_0x5df52b[_0x5496('0x5c')])?_0x5df52b[_0x5496('0x5c')]:!_[_0x5496('0x1c')](_0x5df52b[_0x5496('0x5d')])?_0x5df52b[_0x5496('0x5d')]+'\x20'+_0x5df52b[_0x5496('0x5e')]:_0x5df52b[_0x5496('0x5e')],'id':_0x5df52b['id']};_0x43268c['$se_module']=_[_0x5496('0x48')](_0x5df52b[_0x5496('0x47')]);}if(_0x383be3[_0x5496('0x60')]){_0x43268c[_0x5496('0x61')]=moment[_0x5496('0x62')](parseInt(_0x383be3[_0x5496('0x60')])*0x3e8)['format'](_0x5496('0x63'));}else if(_0x383be3[_0x5496('0x64')]&&_0x383be3[_0x5496('0x65')]){_0x43268c['Call_Duration']=moment['utc'](moment(_0x383be3['endtime'],_0x5496('0x66'))[_0x5496('0x67')](moment(_0x383be3[_0x5496('0x68')],_0x5496('0x66'))))[_0x5496('0x69')](_0x5496('0x63'));}switch(_0x383be3[_0x5496('0x6a')]){case _0x5496('0x6b'):_0x43268c['Call_Result']=_0x5496('0x6c');break;case'complete':case'connect':_0x43268c[_0x5496('0x6d')]=_0x5496('0x6e');break;case _0x5496('0x6f'):_0x43268c[_0x5496('0x6d')]=_0x5496('0x70');break;case'abandoned':_0x43268c[_0x5496('0x6d')]=_0x5496('0x71');break;case'timeout':_0x43268c[_0x5496('0x6d')]=_0x5496('0x72');default:}_0x43268c[_0x5496('0x73')]=(_0x16486f===_0x5496('0x74')?moment(_0x383be3[_0x5496('0x68')])[_0x5496('0x69')]('YYYY-MM-DDTHH:mm:ss'):moment(_0x383be3['agentcalledAt'])[_0x5496('0x69')](_0x5496('0x66')))||moment()['format']('YYYY-MM-DDTHH:mm:ss');_0x43268c[_0x5496('0x75')]=_0x16486f||_0x5496('0x76');_0x43268c=_[_0x5496('0x77')](_0x43268c,getCustomFields(_0x12e603[_0x5496('0x78')],_0x383be3));return request({'method':_0x5496('0x79'),'uri':'https://www.zohoapis.'+_0x1b5e4a+_0x5496('0x7a'),'headers':{'Authorization':'Zoho-oauthtoken\x20'+_0x132674},'body':{'data':[_0x43268c]},'json':!![]})[_0x5496('0x28')](function(_0x56e4f9){if(_0x56e4f9&&_0x56e4f9[_0x5496('0x3d')][0x0][_0x5496('0x44')]===_0x5496('0x45')){logger[_0x5496('0x35')]('Call\x20created!');return{'id':_0x56e4f9[_0x5496('0x3d')][0x0][_0x5496('0x46')]['id']};}})[_0x5496('0x2b')](function(_0x30f477){logger[_0x5496('0x35')]('err',_0x30f477['stack']);console['log'](_0x5496('0x7b'),_0x30f477);});}exports[_0x5496('0x7c')]=function(_0x143b32,_0x45712e,_0x109071,_0x4d9b94,_0x35da96,_0x11c663){var _0x270ac4,_0x57c676,_0x5de3d0;_0x11c663[_0x5496('0x7d')]=intUtil[_0x5496('0x7e')](_0x11c663[_0x5496('0x7d')]);_0x11c663[_0x5496('0x7f')]=intUtil[_0x5496('0x7e')](_0x11c663[_0x5496('0x7f')]);if(_0x35da96&&_0x35da96['monitor_format']){logger[_0x5496('0x35')]('[QUEUE]',_0x5496('0x80'));_0x45712e[_0x5496('0x81')]=_0x11c663[_0x5496('0x7f')]+_0x5496('0x82')+_0x45712e[_0x5496('0x83')]+'/downloads?type=uniqueid&token='+md5(_0x45712e[_0x5496('0x83')]);}else{_0x45712e[_0x5496('0x81')]='';}var _0x471478=_0x11c663[_0x5496('0x7d')]===_0x5496('0x84')?'eu':_0x5496('0x85');return getAccessToken(_0x11c663)['then'](function(_0xd5f310){_0x5de3d0=_0xd5f310;return getUser(_0x5de3d0,_0x471478,_0x11c663,_0x4d9b94['email']);})['then'](function(_0x4195bc){_0x270ac4=_0x4195bc;logger[_0x5496('0x35')](_0x5496('0x86'),_0x270ac4['id']);return getEndUser(_0x5de3d0,_0x471478,_0x11c663,_0x45712e['calleridname'],_0x45712e[_0x5496('0x87')],_0x270ac4,_0x109071);})[_0x5496('0x28')](function(_0x1451f8){_0x57c676=_0x1451f8;return getCall(_0x5de3d0,_0x471478,_0x11c663,_0x270ac4,_0x57c676,_0x109071,_0x45712e,_0x5496('0x76'));})[_0x5496('0x28')](function(_0xceae92){if(_0xceae92){logger[_0x5496('0x35')](_0x5496('0x88'),_0xceae92['id']);logger[_0x5496('0x35')](_0x5496('0x89'),_0x5496('0x8a'));emit(util['format']('user:%s',_0x4d9b94['name']),_0x5496('0x8b'),{'uri':_0x5496('0x8c')+_0x11c663[_0x5496('0x7d')]+'/crm/EntityInfo.do?module=Calls&id='+_0xceae92['id']});}})[_0x5496('0x2b')](function(_0x2b70c5){logger[_0x5496('0x3c')](_0x5496('0x89'),JSON[_0x5496('0xd')](_0x2b70c5));});};exports[_0x5496('0x74')]=function(_0x4e59d3,_0x2f99ab,_0x31ced2,_0x249f04,_0x26176b,_0x4dfcfe,_0x192751){var _0x367e83,_0x2ee1d4,_0x3fdb18;_0x4dfcfe[_0x5496('0x7d')]=intUtil[_0x5496('0x7e')](_0x4dfcfe[_0x5496('0x7d')]);_0x4dfcfe[_0x5496('0x7f')]=intUtil[_0x5496('0x7e')](_0x4dfcfe[_0x5496('0x7f')]);if(_0x192751&&_0x192751[_0x5496('0x8d')]&&_0x192751['recordingFormat']!=='none'){logger[_0x5496('0x35')](_0x5496('0x8e'),_0x5496('0x80'));_0x2f99ab[_0x5496('0x81')]=_0x4dfcfe[_0x5496('0x7f')]+_0x5496('0x82')+_0x2f99ab[_0x5496('0x83')]+'/downloads?type=uniqueid&token='+md5(_0x2f99ab[_0x5496('0x83')]);}var _0x34796b=_0x4dfcfe[_0x5496('0x7d')]===_0x5496('0x84')?'eu':_0x5496('0x85');return getAccessToken(_0x4dfcfe)[_0x5496('0x28')](function(_0x14723c){_0x3fdb18=_0x14723c;return getUser(_0x3fdb18,_0x34796b,_0x4dfcfe,_0x249f04[_0x5496('0x34')]);})['then'](function(_0x264135){_0x367e83=_0x264135;logger['info'](_0x5496('0x86'),_0x367e83['id']);return getEndUser(_0x3fdb18,_0x34796b,_0x4dfcfe,_0x2f99ab[_0x5496('0x8f')],_0x2f99ab[_0x5496('0x90')],_0x367e83,_0x31ced2);})[_0x5496('0x28')](function(_0x5e7d34){_0x2ee1d4=_0x5e7d34;return getCall(_0x3fdb18,_0x34796b,_0x4dfcfe,_0x367e83,_0x2ee1d4,_0x31ced2,_0x2f99ab,_0x5496('0x91'));})[_0x5496('0x28')](function(_0x4cbd54){if(_0x4cbd54){logger[_0x5496('0x35')]('The\x20Call\x20ID\x20is:',_0x4cbd54['id']);logger['info']('[OUTBOUND]','Displaying\x20call\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x5496('0x69')](_0x5496('0x92'),_0x249f04[_0x5496('0x17')]),'trigger:browser:url',{'uri':_0x5496('0x8c')+_0x4dfcfe[_0x5496('0x7d')]+_0x5496('0x93')+_0x4cbd54['id']});}})[_0x5496('0x2b')](function(_0x485cd0){logger[_0x5496('0x3c')](_0x5496('0x8e'),JSON[_0x5496('0xd')](_0x485cd0));});};exports['unmanaged']=function(_0x33cf9c,_0x3475df,_0x458772,_0xf9177a,_0x149a87,_0x4bb18d){var _0x3489d4,_0x2c7cb5,_0xdc4e74;_0x4bb18d[_0x5496('0x7d')]=intUtil[_0x5496('0x7e')](_0x4bb18d[_0x5496('0x7d')]);_0x4bb18d[_0x5496('0x7f')]=intUtil[_0x5496('0x7e')](_0x4bb18d[_0x5496('0x7f')]);if(_0x149a87&&_0x149a87['monitor_format']){logger['info']('['+_0x3475df[_0x5496('0x6a')]['toUpperCase']()+']',_0x5496('0x80'));_0x3475df[_0x5496('0x81')]=_0x4bb18d[_0x5496('0x7f')]+_0x5496('0x82')+_0x3475df[_0x5496('0x83')]+'/downloads?type=uniqueid&token='+md5(_0x3475df['uniqueid']);}else{_0x3475df[_0x5496('0x81')]='';}var _0x1fbeca=_0x4bb18d[_0x5496('0x7d')]==='zoho.eu'?'eu':'com';return getAccessToken(_0x4bb18d)[_0x5496('0x28')](function(_0x5f4a83){_0xdc4e74=_0x5f4a83;return getUser(_0xdc4e74,_0x1fbeca,_0x4bb18d);})[_0x5496('0x28')](function(_0x38e42e){_0x3489d4=_0x38e42e;logger['info'](_0x5496('0x86'),_0x3489d4['id']);return getEndUser(_0xdc4e74,_0x1fbeca,_0x4bb18d,_0x3475df[_0x5496('0x94')],_0x3475df[_0x5496('0x87')],_0x3489d4,_0x458772);})['then'](function(_0x349ae0){_0x2c7cb5=_0x349ae0;return getCall(_0xdc4e74,_0x1fbeca,_0x4bb18d,_0x3489d4,_0x2c7cb5,_0x458772,_0x3475df,_0x5496('0x76'));})['then'](function(_0x320bb4){if(_0x320bb4){logger[_0x5496('0x35')](_0x5496('0x88'),_0x320bb4['id']);}})[_0x5496('0x2b')](function(_0x4ff860){logger['error']('['+_0x3475df[_0x5496('0x6a')][_0x5496('0x95')]()+']',JSON[_0x5496('0xd')](_0x4ff860));});};