35b19211320e40083089546c39879129497707c6
[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 _0x02f7=['callerid','extension','text','Bearer\x20','project','body','ProjectName','ndagenerate_audio','channelData','AudioOutputSettings','audio/wav','CustomAction','custom_action','custom_action_data','CustomActionData','info','stringify','request-promise','url','../../../../../config/logger','exports','POST','resolve','password','then','ndassistant_url','/api/NaturalDialogAssistant/v1/Run','ndaactivity_type','Nda','uniqueid'];(function(_0x54d719,_0xd23fa1){var _0x4cbf09=function(_0x5dfeb7){while(--_0x5dfeb7){_0x54d719['push'](_0x54d719['shift']());}};_0x4cbf09(++_0xd23fa1);}(_0x02f7,0x1d3));var _0x702f=function(_0x409b87,_0x5ef488){_0x409b87=_0x409b87-0x0;var _0x46fa68=_0x02f7[_0x409b87];return _0x46fa68;};'use strict';var rp=require(_0x702f('0x0'));var url=require(_0x702f('0x1'));var logger=require(_0x702f('0x2'))('agi');module[_0x702f('0x3')]=function(_0x3cf515,_0x22e5e4){var _0x1a4bb0={'method':_0x702f('0x4'),'uri':url[_0x702f('0x5')](_0x22e5e4['ndauth_url'],'/token'),'form':{'grant_type':_0x702f('0x6'),'username':_0x22e5e4['username'],'password':_0x22e5e4[_0x702f('0x6')]},'json':!![]};return rp(_0x1a4bb0)[_0x702f('0x7')](function(_0x405a6c){var _0xfe27d7={'method':_0x702f('0x4'),'uri':url['resolve'](_0x22e5e4[_0x702f('0x8')],_0x702f('0x9')),'body':{'type':_0x22e5e4[_0x702f('0xa')]||'message','channelId':_0x702f('0xb'),'conversation':{'id':_0x3cf515[_0x702f('0xc')]},'from':{'id':_0x3cf515[_0x702f('0xd')],'name':_0x3cf515['calleridname']},'recipient':{'id':_0x3cf515['dnid'],'name':_0x3cf515[_0x702f('0xe')]},'text':_0x22e5e4[_0x702f('0xf')],'channelData':{}},'headers':{'Authorization':_0x702f('0x10')+_0x405a6c['access_token']},'json':!![]};if(_0x22e5e4[_0x702f('0x11')]){_0xfe27d7[_0x702f('0x12')]['channelData'][_0x702f('0x13')]=_0x22e5e4[_0x702f('0x11')];}if(_0x22e5e4[_0x702f('0x14')]=='1'){_0xfe27d7[_0x702f('0x12')][_0x702f('0x15')][_0x702f('0x16')]={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':_0x702f('0x17')};}if(_0x22e5e4['custom_action']){_0xfe27d7[_0x702f('0x12')][_0x702f('0x15')][_0x702f('0x18')]=_0x22e5e4[_0x702f('0x19')];if(_0x22e5e4[_0x702f('0x1a')]){_0xfe27d7['body']['channelData'][_0x702f('0x1b')]=_0x22e5e4['custom_action_data'];}}logger[_0x702f('0x1c')](JSON[_0x702f('0x1d')](_0xfe27d7));return rp(_0xfe27d7);});};