- Iniziato a scrivere la CHATBOT...

This commit is contained in:
Surya Paolo
2025-08-09 00:48:50 +02:00
parent 32210bb96a
commit e3db42dcbc
5 changed files with 218 additions and 94 deletions

View File

@@ -15,6 +15,8 @@ const Author = require('../models/author');
const tools = require('../tools/general');
const axios = require('axios');
router.post('/test-lungo', authenticate, (req, res) => {
const timeout = req.body.timeout;
@@ -453,4 +455,19 @@ router.post('/search-books', authenticate, async (req, res) => {
}
});
router.post('/chatbot', authenticate, async (req, res) => {
try {
const response = await axios.post('http://localhost:5005/webhooks/rest/webhook', {
sender: 'user',
message: req.body.payload.message,
});
res.json(response.data);
} catch (error) {
console.error(error);
res.status(500).send('Errore nella comunicazione con Rasa');
}
});
module.exports = router;