980fb460a1d68b8d983453b3152a9a562ad3dcb0
[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 _0xa5fa=['ndagenerate_audio','channelData','AudioOutputSettings','audio/wav','CustomAction','custom_action','custom_action_data','CustomActionData','info','stringify','url','../../../../../config/logger','agi','exports','resolve','ndauth_url','/token','password','username','then','POST','/api/NaturalDialogAssistant/v1/Run','ndaactivity_type','uniqueid','dnid','text','Bearer\x20','access_token','project','body','ProjectName'];(function(_0x52867e,_0x5a5d15){var _0x523893=function(_0xc93c0a){while(--_0xc93c0a){_0x52867e['push'](_0x52867e['shift']());}};_0x523893(++_0x5a5d15);}(_0xa5fa,0xc4));var _0xaa5f=function(_0x128e7e,_0x2f9b63){_0x128e7e=_0x128e7e-0x0;var _0x4ab22e=_0xa5fa[_0x128e7e];return _0x4ab22e;};'use strict';var rp=require('request-promise');var url=require(_0xaa5f('0x0'));var logger=require(_0xaa5f('0x1'))(_0xaa5f('0x2'));module[_0xaa5f('0x3')]=function(_0x499d69,_0x3e56f9){var _0x106128={'method':'POST','uri':url[_0xaa5f('0x4')](_0x3e56f9[_0xaa5f('0x5')],_0xaa5f('0x6')),'form':{'grant_type':_0xaa5f('0x7'),'username':_0x3e56f9[_0xaa5f('0x8')],'password':_0x3e56f9[_0xaa5f('0x7')]},'json':!![]};return rp(_0x106128)[_0xaa5f('0x9')](function(_0xc326df){var _0x74f64f={'method':_0xaa5f('0xa'),'uri':url[_0xaa5f('0x4')](_0x3e56f9['ndassistant_url'],_0xaa5f('0xb')),'body':{'type':_0x3e56f9[_0xaa5f('0xc')]||'message','channelId':'Nda','conversation':{'id':_0x499d69[_0xaa5f('0xd')]},'from':{'id':_0x499d69['callerid'],'name':_0x499d69['calleridname']},'recipient':{'id':_0x499d69[_0xaa5f('0xe')],'name':_0x499d69['extension']},'text':_0x3e56f9[_0xaa5f('0xf')],'channelData':{}},'headers':{'Authorization':_0xaa5f('0x10')+_0xc326df[_0xaa5f('0x11')]},'json':!![]};if(_0x3e56f9[_0xaa5f('0x12')]){_0x74f64f[_0xaa5f('0x13')]['channelData'][_0xaa5f('0x14')]=_0x3e56f9['project'];}if(_0x3e56f9[_0xaa5f('0x15')]=='1'){_0x74f64f[_0xaa5f('0x13')][_0xaa5f('0x16')][_0xaa5f('0x17')]={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':_0xaa5f('0x18')};}if(_0x3e56f9['custom_action']){_0x74f64f['body'][_0xaa5f('0x16')][_0xaa5f('0x19')]=_0x3e56f9[_0xaa5f('0x1a')];if(_0x3e56f9[_0xaa5f('0x1b')]){_0x74f64f[_0xaa5f('0x13')][_0xaa5f('0x16')][_0xaa5f('0x1c')]=_0x3e56f9[_0xaa5f('0x1b')];}}logger[_0xaa5f('0x1d')](JSON[_0xaa5f('0x1e')](_0x74f64f));return rp(_0x74f64f);});};