Updating folder name

This commit is contained in:
Peter Morton 2025-08-07 11:12:00 -05:00
parent 5a722a4d65
commit db79b2147b
4 changed files with 20 additions and 41 deletions

View File

@ -27,9 +27,7 @@ const app = {
console.log(`Checking route: ${route.regexp}`); console.log(`Checking route: ${route.regexp}`);
console.log(`Against path: ${path}`); console.log(`Against path: ${path}`);
if (route.regexp.test(path)) { if (route.regexp.test(path)) {
console.log(`Running route: ${route.regexp}`); console.log(`Matched route: ${route.regexp}`);
console.log(`Path: ${path}`);
console.log(`Function: ${route.function.name}`);
route.function(req, res, route.regexp.exec(path)); route.function(req, res, route.regexp.exec(path));
return; return;
} }
@ -104,7 +102,7 @@ const axioshelper = (message, config, callback, retries = 3, delay = 100) => {
app.route("^(?:/userId/([^/]+))(?:/$)?$", async (req, res, match) => { app.route("^(?:/userId/([^/]+))(?:/$)?$", async (req, res, match) => {
try { try {
console.log("Received request for userId:", match[1]); console.log(`Received request for userId: ${match[1]}`);
const modelName = const modelName =
req.params?.modelName || proactive_agent_settings.modelName; req.params?.modelName || proactive_agent_settings.modelName;
if (match.length > 1) { if (match.length > 1) {
@ -249,36 +247,34 @@ app.route("^(?:/userId/([^/]+))(?:/$)?$", async (req, res, match) => {
app.route("/", async (req, res) => { app.route("/", async (req, res) => {
const sessionId = req.body.event?.conversationId; const sessionId = req.body.event?.conversationId;
const params = req.body.event?.params || {};
const modelName =
params?.modelName || settings_667ef98d3ee8930a5debcbdb.nlu.modelName;
const env = params?.env;
const postBack = req.body.event?.postBack;
const metadata = { const metadata = {
...req.body.event?.metadata, ...req.body.event?.metadata,
userId: req.body.event?.sentBy?.userId, userId: req.body.event?.sentBy?.userId,
}; };
const configuration = req.body.event?.configuration;
try { try {
const umStr = redisKey(metadata.userId); if (sessionId && metadata.userId) {
const umStr = redisKey(metadata.userId);
await redis.hSet(umStr, "sessionId", sessionId); await redis.hSet(umStr, "sessionId", sessionId);
await redis.expire(umStr, 3600); await redis.expire(umStr, 3600);
await axioshelper("messenger join", { await axioshelper("messenger join", {
method: "post", method: "post",
url: `${msgrSettings.messenger.apiBaseURL}Conversation/join`, url: `${msgrSettings.messenger.apiBaseURL}Conversation/join`,
headers: studioToken, headers: studioToken,
data: { data: {
_id: sessionId, _id: sessionId,
participant: bot_user, participant: bot_user,
}, },
}); });
res.send(); res.send();
} else {
res.send({ error: "sessionId or userId not found on event." });
}
} catch (error) { } catch (error) {
console.log(error.message); console.log(error);
res.send({ res.send({
answers: ["Something went wrong. Please try again."], answers: ["Something went wrong. Please try again."],
outputs: {}, outputs: {},

View File

@ -1,17 +0,0 @@
(async () => {
proactive_agent.joinConversation(conversationData.id);
})()
.catch((error) => {
console.log(error.message);
recognizedObject.answers.push("");
recognizedObject.errorInfo = {
...recognizedObject.errorInfo,
label: {
data: error.toJSON ? error.toJSON() : {},
message: error.message,
},
};
})
.finally(() => {
next();
});