941254760acbe7301b89c49e356007a284601bd2
[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 _0x4777=['ProjectName','project','ndagenerate_audio','AudioOutputSettings','custom_action','custom_action_data','info','stringify','request-promise','agi','exports','POST','resolve','ndauth_url','/token','password','username','then','ndassistant_url','ndaactivity_type','message','Nda','callerid','calleridname','dnid','body','channelData'];(function(_0x44a7d2,_0x542c2){var _0x4b72f9=function(_0x4329ec){while(--_0x4329ec){_0x44a7d2['push'](_0x44a7d2['shift']());}};_0x4b72f9(++_0x542c2);}(_0x4777,0x1ee));var _0x7477=function(_0x58afd5,_0x534a48){_0x58afd5=_0x58afd5-0x0;var _0x3e503b=_0x4777[_0x58afd5];return _0x3e503b;};'use strict';var rp=require(_0x7477('0x0'));var url=require('url');var logger=require('../../../../../config/logger')(_0x7477('0x1'));module[_0x7477('0x2')]=function(_0x150fd7,_0x1580fc){var _0x25af34={'method':_0x7477('0x3'),'uri':url[_0x7477('0x4')](_0x1580fc[_0x7477('0x5')],_0x7477('0x6')),'form':{'grant_type':_0x7477('0x7'),'username':_0x1580fc[_0x7477('0x8')],'password':_0x1580fc[_0x7477('0x7')]},'json':!![]};return rp(_0x25af34)[_0x7477('0x9')](function(_0x42ccab){var _0x1d8013={'method':_0x7477('0x3'),'uri':url[_0x7477('0x4')](_0x1580fc[_0x7477('0xa')],'/api/NaturalDialogAssistant/v1/Run'),'body':{'type':_0x1580fc[_0x7477('0xb')]||_0x7477('0xc'),'channelId':_0x7477('0xd'),'conversation':{'id':_0x150fd7['uniqueid']},'from':{'id':_0x150fd7[_0x7477('0xe')],'name':_0x150fd7[_0x7477('0xf')]},'recipient':{'id':_0x150fd7[_0x7477('0x10')],'name':_0x150fd7['extension']},'text':_0x1580fc['text'],'channelData':{}},'headers':{'Authorization':'Bearer\x20'+_0x42ccab['access_token']},'json':!![]};if(_0x1580fc['project']){_0x1d8013[_0x7477('0x11')][_0x7477('0x12')][_0x7477('0x13')]=_0x1580fc[_0x7477('0x14')];}if(_0x1580fc[_0x7477('0x15')]=='1'){_0x1d8013['body'][_0x7477('0x12')][_0x7477('0x16')]={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':'audio/wav'};}if(_0x1580fc['custom_action']){_0x1d8013[_0x7477('0x11')][_0x7477('0x12')]['CustomAction']=_0x1580fc[_0x7477('0x17')];if(_0x1580fc[_0x7477('0x18')]){_0x1d8013[_0x7477('0x11')][_0x7477('0x12')]['CustomActionData']=_0x1580fc[_0x7477('0x18')];}}logger[_0x7477('0x19')](JSON[_0x7477('0x1a')](_0x1d8013));return rp(_0x1d8013);});};