@cognigy/rest-api-client 2025.24.0 → 2025.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/build/shared/charts/descriptors/index.js +5 -1
- package/build/shared/charts/descriptors/placeholder.js +3 -0
- package/build/shared/charts/descriptors/service/agentTools/handoverToAiAgentTool.js +192 -0
- package/build/shared/charts/descriptors/service/agentTools/sendEmailTool.js +243 -0
- package/build/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +1 -1
- package/build/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehub.js +198 -0
- package/build/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehubConnection.js +16 -0
- package/build/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehubForm.js +300 -0
- package/build/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehubProviderModule.js +16 -0
- package/build/shared/charts/descriptors/service/index.js +5 -1
- package/build/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +1 -1
- package/build/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +12 -16
- package/build/shared/constants.js +2 -1
- package/build/shared/interfaces/IOrganisation.js +1 -0
- package/build/shared/interfaces/cxone/knowledgehub/CXoneKnowledgehubAPI.js +3 -0
- package/build/shared/interfaces/resources/IAuditEvent.js +1 -0
- package/build/shared/interfaces/restAPI/simulation/simulationRun/ISimulationRunRest_2_0.js +15 -1
- package/build/shared/interfaces/restAPI/simulation/simulationRunBatch/ISimulationRunBatchRest_2_0.js +6 -1
- package/dist/esm/shared/charts/descriptors/index.js +4 -1
- package/dist/esm/shared/charts/descriptors/placeholder.js +3 -0
- package/dist/esm/shared/charts/descriptors/service/agentTools/handoverToAiAgentTool.js +190 -0
- package/dist/esm/shared/charts/descriptors/service/agentTools/sendEmailTool.js +241 -0
- package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +1 -1
- package/dist/esm/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehub.js +196 -0
- package/dist/esm/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehubConnection.js +13 -0
- package/dist/esm/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehubForm.js +297 -0
- package/dist/esm/shared/charts/descriptors/service/cxone/knowledgehub/CXoneKnowledgehubProviderModule.js +13 -0
- package/dist/esm/shared/charts/descriptors/service/index.js +2 -0
- package/dist/esm/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +1 -1
- package/dist/esm/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +12 -16
- package/dist/esm/shared/constants.js +1 -0
- package/dist/esm/shared/interfaces/IOrganisation.js +1 -0
- package/dist/esm/shared/interfaces/cxone/knowledgehub/CXoneKnowledgehubAPI.js +2 -0
- package/dist/esm/shared/interfaces/resources/IAuditEvent.js +1 -0
- package/dist/esm/shared/interfaces/restAPI/simulation/simulationRun/ISimulationRunRest_2_0.js +14 -0
- package/dist/esm/shared/interfaces/restAPI/simulation/simulationRunBatch/ISimulationRunBatchRest_2_0.js +5 -0
- package/package.json +1 -1
- package/types/index.d.ts +199 -18
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ESentimentTypeRest_2_0 = exports.SuccessCriterionType_2_0 = exports.ESuccessCriteriaTypeRest_2_0 = exports.ETurnTypeRest_2_0 = void 0;
|
|
3
|
+
exports.ESimulationErrorCategoryRest_2_0 = exports.ESimulationStatusRest_2_0 = exports.ESentimentTypeRest_2_0 = exports.SuccessCriterionType_2_0 = exports.ESuccessCriteriaTypeRest_2_0 = exports.ETurnTypeRest_2_0 = void 0;
|
|
4
4
|
var ETurnTypeRest_2_0;
|
|
5
5
|
(function (ETurnTypeRest_2_0) {
|
|
6
6
|
ETurnTypeRest_2_0["INPUT"] = "input";
|
|
@@ -21,4 +21,18 @@ var ESentimentTypeRest_2_0;
|
|
|
21
21
|
ESentimentTypeRest_2_0["NEUTRAL"] = "NEUTRAL";
|
|
22
22
|
ESentimentTypeRest_2_0["NEGATIVE"] = "NEGATIVE";
|
|
23
23
|
})(ESentimentTypeRest_2_0 = exports.ESentimentTypeRest_2_0 || (exports.ESentimentTypeRest_2_0 = {}));
|
|
24
|
+
var ESimulationStatusRest_2_0;
|
|
25
|
+
(function (ESimulationStatusRest_2_0) {
|
|
26
|
+
ESimulationStatusRest_2_0["SUCCESS"] = "success";
|
|
27
|
+
ESimulationStatusRest_2_0["FAILED"] = "failed";
|
|
28
|
+
ESimulationStatusRest_2_0["ERROR"] = "error";
|
|
29
|
+
})(ESimulationStatusRest_2_0 = exports.ESimulationStatusRest_2_0 || (exports.ESimulationStatusRest_2_0 = {}));
|
|
30
|
+
var ESimulationErrorCategoryRest_2_0;
|
|
31
|
+
(function (ESimulationErrorCategoryRest_2_0) {
|
|
32
|
+
ESimulationErrorCategoryRest_2_0["NONE"] = "none";
|
|
33
|
+
ESimulationErrorCategoryRest_2_0["AI_AGENT_TIMEOUT"] = "ai_agent_timeout";
|
|
34
|
+
ESimulationErrorCategoryRest_2_0["LLM_PROVIDER_ERROR"] = "llm_provider_error";
|
|
35
|
+
ESimulationErrorCategoryRest_2_0["AI_AGENT_ERROR"] = "ai_agent_error";
|
|
36
|
+
ESimulationErrorCategoryRest_2_0["UNKNOWN"] = "unknown";
|
|
37
|
+
})(ESimulationErrorCategoryRest_2_0 = exports.ESimulationErrorCategoryRest_2_0 || (exports.ESimulationErrorCategoryRest_2_0 = {}));
|
|
24
38
|
//# sourceMappingURL=ISimulationRunRest_2_0.js.map
|
package/build/shared/interfaces/restAPI/simulation/simulationRunBatch/ISimulationRunBatchRest_2_0.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SimulationRunBatchStatus = void 0;
|
|
3
|
+
exports.SuccessCriterionTypeRest_2_0 = exports.SimulationRunBatchStatus = void 0;
|
|
4
4
|
exports.SimulationRunBatchStatus = [
|
|
5
5
|
"IN_PROGRESS",
|
|
6
6
|
"COMPLETED",
|
|
7
7
|
"FAILED"
|
|
8
8
|
];
|
|
9
|
+
var SuccessCriterionTypeRest_2_0;
|
|
10
|
+
(function (SuccessCriterionTypeRest_2_0) {
|
|
11
|
+
SuccessCriterionTypeRest_2_0["TEXT"] = "text";
|
|
12
|
+
SuccessCriterionTypeRest_2_0["GOAL_COMPLETED"] = "goalCompleted";
|
|
13
|
+
})(SuccessCriterionTypeRest_2_0 = exports.SuccessCriterionTypeRest_2_0 || (exports.SuccessCriterionTypeRest_2_0 = {}));
|
|
9
14
|
//# sourceMappingURL=ISimulationRunBatchRest_2_0.js.map
|
|
@@ -11,7 +11,7 @@ import { REGEX_SLOT_FILLER, EXECUTE_COGNIGY_NLU, ADD_LEXICON_KEYPHRASE, FUZZY_SE
|
|
|
11
11
|
import { KNOWLEDGE_SEARCH, KNOWLEDGE_SEARCH_V2, SEARCH_EXTRACT_OUTPUT } from "./knowledgeSearch";
|
|
12
12
|
import { CONTINUOUS_ASR, DTMF, HANG_UP, PLAY, TRANSFER_VOICE, SESSION_SPEECH_PARAMETERS, USER_INPUT_TIMEOUT, SEND_METADATA, BARGE_IN, MUTE_SPEECH_INPUT, } from "./voice";
|
|
13
13
|
import { ACTIVATE_PROFILE, COMPLETE_GOAL, DEACTIVATE_PROFILE, DELETE_PROFILE, MERGE_PROFILE, UPDATE_PROFILE, ADD_MEMORY, BLIND_MODE, OVERWRITE_ANALYTICS, SET_RATING, REQUEST_RATING, TRACK_GOAL, } from "./analytics";
|
|
14
|
-
import { HANDOVER, HANDOVER_V2, CHECK_AGENT_AVAILABILITY, HTTP_REQUEST, HTTP_CONNECTION_BASIC, HTTP_CONNECTION_APIKEYAUTHKEY, HTTP_CONNECTION_APIKEYXKEY, HTTP_CONNECTION_OAUTH2, JWT_SECRET_CONNECTION, TRIGGER_FUNCTION, ON_SCHEDULING_ERROR, ON_SCHEDULED, GPT_PROMPT, LLM_PROMPT_V2, LLM_PROMPT_DEFAULT, LLM_PROMPT_MCP_TOOL, LLM_PROMPT_TOOL, CLOSE_HANDOVER, HANDOVER_INACTIVITY_TIMER, GPT_CONVERSATION, GPT_CONVERSATION_SUMMARY, LLM_ENTITY_EXTRACT, AI_AGENT_JOB, AI_AGENT_JOB_DEFAULT, AI_AGENT_JOB_TOOL, AI_AGENT_JOB_MCP_TOOL, AI_AGENT_JOB_CALL_MCP_TOOL, AI_AGENT_TOOL_ANSWER, KNOWLEDGE_TOOL, AI_AGENT_HANDOVER, LIVE_AGENT_CONNECTION, RINGCENTRAL_ENGAGE_CONNECTION, CHATWOOT_CONNECTION, EIGHT_BY_EIGHT_CONNECTION, GENESYS_CLOUD_CONNECTION, GENESYS_CLOUD_CONNECTION_OM, LLM_MODERATE, NICECXONEAAH_AUTHENTICATION_CONNECTION, LOAD_AI_AGENT, AIOPS_CENTER_WEBHOOKS_CONNECTION, STORM_CONNECTION, } from "./service";
|
|
14
|
+
import { HANDOVER, HANDOVER_V2, CHECK_AGENT_AVAILABILITY, HTTP_REQUEST, HTTP_CONNECTION_BASIC, HTTP_CONNECTION_APIKEYAUTHKEY, HTTP_CONNECTION_APIKEYXKEY, HTTP_CONNECTION_OAUTH2, JWT_SECRET_CONNECTION, TRIGGER_FUNCTION, ON_SCHEDULING_ERROR, ON_SCHEDULED, GPT_PROMPT, LLM_PROMPT_V2, LLM_PROMPT_DEFAULT, LLM_PROMPT_MCP_TOOL, LLM_PROMPT_TOOL, CLOSE_HANDOVER, HANDOVER_INACTIVITY_TIMER, GPT_CONVERSATION, GPT_CONVERSATION_SUMMARY, LLM_ENTITY_EXTRACT, AI_AGENT_JOB, AI_AGENT_JOB_DEFAULT, AI_AGENT_JOB_TOOL, AI_AGENT_JOB_MCP_TOOL, AI_AGENT_JOB_CALL_MCP_TOOL, AI_AGENT_TOOL_ANSWER, KNOWLEDGE_TOOL, HANDOVER_TO_AI_AGENT_TOOL, SEND_EMAIL_TOOL, AI_AGENT_HANDOVER, LIVE_AGENT_CONNECTION, RINGCENTRAL_ENGAGE_CONNECTION, CHATWOOT_CONNECTION, EIGHT_BY_EIGHT_CONNECTION, GENESYS_CLOUD_CONNECTION, GENESYS_CLOUD_CONNECTION_OM, LLM_MODERATE, NICECXONEAAH_AUTHENTICATION_CONNECTION, LOAD_AI_AGENT, AIOPS_CENTER_WEBHOOKS_CONNECTION, STORM_CONNECTION, } from "./service";
|
|
15
15
|
import { INIT_APP_SESSION, GET_APP_SESSION_PIN, SET_HTML_APP_STATE, SET_ADAPTIVE_CARD_APP_STATE, } from "./apps";
|
|
16
16
|
import { SET_IFRAME_TILE, SET_HTML_TILE, SEND_TILE_DATA, SET_SECURE_FORMS_TILE, SET_ADAPTIVE_CARD_TILE, SET_AGENT_ASSIST_GRID, NEXT_ACTION_ASSIST, SENTIMENT_ASSIST, TRANSCRIPT_ASSIST, IDENTITY_ASSIST, KNOWLEDGE_ASSIST, } from "./agentAssist";
|
|
17
17
|
import { ASSIST_INFO } from "./liveAgent";
|
|
@@ -147,6 +147,8 @@ if (process.env.DISABLE_FEATURE_TRANSCRIPT_MANAGER !== "true") {
|
|
|
147
147
|
nodes.push(AI_AGENT_JOB_CALL_MCP_TOOL);
|
|
148
148
|
nodes.push(AI_AGENT_TOOL_ANSWER);
|
|
149
149
|
nodes.push(KNOWLEDGE_TOOL);
|
|
150
|
+
nodes.push(HANDOVER_TO_AI_AGENT_TOOL);
|
|
151
|
+
nodes.push(SEND_EMAIL_TOOL);
|
|
150
152
|
nodes.push(AI_AGENT_HANDOVER);
|
|
151
153
|
nodes.push(LOAD_AI_AGENT);
|
|
152
154
|
}
|
|
@@ -186,4 +188,5 @@ export { cognigyGenerativeAIProviderModule } from "./connectionNodes/generativeA
|
|
|
186
188
|
export { cognigySpeechProviderModule } from "./connectionNodes/speechProviders";
|
|
187
189
|
export { cognigyTranslationProviderModule } from "./connectionNodes/translationProviders";
|
|
188
190
|
export { cognigyDocumentParserProviderModule } from "./connectionNodes/documentParserProviders";
|
|
191
|
+
export { niceCXoneKnowledgehubProviderModule } from "./service/cxone/knowledgehub/CXoneKnowledgehubProviderModule";
|
|
189
192
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
/* Custom modules */
|
|
3
|
+
import { createNodeDescriptor } from "../../../createNodeDescriptor";
|
|
4
|
+
import { TranscriptEntryType, TranscriptRole } from "../../../../interfaces/transcripts/transcripts";
|
|
5
|
+
export const HANDOVER_TO_AI_AGENT_TOOL = createNodeDescriptor({
|
|
6
|
+
type: "handoverToAiAgentTool",
|
|
7
|
+
defaultLabel: "Handover to AI Agent Tool",
|
|
8
|
+
parentType: ["aiAgentJob", "llmPromptV2"],
|
|
9
|
+
constraints: {
|
|
10
|
+
editable: true,
|
|
11
|
+
deletable: true,
|
|
12
|
+
collapsable: true,
|
|
13
|
+
creatable: true,
|
|
14
|
+
movable: true,
|
|
15
|
+
placement: {
|
|
16
|
+
predecessor: {
|
|
17
|
+
whitelist: []
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
childFlowCreatable: false
|
|
21
|
+
},
|
|
22
|
+
behavior: {
|
|
23
|
+
stopping: true
|
|
24
|
+
},
|
|
25
|
+
preview: {
|
|
26
|
+
type: "text",
|
|
27
|
+
key: "toolId"
|
|
28
|
+
},
|
|
29
|
+
fields: [
|
|
30
|
+
{
|
|
31
|
+
key: "toolId",
|
|
32
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__TOOL_ID__LABEL",
|
|
33
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__TOOL_ID__DESCRIPTION",
|
|
34
|
+
type: "cognigyLLMText",
|
|
35
|
+
defaultValue: "handover_to_ai_agent",
|
|
36
|
+
params: {
|
|
37
|
+
required: true,
|
|
38
|
+
rows: 1,
|
|
39
|
+
multiline: false,
|
|
40
|
+
maxLength: 64,
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
key: "description",
|
|
45
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DESCRIPTION__LABEL",
|
|
46
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DESCRIPTION__DESCRIPTION",
|
|
47
|
+
type: "cognigyLLMText",
|
|
48
|
+
params: {
|
|
49
|
+
required: true,
|
|
50
|
+
rows: 5,
|
|
51
|
+
multiline: true,
|
|
52
|
+
placeholder: "UI__NODE_EDITOR__SERVICE__HANDOVER_TO_AI_AGENT_TOOL__FIELDS__DESCRIPTION__PLACEHOLDER"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: "parameters",
|
|
57
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__PARAMETERS__LABEL",
|
|
58
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__PARAMETERS__DESCRIPTION",
|
|
59
|
+
type: "toolParameters",
|
|
60
|
+
defaultValue: `{
|
|
61
|
+
"type": "object",
|
|
62
|
+
"properties": {
|
|
63
|
+
"handover_reason": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"description": "The reason for handing over to the AI Agent, including context from the conversation."
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"required": ["handover_reason"],
|
|
69
|
+
"additionalProperties": false
|
|
70
|
+
}`,
|
|
71
|
+
params: {
|
|
72
|
+
required: false,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
key: "flowNode",
|
|
77
|
+
type: "flowNode",
|
|
78
|
+
label: "UI__NODE_EDITOR__SERVICE__HANDOVER_TO_AI_AGENT_TOOL__FIELDS__FLOW_NODE__LABEL",
|
|
79
|
+
params: {
|
|
80
|
+
required: true,
|
|
81
|
+
nodeTypeFilter: ["aiAgentJob"]
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
key: "debugMessage",
|
|
86
|
+
type: "toggle",
|
|
87
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__LABEL",
|
|
88
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__DESCRIPTION",
|
|
89
|
+
defaultValue: true,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
key: "condition",
|
|
93
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__LABEL",
|
|
94
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__DESCRIPTION",
|
|
95
|
+
type: "cognigyText",
|
|
96
|
+
defaultValue: "",
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
sections: [
|
|
100
|
+
{
|
|
101
|
+
key: "debugging",
|
|
102
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__DEBUG_SETTINGS__LABEL",
|
|
103
|
+
defaultCollapsed: true,
|
|
104
|
+
fields: [
|
|
105
|
+
"debugMessage",
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
key: "advanced",
|
|
110
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__ADVANCED__LABEL",
|
|
111
|
+
defaultCollapsed: true,
|
|
112
|
+
fields: [
|
|
113
|
+
"condition",
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
form: [
|
|
118
|
+
{ type: "field", key: "toolId" },
|
|
119
|
+
{ type: "field", key: "description" },
|
|
120
|
+
{ type: "field", key: "flowNode" },
|
|
121
|
+
{ type: "section", key: "debugging" },
|
|
122
|
+
{ type: "section", key: "advanced" },
|
|
123
|
+
],
|
|
124
|
+
appearance: {
|
|
125
|
+
color: "white",
|
|
126
|
+
textColor: "#252525",
|
|
127
|
+
variant: "mini",
|
|
128
|
+
},
|
|
129
|
+
function: ({ cognigy, config, nodeId: thisNodeId }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
130
|
+
var _a, _b, _c, _d, _e, _f;
|
|
131
|
+
const { api } = cognigy;
|
|
132
|
+
const { debugMessage, flowNode } = config;
|
|
133
|
+
const sessionState = yield api.loadSessionState();
|
|
134
|
+
const toolCall = (_a = sessionState.lastToolCall) === null || _a === void 0 ? void 0 : _a.toolCall;
|
|
135
|
+
if (!(toolCall === null || toolCall === void 0 ? void 0 : toolCall.id)) {
|
|
136
|
+
(_b = api.logDebugError) === null || _b === void 0 ? void 0 : _b.call(api, "UI__DEBUG_MODE__AI_AGENT_ANSWER__ERROR__MESSAGE");
|
|
137
|
+
}
|
|
138
|
+
if (!(flowNode === null || flowNode === void 0 ? void 0 : flowNode.flow) || !(flowNode === null || flowNode === void 0 ? void 0 : flowNode.node)) {
|
|
139
|
+
throw new Error("Flow Node is required for Handover to AI Agent Tool");
|
|
140
|
+
}
|
|
141
|
+
if (toolCall) {
|
|
142
|
+
if (!((_c = api.checkThink) === null || _c === void 0 ? void 0 : _c.call(api, thisNodeId))) {
|
|
143
|
+
const handoverReason = ((_e = (_d = toolCall === null || toolCall === void 0 ? void 0 : toolCall.function) === null || _d === void 0 ? void 0 : _d.arguments) === null || _e === void 0 ? void 0 : _e.handover_reason) || "Handover requested";
|
|
144
|
+
// Optional Debug Message
|
|
145
|
+
if (debugMessage) {
|
|
146
|
+
(_f = api.logDebugMessage) === null || _f === void 0 ? void 0 : _f.call(api, JSON.stringify({ handover_reason: handoverReason, target_flow: flowNode.flow, target_node: flowNode.node }, null, 2));
|
|
147
|
+
}
|
|
148
|
+
// Add Tool Call Message to Transcript
|
|
149
|
+
const toolCallTranscriptStep = {
|
|
150
|
+
role: TranscriptRole.ASSISTANT,
|
|
151
|
+
type: TranscriptEntryType.TOOL_CALL,
|
|
152
|
+
source: "system",
|
|
153
|
+
payload: {
|
|
154
|
+
name: toolCall.function.name,
|
|
155
|
+
id: toolCall.id,
|
|
156
|
+
input: toolCall.function.arguments,
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
yield api.addTranscriptStep(toolCallTranscriptStep);
|
|
160
|
+
// Add Tool Answer Message to Transcript
|
|
161
|
+
const toolAnswer = {
|
|
162
|
+
role: TranscriptRole.TOOL,
|
|
163
|
+
type: TranscriptEntryType.TOOL_ANSWER,
|
|
164
|
+
source: "system",
|
|
165
|
+
payload: {
|
|
166
|
+
toolCallId: toolCall.id,
|
|
167
|
+
name: toolCall.function.name,
|
|
168
|
+
content: `Handover to AI Agent initiated. Reason: ${handoverReason}`,
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
yield api.addTranscriptStep(toolAnswer);
|
|
172
|
+
api.resetNextNodes();
|
|
173
|
+
api.updateSessionStateValues({
|
|
174
|
+
lastToolCall: undefined
|
|
175
|
+
});
|
|
176
|
+
yield api.executeFlow({
|
|
177
|
+
flowNode: {
|
|
178
|
+
flow: flowNode.flow,
|
|
179
|
+
node: flowNode.node,
|
|
180
|
+
},
|
|
181
|
+
absorbContext: true,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
throw new Error("Infinite Loop Detected");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
});
|
|
190
|
+
//# sourceMappingURL=handoverToAiAgentTool.js.map
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
/* Custom modules */
|
|
3
|
+
import { createNodeDescriptor } from "../../../createNodeDescriptor";
|
|
4
|
+
import { TranscriptEntryType, TranscriptRole } from "../../../../interfaces/transcripts/transcripts";
|
|
5
|
+
export const SEND_EMAIL_TOOL = createNodeDescriptor({
|
|
6
|
+
type: "sendEmailTool",
|
|
7
|
+
defaultLabel: "Send Email Tool",
|
|
8
|
+
parentType: ["aiAgentJob", "llmPromptV2"],
|
|
9
|
+
constraints: {
|
|
10
|
+
editable: true,
|
|
11
|
+
deletable: true,
|
|
12
|
+
collapsable: true,
|
|
13
|
+
creatable: true,
|
|
14
|
+
movable: true,
|
|
15
|
+
placement: {
|
|
16
|
+
predecessor: {
|
|
17
|
+
whitelist: []
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
childFlowCreatable: false
|
|
21
|
+
},
|
|
22
|
+
behavior: {
|
|
23
|
+
stopping: true
|
|
24
|
+
},
|
|
25
|
+
preview: {
|
|
26
|
+
type: "text",
|
|
27
|
+
key: "toolId"
|
|
28
|
+
},
|
|
29
|
+
fields: [
|
|
30
|
+
{
|
|
31
|
+
key: "toolId",
|
|
32
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__TOOL_ID__LABEL",
|
|
33
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__TOOL_ID__DESCRIPTION",
|
|
34
|
+
type: "cognigyLLMText",
|
|
35
|
+
defaultValue: "send_email",
|
|
36
|
+
params: {
|
|
37
|
+
required: true,
|
|
38
|
+
rows: 1,
|
|
39
|
+
multiline: false,
|
|
40
|
+
maxLength: 64,
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
key: "description",
|
|
45
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DESCRIPTION__LABEL",
|
|
46
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DESCRIPTION__DESCRIPTION",
|
|
47
|
+
type: "cognigyLLMText",
|
|
48
|
+
defaultValue: "Create and send a new email message.",
|
|
49
|
+
params: {
|
|
50
|
+
required: true,
|
|
51
|
+
rows: 5,
|
|
52
|
+
multiline: true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: "recipient",
|
|
57
|
+
label: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__RECIPIENT__LABEL",
|
|
58
|
+
description: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__RECIPIENT__DESCRIPTION",
|
|
59
|
+
type: "cognigyText",
|
|
60
|
+
params: {
|
|
61
|
+
required: true,
|
|
62
|
+
rows: 1,
|
|
63
|
+
multiline: false,
|
|
64
|
+
maxLength: 255,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
key: "parameters",
|
|
69
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__PARAMETERS__LABEL",
|
|
70
|
+
type: "toolParameters",
|
|
71
|
+
defaultValue: `{
|
|
72
|
+
"type": "object",
|
|
73
|
+
"properties": {
|
|
74
|
+
"subject": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"description": "The subject of the email."
|
|
77
|
+
},
|
|
78
|
+
"message": {
|
|
79
|
+
"type": "string",
|
|
80
|
+
"description": "The body of the email."
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"required": ["subject", "message"],
|
|
84
|
+
"additionalProperties": false
|
|
85
|
+
}`,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
key: "debugMessage",
|
|
89
|
+
type: "toggle",
|
|
90
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__LABEL",
|
|
91
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__DESCRIPTION",
|
|
92
|
+
defaultValue: true,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
key: "condition",
|
|
96
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__LABEL",
|
|
97
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__DESCRIPTION",
|
|
98
|
+
type: "cognigyText",
|
|
99
|
+
defaultValue: "",
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
sections: [
|
|
103
|
+
{
|
|
104
|
+
key: "debugging",
|
|
105
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__DEBUG_SETTINGS__LABEL",
|
|
106
|
+
defaultCollapsed: true,
|
|
107
|
+
fields: [
|
|
108
|
+
"debugMessage",
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
key: "advanced",
|
|
113
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__ADVANCED__LABEL",
|
|
114
|
+
defaultCollapsed: true,
|
|
115
|
+
fields: [
|
|
116
|
+
"condition"
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
form: [
|
|
121
|
+
{ type: "field", key: "toolId" },
|
|
122
|
+
{ type: "field", key: "description" },
|
|
123
|
+
{ type: "field", key: "recipient" },
|
|
124
|
+
{ type: "section", key: "debugging" },
|
|
125
|
+
{ type: "section", key: "advanced" },
|
|
126
|
+
],
|
|
127
|
+
appearance: {
|
|
128
|
+
color: "white",
|
|
129
|
+
textColor: "#252525",
|
|
130
|
+
variant: "mini",
|
|
131
|
+
},
|
|
132
|
+
function: ({ cognigy, config, nodeId, nodeType, organisationId, projectId, childConfigs }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
134
|
+
const { api, context, input } = cognigy;
|
|
135
|
+
const { debugMessage, recipient, } = config;
|
|
136
|
+
const sessionState = yield api.loadSessionState();
|
|
137
|
+
const toolCall = (_a = sessionState.lastToolCall) === null || _a === void 0 ? void 0 : _a.toolCall;
|
|
138
|
+
const aiAgentJobNode = (_b = sessionState.lastToolCall) === null || _b === void 0 ? void 0 : _b.aiAgentJobNode;
|
|
139
|
+
if (!(toolCall === null || toolCall === void 0 ? void 0 : toolCall.id)) {
|
|
140
|
+
(_c = api.logDebugError) === null || _c === void 0 ? void 0 : _c.call(api, "UI__DEBUG_MODE__AI_AGENT_ANSWER__ERROR__MESSAGE");
|
|
141
|
+
}
|
|
142
|
+
if (toolCall && aiAgentJobNode) {
|
|
143
|
+
if (!((_d = api.checkThink) === null || _d === void 0 ? void 0 : _d.call(api, nodeId))) {
|
|
144
|
+
const { subject, message } = toolCall.function.arguments;
|
|
145
|
+
let result;
|
|
146
|
+
try {
|
|
147
|
+
result = yield ((_e = api === null || api === void 0 ? void 0 : api.emailNotification) === null || _e === void 0 ? void 0 : _e.call(api, {
|
|
148
|
+
cognigy,
|
|
149
|
+
config: {
|
|
150
|
+
recipient,
|
|
151
|
+
subject,
|
|
152
|
+
message,
|
|
153
|
+
cc: "",
|
|
154
|
+
bcc: "",
|
|
155
|
+
priority: "normal",
|
|
156
|
+
async: false,
|
|
157
|
+
storeLocation: "none",
|
|
158
|
+
inputKey: "",
|
|
159
|
+
contextKey: "",
|
|
160
|
+
stopOnError: false,
|
|
161
|
+
},
|
|
162
|
+
nodeId,
|
|
163
|
+
nodeType,
|
|
164
|
+
organisationId,
|
|
165
|
+
projectId,
|
|
166
|
+
childConfigs,
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
// Log error message to debug mode
|
|
171
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
172
|
+
(_f = api.logDebugError) === null || _f === void 0 ? void 0 : _f.call(api, errorMessage, "UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__ERROR");
|
|
173
|
+
// Pass error message to LLM as result
|
|
174
|
+
result = errorMessage;
|
|
175
|
+
}
|
|
176
|
+
// Optional Debug Message of Email sending and response
|
|
177
|
+
if (debugMessage) {
|
|
178
|
+
const messageLines = [];
|
|
179
|
+
if (recipient) {
|
|
180
|
+
messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__RECIPIENT</b> ${recipient}`);
|
|
181
|
+
}
|
|
182
|
+
if (subject) {
|
|
183
|
+
messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__SUBJECT</b> ${subject}`);
|
|
184
|
+
}
|
|
185
|
+
if (message) {
|
|
186
|
+
messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__MESSAGE</b> ${message}`);
|
|
187
|
+
}
|
|
188
|
+
if (result) {
|
|
189
|
+
const resultString = typeof result === 'string' ? result : JSON.stringify(result, null, 2);
|
|
190
|
+
messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__RESULT</b>\n${resultString}`);
|
|
191
|
+
}
|
|
192
|
+
(_g = api.logDebugMessage) === null || _g === void 0 ? void 0 : _g.call(api, messageLines.join("\n"), "UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__HEADER");
|
|
193
|
+
}
|
|
194
|
+
const { flow, node } = aiAgentJobNode;
|
|
195
|
+
if (flow && node) {
|
|
196
|
+
// Add Tool Call Message to Transcript
|
|
197
|
+
const toolCallTranscriptStep = {
|
|
198
|
+
role: TranscriptRole.ASSISTANT,
|
|
199
|
+
type: TranscriptEntryType.TOOL_CALL,
|
|
200
|
+
source: "system",
|
|
201
|
+
payload: {
|
|
202
|
+
name: toolCall.function.name,
|
|
203
|
+
id: toolCall.id,
|
|
204
|
+
input: toolCall.function.arguments,
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
yield api.addTranscriptStep(toolCallTranscriptStep);
|
|
208
|
+
// Add Tool Answer Message to Transcript
|
|
209
|
+
const resultString = typeof result === 'string' ? result : JSON.stringify(result);
|
|
210
|
+
const toolAnswer = {
|
|
211
|
+
role: TranscriptRole.TOOL,
|
|
212
|
+
type: TranscriptEntryType.TOOL_ANSWER,
|
|
213
|
+
source: "system",
|
|
214
|
+
payload: {
|
|
215
|
+
toolCallId: toolCall.id,
|
|
216
|
+
name: toolCall.function.name,
|
|
217
|
+
content: `Send email result:\n${resultString}`,
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
yield api.addTranscriptStep(toolAnswer);
|
|
221
|
+
api.resetNextNodes();
|
|
222
|
+
// remove the call from the session state, because the call has been answered
|
|
223
|
+
api.updateSessionStateValues({
|
|
224
|
+
lastToolCall: undefined
|
|
225
|
+
});
|
|
226
|
+
yield api.executeFlow({
|
|
227
|
+
flowNode: {
|
|
228
|
+
flow,
|
|
229
|
+
node,
|
|
230
|
+
},
|
|
231
|
+
absorbContext: true,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
throw new Error("Infinite Loop Detected");
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
});
|
|
241
|
+
//# sourceMappingURL=sendEmailTool.js.map
|
|
@@ -11,7 +11,7 @@ import { generateSearchPrompt } from "./helpers/generateSearchPrompt";
|
|
|
11
11
|
import { getUserMemory } from "./helpers/getUserMemory";
|
|
12
12
|
import { createToolDefinitions } from "./helpers/createToolDefinitions";
|
|
13
13
|
import { TranscriptEntryType, TranscriptRole } from "../../../../interfaces/transcripts/transcripts";
|
|
14
|
-
export const AI_AGENT_TOOLS_WHITELIST = ["aiAgentJobDefault", "aiAgentJobTool", "aiAgentJobMCPTool", "knowledgeTool"];
|
|
14
|
+
export const AI_AGENT_TOOLS_WHITELIST = ["aiAgentJobDefault", "aiAgentJobTool", "aiAgentJobMCPTool", "knowledgeTool", "handoverToAiAgentTool", "sendEmailTool"];
|
|
15
15
|
export const AI_AGENT_JOB = createNodeDescriptor({
|
|
16
16
|
type: "aiAgentJob",
|
|
17
17
|
defaultLabel: "AI Agent",
|