22a006a52ca26d847b7a15f133f4b515b790a1a8
[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 _0xe3d4=['project','body','channelData','ProjectName','ndagenerate_audio','AudioOutputSettings','audio/wav','CustomAction','custom_action','custom_action_data','CustomActionData','info','url','../../../../../config/logger','agi','POST','ndauth_url','/token','username','password','resolve','ndassistant_url','/api/NaturalDialogAssistant/v1/Run','Nda','uniqueid','callerid','calleridname','dnid','extension','Bearer\x20','access_token'];(function(_0x1692ac,_0x1c86f9){var _0x2b3046=function(_0x5d662a){while(--_0x5d662a){_0x1692ac['push'](_0x1692ac['shift']());}};_0x2b3046(++_0x1c86f9);}(_0xe3d4,0xc6));var _0x4e3d=function(_0x302b5e,_0x564a8e){_0x302b5e=_0x302b5e-0x0;var _0x523ab7=_0xe3d4[_0x302b5e];return _0x523ab7;};'use strict';var rp=require('request-promise');var url=require(_0x4e3d('0x0'));var logger=require(_0x4e3d('0x1'))(_0x4e3d('0x2'));module['exports']=function(_0x327f5a,_0x349efe){var _0x5a7634={'method':_0x4e3d('0x3'),'uri':url['resolve'](_0x349efe[_0x4e3d('0x4')],_0x4e3d('0x5')),'form':{'grant_type':'password','username':_0x349efe[_0x4e3d('0x6')],'password':_0x349efe[_0x4e3d('0x7')]},'json':!![]};return rp(_0x5a7634)['then'](function(_0x40b814){var _0x4275b0={'method':_0x4e3d('0x3'),'uri':url[_0x4e3d('0x8')](_0x349efe[_0x4e3d('0x9')],_0x4e3d('0xa')),'body':{'type':_0x349efe['ndaactivity_type']||'message','channelId':_0x4e3d('0xb'),'conversation':{'id':_0x327f5a[_0x4e3d('0xc')]},'from':{'id':_0x327f5a[_0x4e3d('0xd')],'name':_0x327f5a[_0x4e3d('0xe')]},'recipient':{'id':_0x327f5a[_0x4e3d('0xf')],'name':_0x327f5a[_0x4e3d('0x10')]},'text':_0x349efe['text'],'channelData':{}},'headers':{'Authorization':_0x4e3d('0x11')+_0x40b814[_0x4e3d('0x12')]},'json':!![]};if(_0x349efe[_0x4e3d('0x13')]){_0x4275b0[_0x4e3d('0x14')][_0x4e3d('0x15')][_0x4e3d('0x16')]=_0x349efe[_0x4e3d('0x13')];}if(_0x349efe[_0x4e3d('0x17')]=='1'){_0x4275b0['body'][_0x4e3d('0x15')][_0x4e3d('0x18')]={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':_0x4e3d('0x19')};}if(_0x349efe['custom_action']){_0x4275b0[_0x4e3d('0x14')][_0x4e3d('0x15')][_0x4e3d('0x1a')]=_0x349efe[_0x4e3d('0x1b')];if(_0x349efe[_0x4e3d('0x1c')]){_0x4275b0[_0x4e3d('0x14')][_0x4e3d('0x15')][_0x4e3d('0x1d')]=_0x349efe['custom_action_data'];}}logger[_0x4e3d('0x1e')](JSON['stringify'](_0x4275b0));return rp(_0x4275b0);});};