12911817bbebe1ba9b60d40120b0ad96be495240
[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 _0x5194=['channelData','ndagenerate_audio','AudioOutputSettings','custom_action','CustomAction','custom_action_data','stringify','../../../../../config/logger','agi','exports','POST','resolve','ndauth_url','password','username','then','ndassistant_url','/api/NaturalDialogAssistant/v1/Run','message','Nda','uniqueid','calleridname','Bearer\x20','access_token','project','body'];(function(_0x28ca08,_0x7ad7c3){var _0x3eb383=function(_0x443c8e){while(--_0x443c8e){_0x28ca08['push'](_0x28ca08['shift']());}};_0x3eb383(++_0x7ad7c3);}(_0x5194,0x173));var _0x4519=function(_0x16b9ed,_0x56517a){_0x16b9ed=_0x16b9ed-0x0;var _0x66b1f8=_0x5194[_0x16b9ed];return _0x66b1f8;};'use strict';var rp=require('request-promise');var url=require('url');var logger=require(_0x4519('0x0'))(_0x4519('0x1'));module[_0x4519('0x2')]=function(_0x4046a5,_0x2690a8){var _0x126b16={'method':_0x4519('0x3'),'uri':url[_0x4519('0x4')](_0x2690a8[_0x4519('0x5')],'/token'),'form':{'grant_type':_0x4519('0x6'),'username':_0x2690a8[_0x4519('0x7')],'password':_0x2690a8[_0x4519('0x6')]},'json':!![]};return rp(_0x126b16)[_0x4519('0x8')](function(_0x4e4537){var _0x554121={'method':'POST','uri':url[_0x4519('0x4')](_0x2690a8[_0x4519('0x9')],_0x4519('0xa')),'body':{'type':_0x2690a8['ndaactivity_type']||_0x4519('0xb'),'channelId':_0x4519('0xc'),'conversation':{'id':_0x4046a5[_0x4519('0xd')]},'from':{'id':_0x4046a5['callerid'],'name':_0x4046a5[_0x4519('0xe')]},'recipient':{'id':_0x4046a5['dnid'],'name':_0x4046a5['extension']},'text':_0x2690a8['text'],'channelData':{}},'headers':{'Authorization':_0x4519('0xf')+_0x4e4537[_0x4519('0x10')]},'json':!![]};if(_0x2690a8[_0x4519('0x11')]){_0x554121[_0x4519('0x12')][_0x4519('0x13')]['ProjectName']=_0x2690a8['project'];}if(_0x2690a8[_0x4519('0x14')]=='1'){_0x554121[_0x4519('0x12')][_0x4519('0x13')][_0x4519('0x15')]={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':'audio/wav'};}if(_0x2690a8[_0x4519('0x16')]){_0x554121['body'][_0x4519('0x13')][_0x4519('0x17')]=_0x2690a8['custom_action'];if(_0x2690a8[_0x4519('0x18')]){_0x554121[_0x4519('0x12')][_0x4519('0x13')]['CustomActionData']=_0x2690a8[_0x4519('0x18')];}}logger['info'](JSON[_0x4519('0x19')](_0x554121));return rp(_0x554121);});};