3a9e26679531032f2acd77e631d51ee3b5b7f682
[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 _0xc577=['username','then','/api/NaturalDialogAssistant/v1/Run','ndaactivity_type','message','Nda','callerid','calleridname','extension','text','Bearer\x20','access_token','project','body','channelData','AudioOutputSettings','audio/wav','custom_action','CustomAction','CustomActionData','custom_action_data','info','request-promise','agi','exports','POST','resolve','/token','password'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xc577,0x172));var _0x7c57=function(_0x1cbc47,_0x58b1e4){_0x1cbc47=_0x1cbc47-0x0;var _0x2759ff=_0xc577[_0x1cbc47];return _0x2759ff;};'use strict';var rp=require(_0x7c57('0x0'));var url=require('url');var logger=require('../../../../../config/logger')(_0x7c57('0x1'));module[_0x7c57('0x2')]=function(_0xe9a500,_0x2a2415){var _0x3abdb2={'method':_0x7c57('0x3'),'uri':url[_0x7c57('0x4')](_0x2a2415['ndauth_url'],_0x7c57('0x5')),'form':{'grant_type':_0x7c57('0x6'),'username':_0x2a2415[_0x7c57('0x7')],'password':_0x2a2415[_0x7c57('0x6')]},'json':!![]};return rp(_0x3abdb2)[_0x7c57('0x8')](function(_0x4bb81b){var _0x4e5cb2={'method':'POST','uri':url[_0x7c57('0x4')](_0x2a2415['ndassistant_url'],_0x7c57('0x9')),'body':{'type':_0x2a2415[_0x7c57('0xa')]||_0x7c57('0xb'),'channelId':_0x7c57('0xc'),'conversation':{'id':_0xe9a500['uniqueid']},'from':{'id':_0xe9a500[_0x7c57('0xd')],'name':_0xe9a500[_0x7c57('0xe')]},'recipient':{'id':_0xe9a500['dnid'],'name':_0xe9a500[_0x7c57('0xf')]},'text':_0x2a2415[_0x7c57('0x10')],'channelData':{}},'headers':{'Authorization':_0x7c57('0x11')+_0x4bb81b[_0x7c57('0x12')]},'json':!![]};if(_0x2a2415[_0x7c57('0x13')]){_0x4e5cb2[_0x7c57('0x14')][_0x7c57('0x15')]['ProjectName']=_0x2a2415['project'];}if(_0x2a2415['ndagenerate_audio']=='1'){_0x4e5cb2[_0x7c57('0x14')][_0x7c57('0x15')][_0x7c57('0x16')]={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':_0x7c57('0x17')};}if(_0x2a2415[_0x7c57('0x18')]){_0x4e5cb2[_0x7c57('0x14')][_0x7c57('0x15')][_0x7c57('0x19')]=_0x2a2415['custom_action'];if(_0x2a2415['custom_action_data']){_0x4e5cb2[_0x7c57('0x14')][_0x7c57('0x15')][_0x7c57('0x1a')]=_0x2a2415[_0x7c57('0x1b')];}}logger[_0x7c57('0x1c')](JSON['stringify'](_0x4e5cb2));return rp(_0x4e5cb2);});};