@cognigy/rest-api-client
Version:
Cognigy REST-Client
111 lines • 4.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TRANSCRIPT_ASSIST = void 0;
/* Custom modules */
const createNodeDescriptor_1 = require("../../createNodeDescriptor");
const transcriptAssistTemplate_1 = require("./htmlTemplates/transcriptAssistTemplate");
const constants_1 = require("./constants/constants");
const sentiment_helper_1 = require("./helpers/sentiment.helper");
const getFontSizeFieldOptions_1 = require("./helpers/getFontSizeFieldOptions");
/**
* Node name: "transcriptAssist"
*
* Purpose:
* The Transcript Assist widget will suggest agent responses and provide more information to draft messages.
*/
exports.TRANSCRIPT_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
type: "transcriptAssist",
defaultLabel: "Copilot: Transcript Tile",
summary: "UI__NODE_EDITOR__TRANSCRIPT_ASSIST__SUMMARY",
appearance: {
showIcon: false,
},
tags: ["agentAssist"],
fields: [
{
key: "tileId",
label: "UI__NODE_EDITOR__TRANSCRIPT_ASSIST__ID__LABEL",
type: "cognigyText",
description: "UI__NODE_EDITOR__TRANSCRIPT_ASSIST_TILE_ID__DESCRIPTION",
defaultValue: "transcript-assist",
params: {
required: true,
},
},
{
key: "enableSentiment",
label: "UI__NODE_EDITOR__TRANSCRIPT_ASSIST__ENABLE_SENTIMENT__LABEL",
type: "toggle",
defaultValue: false,
},
{
key: "fontSize",
type: "select",
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE",
description: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE__INFO",
defaultValue: "text-sm",
params: {
options: getFontSizeFieldOptions_1.getFontSizeFieldOptions,
},
},
{
key: "messageFontSize",
type: "select",
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE",
description: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE__INFO",
defaultValue: "text-sm",
params: {
options: getFontSizeFieldOptions_1.getFontSizeFieldOptions,
},
},
],
sections: [
{
key: "uiPreferences",
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__TITLE",
defaultCollapsed: true,
fields: ["fontSize", "messageFontSize"],
},
],
form: [
{ type: "field", key: "tileId" },
{ type: "field", key: "enableSentiment" },
{ type: "section", key: "uiPreferences" },
].filter((element) => !!element),
function: async (params) => {
const { cognigy, config } = params;
const { api } = cognigy;
const sentimentEnabled = config["enableSentiment"];
let sentiment;
try {
const inputText = cognigy.input.text;
if (!inputText) {
return;
}
if (sentimentEnabled) {
const prompt = `${constants_1.LAST_INPUT_PROMPT} ${inputText}`;
sentiment = await (0, sentiment_helper_1.sentimentAnalysis)(api, prompt);
}
const data = {
html: (0, transcriptAssistTemplate_1.default)({
message: inputText,
assetsBaseURL: process.env.AGENT_ASSIST_WORKSPACE_FRONTEND_URL_WITH_PROTOCOL || "",
sentiment,
fontSize: config.fontSize,
messageFontSize: config.messageFontSize
}),
};
cognigy.api.sendTileUpdateToAgentAssistWorkspace(Object.assign(Object.assign({}, params), { tile: {
id: config.tileId,
type: "html",
data,
} }));
api.logDebugMessage(`UI__DEBUG_MODE__TRANSCRIPT_ASSIST__MESSAGE`);
}
catch (error) {
api.logDebugError(error, "Copilot: Transcript Tile Error");
}
return;
},
});
//# sourceMappingURL=transcriptAssist.js.map