diff --git a/CA_ContextService/snippets/postContactHistory.js b/CA_ContextService/snippets/postContactHistory.js index 92e7a06..c5aa822 100644 --- a/CA_ContextService/snippets/postContactHistory.js +++ b/CA_ContextService/snippets/postContactHistory.js @@ -7,6 +7,8 @@ let notes = ["No History Found"]; let startTime = new Date(); if (history.messages.length > 0) { + history.messages.sort((a, b) => new Date(a.dateSent) - new Date(b.dateSent)); + notes = history.messages .map( (message) => @@ -14,12 +16,6 @@ ) .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}`;