@cognigy/rest-api-client
Version:
Cognigy REST-Client
208 lines • 8.04 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IDENTITY_ASSIST = void 0;
/* Custom Modules */
const createNodeDescriptor_1 = require("../../createNodeDescriptor");
/* Templates */
const identityAssistTemplate_1 = require("./htmlTemplates/identityAssistTemplate");
const getFontSizeFieldOptions_1 = require("./helpers/getFontSizeFieldOptions");
/**
* Node name: "identityAssist"
*
* Purpose:
* Set a Identity Assist Tile for the Agent Assist Workspace
*/
exports.IDENTITY_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
type: "identityAssist",
defaultLabel: "Copilot: Identity Tile",
summary: "UI__NODE_EDITOR__IDENTITY_ASSIST__SUMMARY",
appearance: {
showIcon: false,
},
tags: ["agentAssist"],
fields: [
{
key: "tileId",
label: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__TILE_ID__LABEL",
description: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__TILE_ID__DESCRIPTION",
type: "cognigyText",
defaultValue: "identity-assist",
params: {
required: true,
},
},
{
key: "widgetLayout",
label: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__WIDGET_LAYOUT__LABEL",
type: "select",
defaultValue: "horizontal",
params: {
options: [
{
label: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__WIDGET_LAYOUT__OPTIONS__HORIZONTAL__LABEL",
value: "horizontal",
},
{
label: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__WIDGET_LAYOUT__OPTIONS__VERTICAL__LABEL",
value: "vertical",
},
],
},
},
{
key: "showProfileImage",
label: "UI__NODE_EDITOR__IDENTITY_ASSIST__ENABLE_PROFILE_IMAGE__LABEL",
type: "toggle",
defaultValue: true,
},
{
key: "imageShape",
label: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__IMAGE_SHAPE__LABEL",
type: "select",
defaultValue: "round",
params: {
options: [
{
label: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__IMAGE_SHAPE__OPTIONS__ROUND__LABEL",
value: "round",
},
{
label: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__IMAGE_SHAPE__OPTIONS__SQUARE__LABEL",
value: "square",
},
],
},
condition: {
key: "showProfileImage",
value: true,
},
},
{
key: "imageUrl",
label: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__IMAGE_URL__LABEL",
description: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__IMAGE_URL__DESCRIPTION",
type: "cognigyText",
defaultValue: "{{profile.profilepic}}",
params: {
required: true,
},
condition: {
key: "showProfileImage",
value: true,
},
},
{
key: "customer",
label: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__CUSTOMER__LABEL",
description: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__CUSTOMER__DESCRIPTION",
type: "cognigyText",
defaultValue: "{{profile.firstName}} {{profile.lastName}}",
},
{
key: "customerData",
type: "keyValuePairs",
label: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__CUSTOMER_DATA__LABEL",
description: "UI__NODE_EDITOR__IDENTITY_ASSIST__FIELDS__CUSTOMER_DATA__DESCRIPTION",
defaultValue: `{"Email": "{{profile.email}}","Phone": "{{profile.phone}}"}`,
params: {
required: true,
},
},
{
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: "profileFontSize",
type: "select",
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__IDENTITY_ASSIST__PROFILE__FONT_SIZE",
description: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__IDENTITY_ASSIST__PROFILE__FONT_SIZE__DESCRIPTION",
defaultValue: "text-xl",
params: {
options: getFontSizeFieldOptions_1.getFontSizeFieldOptions,
},
},
{
key: "keyValueFontSize",
type: "select",
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__IDENTITY_ASSIST__KEY_VALUE__FONT_SIZE",
description: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__IDENTITY_ASSIST__KEY_VALUE__FONT_SIZE__DESCRIPTION",
defaultValue: "text-sm",
params: {
options: getFontSizeFieldOptions_1.getFontSizeFieldOptions,
},
},
{
key: "profileImageSize",
type: "select",
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__IDENTITY_ASSIST__IMAGE__SIZE",
description: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__IDENTITY_ASSIST__IMAGE__SIZE__DESCRIPTION",
defaultValue: "h-32 w-32",
params: {
options: getFontSizeFieldOptions_1.getImageSizeFieldOptions,
},
condition: {
key: "showProfileImage",
value: true,
},
},
],
sections: [
{
key: "uiPreferences",
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__TITLE",
defaultCollapsed: true,
fields: ["fontSize", "profileFontSize", "keyValueFontSize", "profileImageSize"],
},
],
form: [
{ type: "field", key: "tileId" },
{ type: "field", key: "widgetLayout" },
{ type: "field", key: "showProfileImage" },
{ type: "field", key: "imageShape" },
{ type: "field", key: "imageUrl" },
{ type: "field", key: "customer" },
{ type: "field", key: "customerData" },
{ type: "section", key: "uiPreferences" },
].filter(element => !!element),
function: async (params) => {
const { cognigy, config } = params;
const { api } = cognigy;
const widgetLayout = config.widgetLayout;
const imageShape = config.imageShape;
const imageUrl = config.imageUrl;
const customer = config.customer;
const customerData = config.customerData;
try {
const data = {
html: (0, identityAssistTemplate_1.default)({
widgetLayout,
imageShape,
imageUrl,
customer,
customerData,
fontSize: config.fontSize,
profileFontSize: config.profileFontSize,
keyValueFontSize: config.keyValueFontSize,
showProfileImage: config.showProfileImage,
profileImageSize: config.profileImageSize,
}),
};
cognigy.api.sendTileUpdateToAgentAssistWorkspace(Object.assign(Object.assign({}, params), { tile: {
id: config.tileId,
type: "html",
data,
} }));
}
catch (err) {
api.logDebugError(err, "UI__DEBUG_MODE__IDENTITY_ASSIST__ERROR");
}
},
});
//# sourceMappingURL=identityAssist.js.map