18dcb4d8e68908043a82c82ea20be3e0e13346f0
[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 _0x22dd=['CustomAction','custom_action','CustomActionData','custom_action_data','request-promise','url','../../../../../config/logger','POST','resolve','ndauth_url','/token','password','username','/api/NaturalDialogAssistant/v1/Run','message','Nda','uniqueid','callerid','calleridname','dnid','extension','text','access_token','project','channelData','ProjectName','audio/wav','body'];(function(_0x43255b,_0xcdcc19){var _0x5ab43b=function(_0xbf4c68){while(--_0xbf4c68){_0x43255b['push'](_0x43255b['shift']());}};_0x5ab43b(++_0xcdcc19);}(_0x22dd,0xe4));var _0xd22d=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x22dd[_0x3dd15e];return _0x231fd0;};'use strict';var rp=require(_0xd22d('0x0'));var url=require(_0xd22d('0x1'));var logger=require(_0xd22d('0x2'))('agi');module['exports']=function(_0x42ad34,_0x3764ac){var _0x2412eb={'method':_0xd22d('0x3'),'uri':url[_0xd22d('0x4')](_0x3764ac[_0xd22d('0x5')],_0xd22d('0x6')),'form':{'grant_type':_0xd22d('0x7'),'username':_0x3764ac[_0xd22d('0x8')],'password':_0x3764ac[_0xd22d('0x7')]},'json':!![]};return rp(_0x2412eb)['then'](function(_0x40986a){var _0x3649df={'method':'POST','uri':url[_0xd22d('0x4')](_0x3764ac['ndassistant_url'],_0xd22d('0x9')),'body':{'type':_0x3764ac['ndaactivity_type']||_0xd22d('0xa'),'channelId':_0xd22d('0xb'),'conversation':{'id':_0x42ad34[_0xd22d('0xc')]},'from':{'id':_0x42ad34[_0xd22d('0xd')],'name':_0x42ad34[_0xd22d('0xe')]},'recipient':{'id':_0x42ad34[_0xd22d('0xf')],'name':_0x42ad34[_0xd22d('0x10')]},'text':_0x3764ac[_0xd22d('0x11')],'channelData':{}},'headers':{'Authorization':'Bearer\x20'+_0x40986a[_0xd22d('0x12')]},'json':!![]};if(_0x3764ac[_0xd22d('0x13')]){_0x3649df['body'][_0xd22d('0x14')][_0xd22d('0x15')]=_0x3764ac['project'];}if(_0x3764ac['ndagenerate_audio']=='1'){_0x3649df['body'][_0xd22d('0x14')]['AudioOutputSettings']={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':_0xd22d('0x16')};}if(_0x3764ac['custom_action']){_0x3649df[_0xd22d('0x17')]['channelData'][_0xd22d('0x18')]=_0x3764ac[_0xd22d('0x19')];if(_0x3764ac['custom_action_data']){_0x3649df[_0xd22d('0x17')][_0xd22d('0x14')][_0xd22d('0x1a')]=_0x3764ac[_0xd22d('0x1b')];}}logger['info'](JSON['stringify'](_0x3649df));return rp(_0x3649df);});};