@andreswagner/node-red-contrib-wxo-agent 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/nodes/wxo-agent/wxo-agent.js +13 -3
- package/package.json +1 -1
|
@@ -90,10 +90,20 @@ module.exports = function(RED) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
// Determine thread ID (for multi-turn conversations)
|
|
93
|
-
//
|
|
93
|
+
// Accept explicit "true" values only for forcing new sessions.
|
|
94
|
+
const forceNewSession = msg.wxo_new_session === true ||
|
|
95
|
+
msg.wxo_new_session === 'true' ||
|
|
96
|
+
msg.wxo_new_session === 1 ||
|
|
97
|
+
msg.wxo_new_session === '1';
|
|
94
98
|
let threadId = null;
|
|
95
|
-
if (!
|
|
96
|
-
|
|
99
|
+
if (!forceNewSession) {
|
|
100
|
+
// Full request object takes precedence over msg.topic if provided.
|
|
101
|
+
if (typeof requestPayload === 'object' && requestPayload !== null) {
|
|
102
|
+
threadId = requestPayload.thread_id || requestPayload.threadId || null;
|
|
103
|
+
}
|
|
104
|
+
if (!threadId && typeof msg.topic === 'string' && msg.topic.trim() !== '') {
|
|
105
|
+
threadId = msg.topic.trim();
|
|
106
|
+
}
|
|
97
107
|
}
|
|
98
108
|
|
|
99
109
|
node.status({ fill: 'blue', shape: 'dot', text: 'calling agent...' });
|