Built motion from commit (unavailable).|2.5.1
[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 _0x43dc=['stringify','url','../../../../../config/logger','agi','exports','resolve','ndauth_url','/token','POST','ndassistant_url','/api/NaturalDialogAssistant/v1/Run','ndaactivity_type','calleridname','dnid','extension','text','access_token','project','body','ProjectName','ndagenerate_audio','audio/wav','custom_action','channelData','CustomAction','CustomActionData','custom_action_data','info'];(function(_0x5cca9f,_0x154684){var _0x55edda=function(_0x115aa2){while(--_0x115aa2){_0x5cca9f['push'](_0x5cca9f['shift']());}};_0x55edda(++_0x154684);}(_0x43dc,0xa9));var _0xc43d=function(_0x4a53d,_0x58a95e){_0x4a53d=_0x4a53d-0x0;var _0x27410e=_0x43dc[_0x4a53d];return _0x27410e;};'use strict';var rp=require('request-promise');var url=require(_0xc43d('0x0'));var logger=require(_0xc43d('0x1'))(_0xc43d('0x2'));module[_0xc43d('0x3')]=function(_0x202d9b,_0x52f9c7){var _0x22b4fe={'method':'POST','uri':url[_0xc43d('0x4')](_0x52f9c7[_0xc43d('0x5')],_0xc43d('0x6')),'form':{'grant_type':'password','username':_0x52f9c7['username'],'password':_0x52f9c7['password']},'json':!![]};return rp(_0x22b4fe)['then'](function(_0x1e8732){var _0x563bf2={'method':_0xc43d('0x7'),'uri':url['resolve'](_0x52f9c7[_0xc43d('0x8')],_0xc43d('0x9')),'body':{'type':_0x52f9c7[_0xc43d('0xa')]||'message','channelId':'Nda','conversation':{'id':_0x202d9b['uniqueid']},'from':{'id':_0x202d9b['callerid'],'name':_0x202d9b[_0xc43d('0xb')]},'recipient':{'id':_0x202d9b[_0xc43d('0xc')],'name':_0x202d9b[_0xc43d('0xd')]},'text':_0x52f9c7[_0xc43d('0xe')],'channelData':{}},'headers':{'Authorization':'Bearer\x20'+_0x1e8732[_0xc43d('0xf')]},'json':!![]};if(_0x52f9c7[_0xc43d('0x10')]){_0x563bf2[_0xc43d('0x11')]['channelData'][_0xc43d('0x12')]=_0x52f9c7['project'];}if(_0x52f9c7[_0xc43d('0x13')]=='1'){_0x563bf2['body']['channelData']['AudioOutputSettings']={'Generate':!![],'PutInStructuredPart':![],'ExpectedFormat':_0xc43d('0x14')};}if(_0x52f9c7[_0xc43d('0x15')]){_0x563bf2[_0xc43d('0x11')][_0xc43d('0x16')][_0xc43d('0x17')]=_0x52f9c7['custom_action'];if(_0x52f9c7['custom_action_data']){_0x563bf2['body'][_0xc43d('0x16')][_0xc43d('0x18')]=_0x52f9c7[_0xc43d('0x19')];}}logger[_0xc43d('0x1a')](JSON[_0xc43d('0x1b')](_0x563bf2));return rp(_0x563bf2);});};