84988c185a40a98db0fcb1f6cd78d6a0c02eba63
[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 _0xcd31=['dnid','extension','text','Bearer\x20','project','channelData','ProjectName','AudioOutputSettings','audio/wav','body','CustomAction','custom_action','stringify','url','../../../../../config/logger','agi','POST','resolve','ndauth_url','password','username','ndassistant_url','/api/NaturalDialogAssistant/v1/Run','ndaactivity_type','message','Nda','uniqueid','callerid'];(function(_0x2bca15,_0x23fc22){var _0xed9bda=function(_0xf65cc6){while(--_0xf65cc6){_0x2bca15['push'](_0x2bca15['shift']());}};_0xed9bda(++_0x23fc22);}(_0xcd31,0x15d));var _0x1cd3=function(_0x1c9d5f,_0x5ee458){_0x1c9d5f=_0x1c9d5f-0x0;var _0x2bf1ff=_0xcd31[_0x1c9d5f];return _0x2bf1ff;};'use strict';var rp=require('request-promise');var url=require(_0x1cd3('0x0'));var logger=require(_0x1cd3('0x1'))(_0x1cd3('0x2'));module['exports']=function(_0x3da1e3,_0x19dd0c){var _0x2526ea={'method':_0x1cd3('0x3'),'uri':url[_0x1cd3('0x4')](_0x19dd0c[_0x1cd3('0x5')],'/token'),'form':{'grant_type':_0x1cd3('0x6'),'username':_0x19dd0c[_0x1cd3('0x7')],'password':_0x19dd0c[_0x1cd3('0x6')]},'json':!![]};return rp(_0x2526ea)['then'](function(_0x45cc24){var _0x11b139={'method':_0x1cd3('0x3'),'uri':url['resolve'](_0x19dd0c[_0x1cd3('0x8')],_0x1cd3('0x9')),'body':{'type':_0x19dd0c[_0x1cd3('0xa')]||_0x1cd3('0xb'),'channelId':_0x1cd3('0xc'),'conversation':{'id':_0x3da1e3[_0x1cd3('0xd')]},'from':{'id':_0x3da1e3[_0x1cd3('0xe')],'name':_0x3da1e3['calleridname']},'recipient':{'id':_0x3da1e3[_0x1cd3('0xf')],'name':_0x3da1e3[_0x1cd3('0x10')]},'text':_0x19dd0c[_0x1cd3('0x11')],'channelData':{}},'headers':{'Authorization':_0x1cd3('0x12')+_0x45cc24['access_token']},'json':!![]};if(_0x19dd0c[_0x1cd3('0x13')]){_0x11b139['body'][_0x1cd3('0x14')][_0x1cd3('0x15')]=_0x19dd0c[_0x1cd3('0x13')];}if(_0x19dd0c['ndagenerate_audio']=='1'){_0x11b139['body'][_0x1cd3('0x14')][_0x1cd3('0x16')]={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':_0x1cd3('0x17')};}if(_0x19dd0c['custom_action']){_0x11b139[_0x1cd3('0x18')][_0x1cd3('0x14')][_0x1cd3('0x19')]=_0x19dd0c[_0x1cd3('0x1a')];if(_0x19dd0c['custom_action_data']){_0x11b139['body']['channelData']['CustomActionData']=_0x19dd0c['custom_action_data'];}}logger['info'](JSON[_0x1cd3('0x1b')](_0x11b139));return rp(_0x11b139);});};