From 0b1086232047cae9feadb321fe9a1824339ed702 Mon Sep 17 00:00:00 2001 From: "Peter.Morton" Date: Fri, 6 Jun 2025 14:03:46 -0500 Subject: [PATCH] Added sorting of messages --- CA_ContextService/snippets/postContactHistory.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CA_ContextService/snippets/postContactHistory.js b/CA_ContextService/snippets/postContactHistory.js index 955414f..92e7a06 100644 --- a/CA_ContextService/snippets/postContactHistory.js +++ b/CA_ContextService/snippets/postContactHistory.js @@ -8,9 +8,18 @@ let startTime = new Date(); if (history.messages.length > 0) { notes = history.messages - .map((message) => `[${message.dateSent}] ${message.direction} : ${message.text}`) + .map( + (message) => + `[${message.dateSent}] ${message.direction} : ${message.text}` + ) .filter((text) => text.trim() !== ""); startTime = new Date(history.messages[0]?.dateSent || startTime); + + // reverse notes so that older messages are at the top + notes.reverse(); + notes.forEach((note, index) => { + console.log(`Note ${index + 1}: ${note}`); + }); } const endTime = new Date(); const url = `https://ivastudio.verint.live/organizations/${recognizedObject.classificationResults.organizationId}/workspaces/${conversationData.workspaceId}/conversation/${conversationData.id}`;