UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

102 lines 3.44 kB
import { __awaiter } from "tslib"; /* Custom modules */ import { createNodeDescriptor } from "../../createNodeDescriptor"; import { TranscriptRole } from "../../../interfaces/transcripts/transcripts"; /** * Node name: 'getTranscript' * * Purpose: * Get the transcript of the current session * @param mode the mode in which the transcript should be read * @param limit the number of entries to read */ export const GET_TRANSCRIPT = createNodeDescriptor({ type: "getTranscript", defaultLabel: "Get Transcript", summary: "UI__NODE_EDITOR__GET_TRANSCRIPT__SUMMARY", appearance: { showIcon: false }, fields: [ { key: "limit", type: "slider", label: "UI__NODE_EDITOR__GET_TRANSCRIPT__FIELDS__LIMIT__LABEL", description: "UI__NODE_EDITOR__GET_TRANSCRIPT__FIELDS__LIMIT__DESCRIPTION", defaultValue: 25, params: { min: 0, max: 50, step: 1, }, }, { key: "storeLocation", type: "select", label: "UI__NODE_EDITOR__GET_TRANSCRIPT__FIELDS__STORE_LOCATION__LABEL", params: { options: [ { label: "UI__NODE_EDITOR__GET_TRANSCRIPT__FIELDS__STORE_LOCATION__OPTIONS__INPUT", value: "input" }, { label: "UI__NODE_EDITOR__GET_TRANSCRIPT__FIELDS__STORE_LOCATION__OPTIONS__CONTEXT", value: "context" } ], }, defaultValue: "input" }, { key: "inputKey", type: "cognigyText", label: "UI__NODE_EDITOR__GET_TRANSCRIPT__FIELDS__INPUT_KEY__LABEL", defaultValue: "transcript", condition: { key: "storeLocation", value: "input", } }, { key: "contextKey", type: "cognigyText", label: "UI__NODE_EDITOR__GET_TRANSCRIPT__FIELDS__CONTEXT_KEY__LABEL", defaultValue: "transcript", condition: { key: "storeLocation", value: "context", } }, ], sections: [ { key: "storage", label: "UI__NODE_EDITOR__GET_TRANSCRIPT__FIELDS__STORAGE__LABEL", defaultCollapsed: true, fields: [ "storeLocation", "inputKey", "contextKey", ] } ], form: [ { type: "field", key: "limit" }, { type: "section", key: "storage" }, ], tags: ["service", "transcripts"], function: ({ cognigy, config }) => __awaiter(void 0, void 0, void 0, function* () { var _a; const { limit, storeLocation, inputKey, contextKey } = config; const { api } = cognigy; const transcript = yield api.getTranscript({ limit, excludeDataOnlyMessagesFilter: [TranscriptRole.AGENT, TranscriptRole.ASSISTANT] }); if (storeLocation === "context") { (_a = api.addToContext) === null || _a === void 0 ? void 0 : _a.call(api, contextKey, transcript, "simple"); } else { api.addToInput(inputKey, transcript); } }) }); //# sourceMappingURL=getTranscript.js.map