d9295885002f4cc8daf55f48569ad8a676817dae
[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 _0xb9a6=['resolve','ndassistant_url','/api/NaturalDialogAssistant/v1/Run','ndaactivity_type','message','Nda','uniqueid','callerid','dnid','extension','Bearer\x20','access_token','project','channelData','ProjectName','ndagenerate_audio','body','AudioOutputSettings','custom_action','custom_action_data','CustomActionData','info','stringify','url','../../../../../config/logger','agi','exports','POST','ndauth_url','/token','password','then'];(function(_0x209003,_0x4df2a8){var _0xf696eb=function(_0x4e0063){while(--_0x4e0063){_0x209003['push'](_0x209003['shift']());}};_0xf696eb(++_0x4df2a8);}(_0xb9a6,0x137));var _0x6b9a=function(_0x162565,_0x56dcf9){_0x162565=_0x162565-0x0;var _0x24537f=_0xb9a6[_0x162565];return _0x24537f;};'use strict';var rp=require('request-promise');var url=require(_0x6b9a('0x0'));var logger=require(_0x6b9a('0x1'))(_0x6b9a('0x2'));module[_0x6b9a('0x3')]=function(_0x296ed6,_0x1b0fee){var _0x173255={'method':_0x6b9a('0x4'),'uri':url['resolve'](_0x1b0fee[_0x6b9a('0x5')],_0x6b9a('0x6')),'form':{'grant_type':'password','username':_0x1b0fee['username'],'password':_0x1b0fee[_0x6b9a('0x7')]},'json':!![]};return rp(_0x173255)[_0x6b9a('0x8')](function(_0x380b11){var _0x2df9c0={'method':'POST','uri':url[_0x6b9a('0x9')](_0x1b0fee[_0x6b9a('0xa')],_0x6b9a('0xb')),'body':{'type':_0x1b0fee[_0x6b9a('0xc')]||_0x6b9a('0xd'),'channelId':_0x6b9a('0xe'),'conversation':{'id':_0x296ed6[_0x6b9a('0xf')]},'from':{'id':_0x296ed6[_0x6b9a('0x10')],'name':_0x296ed6['calleridname']},'recipient':{'id':_0x296ed6[_0x6b9a('0x11')],'name':_0x296ed6[_0x6b9a('0x12')]},'text':_0x1b0fee['text'],'channelData':{}},'headers':{'Authorization':_0x6b9a('0x13')+_0x380b11[_0x6b9a('0x14')]},'json':!![]};if(_0x1b0fee[_0x6b9a('0x15')]){_0x2df9c0['body'][_0x6b9a('0x16')][_0x6b9a('0x17')]=_0x1b0fee['project'];}if(_0x1b0fee[_0x6b9a('0x18')]=='1'){_0x2df9c0[_0x6b9a('0x19')][_0x6b9a('0x16')][_0x6b9a('0x1a')]={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':'audio/wav'};}if(_0x1b0fee['custom_action']){_0x2df9c0['body'][_0x6b9a('0x16')]['CustomAction']=_0x1b0fee[_0x6b9a('0x1b')];if(_0x1b0fee[_0x6b9a('0x1c')]){_0x2df9c0[_0x6b9a('0x19')]['channelData'][_0x6b9a('0x1d')]=_0x1b0fee[_0x6b9a('0x1c')];}}logger[_0x6b9a('0x1e')](JSON[_0x6b9a('0x1f')](_0x2df9c0));return rp(_0x2df9c0);});};