57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
/*
|
|
Proxy Script for CoPilot integration with IVAS
|
|
*/
|
|
console.log({ script: "copilot", body: req.body});
|
|
|
|
req.body.event.metadata = _.merge(req.body.event.metadata, {
|
|
channel: copilot_settings.channel
|
|
});
|
|
|
|
const messengerUrl = `${copilot_settings.nlu.apiBaseURL}ProxyScript/run/${req.params.workspaceId}/${req.params.branch}/${copilot_settings.messengerRouteName}`;
|
|
(async () => {
|
|
try {
|
|
const { data: recognizedData } = await axios({
|
|
url: messengerUrl,
|
|
method: "post",
|
|
data: req.body,
|
|
// headers: {
|
|
// Authorization: `Bearer ${copilot_settings.ops.token}`
|
|
// }
|
|
});
|
|
res.send(recognizedData);
|
|
} catch (error) {
|
|
console.log(error.message);
|
|
res.send({
|
|
answers: ['Something went wrong. Please try again.'],
|
|
outputs: {}
|
|
});
|
|
}
|
|
})();/*
|
|
Proxy Script for CoPilot integration with IVAS
|
|
*/
|
|
console.log({ script: "copilot", body: req.body});
|
|
|
|
req.body.event.metadata = _.merge(req.body.event.metadata, {
|
|
channel: copilot_settings.channel
|
|
});
|
|
|
|
const messengerUrl = `${copilot_settings.nlu.apiBaseURL}ProxyScript/run/${req.params.workspaceId}/${req.params.branch}/${copilot_settings.messengerRouteName}`;
|
|
(async () => {
|
|
try {
|
|
const { data: recognizedData } = await axios({
|
|
url: messengerUrl,
|
|
method: "post",
|
|
data: req.body,
|
|
// headers: {
|
|
// Authorization: `Bearer ${copilot_settings.ops.token}`
|
|
// }
|
|
});
|
|
res.send(recognizedData);
|
|
} catch (error) {
|
|
console.log(error.message);
|
|
res.send({
|
|
answers: ['Something went wrong. Please try again.'],
|
|
outputs: {}
|
|
});
|
|
}
|
|
})(); |