Built motion from commit 616d3211.|2.6.4
[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 _0x8a9a=['exports','ndauth_url','/token','password','username','POST','resolve','ndassistant_url','/api/NaturalDialogAssistant/v1/Run','ndaactivity_type','message','uniqueid','calleridname','extension','text','Bearer\x20','access_token','project','body','channelData','AudioOutputSettings','audio/wav','custom_action','custom_action_data','stringify','../../../../../config/logger','agi'];(function(_0x18daeb,_0x1b8ff3){var _0x425a30=function(_0x271e0c){while(--_0x271e0c){_0x18daeb['push'](_0x18daeb['shift']());}};_0x425a30(++_0x1b8ff3);}(_0x8a9a,0x193));var _0xa8a9=function(_0x45d55e,_0x2fede3){_0x45d55e=_0x45d55e-0x0;var _0x29812a=_0x8a9a[_0x45d55e];return _0x29812a;};'use strict';var rp=require('request-promise');var url=require('url');var logger=require(_0xa8a9('0x0'))(_0xa8a9('0x1'));module[_0xa8a9('0x2')]=function(_0x587940,_0x317f5c){var _0x46204c={'method':'POST','uri':url['resolve'](_0x317f5c[_0xa8a9('0x3')],_0xa8a9('0x4')),'form':{'grant_type':_0xa8a9('0x5'),'username':_0x317f5c[_0xa8a9('0x6')],'password':_0x317f5c[_0xa8a9('0x5')]},'json':!![]};return rp(_0x46204c)['then'](function(_0x47fda8){var _0x4414c6={'method':_0xa8a9('0x7'),'uri':url[_0xa8a9('0x8')](_0x317f5c[_0xa8a9('0x9')],_0xa8a9('0xa')),'body':{'type':_0x317f5c[_0xa8a9('0xb')]||_0xa8a9('0xc'),'channelId':'Nda','conversation':{'id':_0x587940[_0xa8a9('0xd')]},'from':{'id':_0x587940['callerid'],'name':_0x587940[_0xa8a9('0xe')]},'recipient':{'id':_0x587940['dnid'],'name':_0x587940[_0xa8a9('0xf')]},'text':_0x317f5c[_0xa8a9('0x10')],'channelData':{}},'headers':{'Authorization':_0xa8a9('0x11')+_0x47fda8[_0xa8a9('0x12')]},'json':!![]};if(_0x317f5c[_0xa8a9('0x13')]){_0x4414c6[_0xa8a9('0x14')]['channelData']['ProjectName']=_0x317f5c[_0xa8a9('0x13')];}if(_0x317f5c['ndagenerate_audio']=='1'){_0x4414c6[_0xa8a9('0x14')][_0xa8a9('0x15')][_0xa8a9('0x16')]={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':_0xa8a9('0x17')};}if(_0x317f5c[_0xa8a9('0x18')]){_0x4414c6['body'][_0xa8a9('0x15')]['CustomAction']=_0x317f5c[_0xa8a9('0x18')];if(_0x317f5c['custom_action_data']){_0x4414c6[_0xa8a9('0x14')][_0xa8a9('0x15')]['CustomActionData']=_0x317f5c[_0xa8a9('0x19')];}}logger['info'](JSON[_0xa8a9('0x1a')](_0x4414c6));return rp(_0x4414c6);});};