Built motion from commit a679711e.|2.6.15
[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 _0x3df4=['callerid','calleridname','dnid','extension','text','access_token','project','channelData','ndagenerate_audio','custom_action','body','CustomAction','custom_action_data','CustomActionData','info','../../../../../config/logger','agi','exports','POST','/token','password','username','resolve','ndassistant_url','ndaactivity_type','Nda','uniqueid'];(function(_0x56e383,_0x2f844f){var _0x4a2156=function(_0x34f534){while(--_0x34f534){_0x56e383['push'](_0x56e383['shift']());}};_0x4a2156(++_0x2f844f);}(_0x3df4,0x102));var _0x43df=function(_0x5a28ae,_0x31bcf3){_0x5a28ae=_0x5a28ae-0x0;var _0x2f5156=_0x3df4[_0x5a28ae];return _0x2f5156;};'use strict';var rp=require('request-promise');var url=require('url');var logger=require(_0x43df('0x0'))(_0x43df('0x1'));module[_0x43df('0x2')]=function(_0x206707,_0x38a050){var _0x2985bf={'method':_0x43df('0x3'),'uri':url['resolve'](_0x38a050['ndauth_url'],_0x43df('0x4')),'form':{'grant_type':_0x43df('0x5'),'username':_0x38a050[_0x43df('0x6')],'password':_0x38a050[_0x43df('0x5')]},'json':!![]};return rp(_0x2985bf)['then'](function(_0x5863be){var _0x2492a9={'method':_0x43df('0x3'),'uri':url[_0x43df('0x7')](_0x38a050[_0x43df('0x8')],'/api/NaturalDialogAssistant/v1/Run'),'body':{'type':_0x38a050[_0x43df('0x9')]||'message','channelId':_0x43df('0xa'),'conversation':{'id':_0x206707[_0x43df('0xb')]},'from':{'id':_0x206707[_0x43df('0xc')],'name':_0x206707[_0x43df('0xd')]},'recipient':{'id':_0x206707[_0x43df('0xe')],'name':_0x206707[_0x43df('0xf')]},'text':_0x38a050[_0x43df('0x10')],'channelData':{}},'headers':{'Authorization':'Bearer\x20'+_0x5863be[_0x43df('0x11')]},'json':!![]};if(_0x38a050[_0x43df('0x12')]){_0x2492a9['body'][_0x43df('0x13')]['ProjectName']=_0x38a050[_0x43df('0x12')];}if(_0x38a050[_0x43df('0x14')]=='1'){_0x2492a9['body'][_0x43df('0x13')]['AudioOutputSettings']={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':'audio/wav'};}if(_0x38a050[_0x43df('0x15')]){_0x2492a9[_0x43df('0x16')]['channelData'][_0x43df('0x17')]=_0x38a050['custom_action'];if(_0x38a050[_0x43df('0x18')]){_0x2492a9[_0x43df('0x16')][_0x43df('0x13')][_0x43df('0x19')]=_0x38a050[_0x43df('0x18')];}}logger[_0x43df('0x1a')](JSON['stringify'](_0x2492a9));return rp(_0x2492a9);});};