From db79b2147b2441c15433061cab52cdd9d2af0689 Mon Sep 17 00:00:00 2001 From: "Peter.Morton" Date: Thu, 7 Aug 2025 11:12:00 -0500 Subject: [PATCH] Updating folder name --- .../proactive_agent_settings.json | 0 .../ProxyScript/proactive_agent_messenger.js | 44 +++++++++---------- .../snippets/DigitalWelcomeEvent.js | 0 proactiveAgent/snippets/join.js | 17 ------- 4 files changed, 20 insertions(+), 41 deletions(-) rename {proactiveAgent => proactive-agent}/_studio_dependencies/GlobalVariable/proactive_agent_settings.json (100%) rename {proactiveAgent => proactive-agent}/_studio_dependencies/ProxyScript/proactive_agent_messenger.js (89%) rename {proactiveAgent => proactive-agent}/snippets/DigitalWelcomeEvent.js (100%) delete mode 100644 proactiveAgent/snippets/join.js diff --git a/proactiveAgent/_studio_dependencies/GlobalVariable/proactive_agent_settings.json b/proactive-agent/_studio_dependencies/GlobalVariable/proactive_agent_settings.json similarity index 100% rename from proactiveAgent/_studio_dependencies/GlobalVariable/proactive_agent_settings.json rename to proactive-agent/_studio_dependencies/GlobalVariable/proactive_agent_settings.json diff --git a/proactiveAgent/_studio_dependencies/ProxyScript/proactive_agent_messenger.js b/proactive-agent/_studio_dependencies/ProxyScript/proactive_agent_messenger.js similarity index 89% rename from proactiveAgent/_studio_dependencies/ProxyScript/proactive_agent_messenger.js rename to proactive-agent/_studio_dependencies/ProxyScript/proactive_agent_messenger.js index b2eb079..88a80b5 100644 --- a/proactiveAgent/_studio_dependencies/ProxyScript/proactive_agent_messenger.js +++ b/proactive-agent/_studio_dependencies/ProxyScript/proactive_agent_messenger.js @@ -27,9 +27,7 @@ const app = { console.log(`Checking route: ${route.regexp}`); console.log(`Against path: ${path}`); if (route.regexp.test(path)) { - console.log(`Running route: ${route.regexp}`); - console.log(`Path: ${path}`); - console.log(`Function: ${route.function.name}`); + console.log(`Matched route: ${route.regexp}`); route.function(req, res, route.regexp.exec(path)); return; } @@ -104,7 +102,7 @@ const axioshelper = (message, config, callback, retries = 3, delay = 100) => { app.route("^(?:/userId/([^/]+))(?:/$)?$", async (req, res, match) => { try { - console.log("Received request for userId:", match[1]); + console.log(`Received request for userId: ${match[1]}`); const modelName = req.params?.modelName || proactive_agent_settings.modelName; if (match.length > 1) { @@ -249,36 +247,34 @@ app.route("^(?:/userId/([^/]+))(?:/$)?$", async (req, res, match) => { app.route("/", async (req, res) => { 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 = { ...req.body.event?.metadata, userId: req.body.event?.sentBy?.userId, }; - const configuration = req.body.event?.configuration; try { - const umStr = redisKey(metadata.userId); + if (sessionId && metadata.userId) { + const umStr = redisKey(metadata.userId); - await redis.hSet(umStr, "sessionId", sessionId); - await redis.expire(umStr, 3600); + await redis.hSet(umStr, "sessionId", sessionId); + await redis.expire(umStr, 3600); - await axioshelper("messenger join", { - method: "post", - url: `${msgrSettings.messenger.apiBaseURL}Conversation/join`, - headers: studioToken, - data: { - _id: sessionId, - participant: bot_user, - }, - }); + await axioshelper("messenger join", { + method: "post", + url: `${msgrSettings.messenger.apiBaseURL}Conversation/join`, + headers: studioToken, + data: { + _id: sessionId, + participant: bot_user, + }, + }); - res.send(); + res.send(); + } else { + res.send({ error: "sessionId or userId not found on event." }); + } } catch (error) { - console.log(error.message); + console.log(error); res.send({ answers: ["Something went wrong. Please try again."], outputs: {}, diff --git a/proactiveAgent/snippets/DigitalWelcomeEvent.js b/proactive-agent/snippets/DigitalWelcomeEvent.js similarity index 100% rename from proactiveAgent/snippets/DigitalWelcomeEvent.js rename to proactive-agent/snippets/DigitalWelcomeEvent.js diff --git a/proactiveAgent/snippets/join.js b/proactiveAgent/snippets/join.js deleted file mode 100644 index 4fe0823..0000000 --- a/proactiveAgent/snippets/join.js +++ /dev/null @@ -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(); - });