Hello Rasa Community,
I’m currently facing an issue with passing data from a custom action to my external Node.js server. I’ve configured my endpoints.yml
file as follows:
action_endpoint:
url: "http://localhost:5055/webhook"
cors:
enable: true
allow_origin: "*"
And this is my Node.js server code:
const express = require("express");
const cors = require("cors");
const morgan = require('morgan');
const app = express();
app.use(express.json());
app.use(cors());
app.use(morgan('dev'));
app.post("/webhook", (req, res) => {
try {
// Get data from Rasa action request
const { action, domain, sender, session_id, tracker } = req.body;
console.log('Tracks', action, domain, sender, session_id, tracker);
// Custom logic for handling Rasa actions
// Example: Send a response back to Rasa
const response = {
events: [],
responses: {
your_action_name: "Hello, this is your custom action response.",
},
};
res.json(response);
} catch (error) {
console.error(error);
res.status(500).json({ error: "An error occurred" });
}
});
app.use("*", (req, res) => {
return res.status(404).json({
events: [],
responses: {
your_action_name: "This route is not available.",
},
})
})
app.listen(5055, () => {
console.log("Listening :)");
});
My problem is that when I trigger the custom action, it reaches my external server, but I don’t receive the expected data in the console.log('Tracks', action, domain, sender, session_id, tracker);
. Instead, all I get is the raw message sent from the user in JSON format:
{
message: "Message sent from user"
}
The custom action involves a form, and I need access to its data on my external server. Any assistance in resolving this issue would be greatly appreciated.
Thank you for your help! If you need any additional information, please let me know.