3a8e30a8e98fb01a5082ce2fe33c4e094679657d
[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 _0x2419=['audio/wav','custom_action','custom_action_data','request-promise','url','../../../../../config/logger','agi','exports','POST','resolve','ndauth_url','/token','password','then','ndassistant_url','ndaactivity_type','message','uniqueid','callerid','calleridname','Bearer\x20','access_token','body','channelData','project','ndagenerate_audio'];(function(_0x38f6bc,_0x10832a){var _0x209b27=function(_0xa85571){while(--_0xa85571){_0x38f6bc['push'](_0x38f6bc['shift']());}};_0x209b27(++_0x10832a);}(_0x2419,0xed));var _0x9241=function(_0x279624,_0x555b65){_0x279624=_0x279624-0x0;var _0x533513=_0x2419[_0x279624];return _0x533513;};'use strict';var rp=require(_0x9241('0x0'));var url=require(_0x9241('0x1'));var logger=require(_0x9241('0x2'))(_0x9241('0x3'));module[_0x9241('0x4')]=function(_0x51f021,_0x1441e2){var _0xd12308={'method':_0x9241('0x5'),'uri':url[_0x9241('0x6')](_0x1441e2[_0x9241('0x7')],_0x9241('0x8')),'form':{'grant_type':_0x9241('0x9'),'username':_0x1441e2['username'],'password':_0x1441e2['password']},'json':!![]};return rp(_0xd12308)[_0x9241('0xa')](function(_0x197d02){var _0x230690={'method':_0x9241('0x5'),'uri':url['resolve'](_0x1441e2[_0x9241('0xb')],'/api/NaturalDialogAssistant/v1/Run'),'body':{'type':_0x1441e2[_0x9241('0xc')]||_0x9241('0xd'),'channelId':'Nda','conversation':{'id':_0x51f021[_0x9241('0xe')]},'from':{'id':_0x51f021[_0x9241('0xf')],'name':_0x51f021[_0x9241('0x10')]},'recipient':{'id':_0x51f021['dnid'],'name':_0x51f021['extension']},'text':_0x1441e2['text'],'channelData':{}},'headers':{'Authorization':_0x9241('0x11')+_0x197d02[_0x9241('0x12')]},'json':!![]};if(_0x1441e2['project']){_0x230690[_0x9241('0x13')][_0x9241('0x14')]['ProjectName']=_0x1441e2[_0x9241('0x15')];}if(_0x1441e2[_0x9241('0x16')]=='1'){_0x230690['body']['channelData']['AudioOutputSettings']={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':_0x9241('0x17')};}if(_0x1441e2[_0x9241('0x18')]){_0x230690[_0x9241('0x13')]['channelData']['CustomAction']=_0x1441e2[_0x9241('0x18')];if(_0x1441e2[_0x9241('0x19')]){_0x230690['body'][_0x9241('0x14')]['CustomActionData']=_0x1441e2[_0x9241('0x19')];}}logger['info'](JSON['stringify'](_0x230690));return rp(_0x230690);});};