moving copilot work under common folder and adding _studio_dependencies
57
copilot/_studio_dependencies/ProxyScript/copilot.js
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
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: {}
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 533 B After Width: | Height: | Size: 533 B |
|
Before Width: | Height: | Size: 961 B After Width: | Height: | Size: 961 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |