f4416dca1de200fb4857fa8ae4f7836bcd387278
[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 _0xc5f7=['url','POST','ndauth_url','password','username','ndassistant_url','ndaactivity_type','Nda','uniqueid','callerid','dnid','text','Bearer\x20','access_token','body','channelData','ProjectName','project','AudioOutputSettings','audio/wav','custom_action','CustomActionData','custom_action_data','stringify','request-promise'];(function(_0x2112d4,_0x3c863c){var _0x434972=function(_0x477020){while(--_0x477020){_0x2112d4['push'](_0x2112d4['shift']());}};_0x434972(++_0x3c863c);}(_0xc5f7,0x18f));var _0x7c5f=function(_0x259a2d,_0x1eec31){_0x259a2d=_0x259a2d-0x0;var _0x8c103e=_0xc5f7[_0x259a2d];return _0x8c103e;};'use strict';var rp=require(_0x7c5f('0x0'));var url=require(_0x7c5f('0x1'));var logger=require('../../../../../config/logger')('agi');module['exports']=function(_0xde9a03,_0x11b69b){var _0x1c65ed={'method':_0x7c5f('0x2'),'uri':url['resolve'](_0x11b69b[_0x7c5f('0x3')],'/token'),'form':{'grant_type':_0x7c5f('0x4'),'username':_0x11b69b[_0x7c5f('0x5')],'password':_0x11b69b[_0x7c5f('0x4')]},'json':!![]};return rp(_0x1c65ed)['then'](function(_0xb06ab5){var _0x43bdf4={'method':'POST','uri':url['resolve'](_0x11b69b[_0x7c5f('0x6')],'/api/NaturalDialogAssistant/v1/Run'),'body':{'type':_0x11b69b[_0x7c5f('0x7')]||'message','channelId':_0x7c5f('0x8'),'conversation':{'id':_0xde9a03[_0x7c5f('0x9')]},'from':{'id':_0xde9a03[_0x7c5f('0xa')],'name':_0xde9a03['calleridname']},'recipient':{'id':_0xde9a03[_0x7c5f('0xb')],'name':_0xde9a03['extension']},'text':_0x11b69b[_0x7c5f('0xc')],'channelData':{}},'headers':{'Authorization':_0x7c5f('0xd')+_0xb06ab5[_0x7c5f('0xe')]},'json':!![]};if(_0x11b69b['project']){_0x43bdf4[_0x7c5f('0xf')][_0x7c5f('0x10')][_0x7c5f('0x11')]=_0x11b69b[_0x7c5f('0x12')];}if(_0x11b69b['ndagenerate_audio']=='1'){_0x43bdf4[_0x7c5f('0xf')]['channelData'][_0x7c5f('0x13')]={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':_0x7c5f('0x14')};}if(_0x11b69b[_0x7c5f('0x15')]){_0x43bdf4[_0x7c5f('0xf')][_0x7c5f('0x10')]['CustomAction']=_0x11b69b[_0x7c5f('0x15')];if(_0x11b69b['custom_action_data']){_0x43bdf4[_0x7c5f('0xf')][_0x7c5f('0x10')][_0x7c5f('0x16')]=_0x11b69b[_0x7c5f('0x17')];}}logger['info'](JSON[_0x7c5f('0x18')](_0x43bdf4));return rp(_0x43bdf4);});};