UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

44 lines 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * TMS (Transcript Management Service) payload transformer for CXone */ function transformConversation(conversation, action, contactId, businessNumber) { const transcripts = conversation .filter(item => item.type === "output" || (item.type === "input" && item.payload.text)) .map(item => { var _a; const participantId = item.role === "assistant" ? "Bot" : "Patron"; const messageBody = (_a = item.payload.text) !== null && _a !== void 0 ? _a : ""; const date = new Date(item.timestamp); const utcDateTime = date.toISOString().replace(/\.\d{3}Z$/, (() => { const msStr = date.getMilliseconds().toString().padStart(3, "0"); return `.${msStr}`; })()); return { participantId, messageBody, messageContentType: "TRANSCRIPT", utcDateTime, }; }); return { vendorId: "Cognigy", busId: businessNumber, virtualAgentId: "", contactId, contactState: "SELF_SERVICE", mediaType: "Voice", selfServiceSessionDetails: { transcriptPublishSettingOption: "PUBLISH_TRANSCRIPTS_ONLY", sessionCompletionType: action === "End" ? "CONTAINED" : "ESCALATED", sessionCompletionDetails: action === "End" ? "User Asked to End Conversation" : "User Escalated Conversation to Live Agent", transcriptSummary: "", transcripts, }, }; } exports.default = transformConversation; //# sourceMappingURL=cxOneTmsPayload.js.map