b3bec7462aea0f3759e81268f9775b6cee3b4ecd
[motion2.git] / server / services / agi / scripts / sestek / nda / index.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 _0xe3ee=['project','ProjectName','body','channelData','AudioOutputSettings','custom_action','custom_action_data','stringify','../../../../../config/logger','agi','resolve','/token','password','username','then','POST','ndassistant_url','/api/NaturalDialogAssistant/v1/Run','message','Nda','callerid','calleridname','dnid','extension','text','Bearer\x20','access_token'];(function(_0x2d92d8,_0xb4ed29){var _0x5a3e7a=function(_0x3f8d0a){while(--_0x3f8d0a){_0x2d92d8['push'](_0x2d92d8['shift']());}};_0x5a3e7a(++_0xb4ed29);}(_0xe3ee,0x116));var _0xee3e=function(_0xc05a59,_0x1fd2b4){_0xc05a59=_0xc05a59-0x0;var _0x3115f5=_0xe3ee[_0xc05a59];return _0x3115f5;};'use strict';var rp=require('request-promise');var url=require('url');var logger=require(_0xee3e('0x0'))(_0xee3e('0x1'));module['exports']=function(_0x52bcf2,_0x45bf25){var _0x4a7031={'method':'POST','uri':url[_0xee3e('0x2')](_0x45bf25['ndauth_url'],_0xee3e('0x3')),'form':{'grant_type':_0xee3e('0x4'),'username':_0x45bf25[_0xee3e('0x5')],'password':_0x45bf25[_0xee3e('0x4')]},'json':!![]};return rp(_0x4a7031)[_0xee3e('0x6')](function(_0x39a770){var _0x43ab67={'method':_0xee3e('0x7'),'uri':url['resolve'](_0x45bf25[_0xee3e('0x8')],_0xee3e('0x9')),'body':{'type':_0x45bf25['ndaactivity_type']||_0xee3e('0xa'),'channelId':_0xee3e('0xb'),'conversation':{'id':_0x52bcf2['uniqueid']},'from':{'id':_0x52bcf2[_0xee3e('0xc')],'name':_0x52bcf2[_0xee3e('0xd')]},'recipient':{'id':_0x52bcf2[_0xee3e('0xe')],'name':_0x52bcf2[_0xee3e('0xf')]},'text':_0x45bf25[_0xee3e('0x10')],'channelData':{}},'headers':{'Authorization':_0xee3e('0x11')+_0x39a770[_0xee3e('0x12')]},'json':!![]};if(_0x45bf25[_0xee3e('0x13')]){_0x43ab67['body']['channelData'][_0xee3e('0x14')]=_0x45bf25[_0xee3e('0x13')];}if(_0x45bf25['ndagenerate_audio']=='1'){_0x43ab67[_0xee3e('0x15')][_0xee3e('0x16')][_0xee3e('0x17')]={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':'audio/wav'};}if(_0x45bf25[_0xee3e('0x18')]){_0x43ab67[_0xee3e('0x15')]['channelData']['CustomAction']=_0x45bf25[_0xee3e('0x18')];if(_0x45bf25[_0xee3e('0x19')]){_0x43ab67[_0xee3e('0x15')]['channelData']['CustomActionData']=_0x45bf25['custom_action_data'];}}logger['info'](JSON[_0xee3e('0x1a')](_0x43ab67));return rp(_0x43ab67);});};