38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
(async () => {
|
|
const customerId = conversationData.customer?.customerId ?? "CC1000778";
|
|
const history = await CAInterface().getConversationHistory(
|
|
conversationData.id,
|
|
50
|
|
);
|
|
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) =>
|
|
`[${message.dateSent}] ${message.direction} : ${message.text}`
|
|
)
|
|
.filter((text) => text.trim() !== "");
|
|
startTime = new Date(history.messages[0]?.dateSent || startTime);
|
|
}
|
|
const endTime = new Date();
|
|
const url = `https://ivastudio.verint.live/organizations/${recognizedObject.classificationResults.organizationId}/workspaces/${conversationData.workspaceId}/conversation/${conversationData.id}`;
|
|
CA_ContextService().post(customerId, notes, startTime, endTime, url);
|
|
})()
|
|
.catch((error) => {
|
|
console.log(error.message);
|
|
recognizedObject.answers.push("");
|
|
recognizedObject.errorInfo = {
|
|
...recognizedObject.errorInfo,
|
|
label: {
|
|
data: error.toJSON ? error.toJSON() : {},
|
|
message: error.message,
|
|
},
|
|
};
|
|
})
|
|
.finally(() => {
|
|
next();
|
|
});
|