@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
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cognigyDocumentParserProviderModule = exports.cognigyTranslationProviderModule = exports.cognigySpeechProviderModule = exports.cognigyGenerativeAIProviderModule = exports.cognigyInternalStorageProviderModule = exports.cognigyVoiceGateway2Module = exports.cognigyMicrosoftModule = exports.cognigyVoiceGatewayModule = exports.cognigySMTPModule = exports.cognigySQLModule = exports.cognigyMongoDBModule = exports.cognigyBasicModule = void 0;
|
|
3
|
+
exports.niceCXoneKnowledgehubProviderModule = exports.cognigyDocumentParserProviderModule = exports.cognigyTranslationProviderModule = exports.cognigySpeechProviderModule = exports.cognigyGenerativeAIProviderModule = exports.cognigyInternalStorageProviderModule = exports.cognigyVoiceGateway2Module = exports.cognigyMicrosoftModule = exports.cognigyVoiceGatewayModule = exports.cognigySMTPModule = exports.cognigySQLModule = exports.cognigyMongoDBModule = exports.cognigyBasicModule = void 0;
|
|
4
4
|
/* Custom modules */
|
|
5
5
|
const createNodeDescriptor_1 = require("../createNodeDescriptor");
|
|
6
6
|
/* Nodes */
|
|
@@ -150,6 +150,8 @@ if (process.env.DISABLE_FEATURE_TRANSCRIPT_MANAGER !== "true") {
|
|
|
150
150
|
nodes.push(service_1.AI_AGENT_JOB_CALL_MCP_TOOL);
|
|
151
151
|
nodes.push(service_1.AI_AGENT_TOOL_ANSWER);
|
|
152
152
|
nodes.push(service_1.KNOWLEDGE_TOOL);
|
|
153
|
+
nodes.push(service_1.HANDOVER_TO_AI_AGENT_TOOL);
|
|
154
|
+
nodes.push(service_1.SEND_EMAIL_TOOL);
|
|
153
155
|
nodes.push(service_1.AI_AGENT_HANDOVER);
|
|
154
156
|
nodes.push(service_1.LOAD_AI_AGENT);
|
|
155
157
|
}
|
|
@@ -200,4 +202,6 @@ var translationProviders_1 = require("./connectionNodes/translationProviders");
|
|
|
200
202
|
Object.defineProperty(exports, "cognigyTranslationProviderModule", { enumerable: true, get: function () { return translationProviders_1.cognigyTranslationProviderModule; } });
|
|
201
203
|
var documentParserProviders_1 = require("./connectionNodes/documentParserProviders");
|
|
202
204
|
Object.defineProperty(exports, "cognigyDocumentParserProviderModule", { enumerable: true, get: function () { return documentParserProviders_1.cognigyDocumentParserProviderModule; } });
|
|
205
|
+
var CXoneKnowledgehubProviderModule_1 = require("./service/cxone/knowledgehub/CXoneKnowledgehubProviderModule");
|
|
206
|
+
Object.defineProperty(exports, "niceCXoneKnowledgehubProviderModule", { enumerable: true, get: function () { return CXoneKnowledgehubProviderModule_1.niceCXoneKnowledgehubProviderModule; } });
|
|
203
207
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HANDOVER_TO_AI_AGENT_TOOL = void 0;
|
|
4
|
+
/* Custom modules */
|
|
5
|
+
const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
|
|
6
|
+
const transcripts_1 = require("../../../../interfaces/transcripts/transcripts");
|
|
7
|
+
exports.HANDOVER_TO_AI_AGENT_TOOL = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
8
|
+
type: "handoverToAiAgentTool",
|
|
9
|
+
defaultLabel: "Handover to AI Agent Tool",
|
|
10
|
+
parentType: ["aiAgentJob", "llmPromptV2"],
|
|
11
|
+
constraints: {
|
|
12
|
+
editable: true,
|
|
13
|
+
deletable: true,
|
|
14
|
+
collapsable: true,
|
|
15
|
+
creatable: true,
|
|
16
|
+
movable: true,
|
|
17
|
+
placement: {
|
|
18
|
+
predecessor: {
|
|
19
|
+
whitelist: []
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
childFlowCreatable: false
|
|
23
|
+
},
|
|
24
|
+
behavior: {
|
|
25
|
+
stopping: true
|
|
26
|
+
},
|
|
27
|
+
preview: {
|
|
28
|
+
type: "text",
|
|
29
|
+
key: "toolId"
|
|
30
|
+
},
|
|
31
|
+
fields: [
|
|
32
|
+
{
|
|
33
|
+
key: "toolId",
|
|
34
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__TOOL_ID__LABEL",
|
|
35
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__TOOL_ID__DESCRIPTION",
|
|
36
|
+
type: "cognigyLLMText",
|
|
37
|
+
defaultValue: "handover_to_ai_agent",
|
|
38
|
+
params: {
|
|
39
|
+
required: true,
|
|
40
|
+
rows: 1,
|
|
41
|
+
multiline: false,
|
|
42
|
+
maxLength: 64,
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: "description",
|
|
47
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DESCRIPTION__LABEL",
|
|
48
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DESCRIPTION__DESCRIPTION",
|
|
49
|
+
type: "cognigyLLMText",
|
|
50
|
+
params: {
|
|
51
|
+
required: true,
|
|
52
|
+
rows: 5,
|
|
53
|
+
multiline: true,
|
|
54
|
+
placeholder: "UI__NODE_EDITOR__SERVICE__HANDOVER_TO_AI_AGENT_TOOL__FIELDS__DESCRIPTION__PLACEHOLDER"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: "parameters",
|
|
59
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__PARAMETERS__LABEL",
|
|
60
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__PARAMETERS__DESCRIPTION",
|
|
61
|
+
type: "toolParameters",
|
|
62
|
+
defaultValue: `{
|
|
63
|
+
"type": "object",
|
|
64
|
+
"properties": {
|
|
65
|
+
"handover_reason": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "The reason for handing over to the AI Agent, including context from the conversation."
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"required": ["handover_reason"],
|
|
71
|
+
"additionalProperties": false
|
|
72
|
+
}`,
|
|
73
|
+
params: {
|
|
74
|
+
required: false,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
key: "flowNode",
|
|
79
|
+
type: "flowNode",
|
|
80
|
+
label: "UI__NODE_EDITOR__SERVICE__HANDOVER_TO_AI_AGENT_TOOL__FIELDS__FLOW_NODE__LABEL",
|
|
81
|
+
params: {
|
|
82
|
+
required: true,
|
|
83
|
+
nodeTypeFilter: ["aiAgentJob"]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
key: "debugMessage",
|
|
88
|
+
type: "toggle",
|
|
89
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__LABEL",
|
|
90
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__DESCRIPTION",
|
|
91
|
+
defaultValue: true,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
key: "condition",
|
|
95
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__LABEL",
|
|
96
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__DESCRIPTION",
|
|
97
|
+
type: "cognigyText",
|
|
98
|
+
defaultValue: "",
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
sections: [
|
|
102
|
+
{
|
|
103
|
+
key: "debugging",
|
|
104
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__DEBUG_SETTINGS__LABEL",
|
|
105
|
+
defaultCollapsed: true,
|
|
106
|
+
fields: [
|
|
107
|
+
"debugMessage",
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
key: "advanced",
|
|
112
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__ADVANCED__LABEL",
|
|
113
|
+
defaultCollapsed: true,
|
|
114
|
+
fields: [
|
|
115
|
+
"condition",
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
form: [
|
|
120
|
+
{ type: "field", key: "toolId" },
|
|
121
|
+
{ type: "field", key: "description" },
|
|
122
|
+
{ type: "field", key: "flowNode" },
|
|
123
|
+
{ type: "section", key: "debugging" },
|
|
124
|
+
{ type: "section", key: "advanced" },
|
|
125
|
+
],
|
|
126
|
+
appearance: {
|
|
127
|
+
color: "white",
|
|
128
|
+
textColor: "#252525",
|
|
129
|
+
variant: "mini",
|
|
130
|
+
},
|
|
131
|
+
function: async ({ cognigy, config, nodeId: thisNodeId }) => {
|
|
132
|
+
var _a, _b, _c, _d, _e, _f;
|
|
133
|
+
const { api } = cognigy;
|
|
134
|
+
const { debugMessage, flowNode } = config;
|
|
135
|
+
const sessionState = await api.loadSessionState();
|
|
136
|
+
const toolCall = (_a = sessionState.lastToolCall) === null || _a === void 0 ? void 0 : _a.toolCall;
|
|
137
|
+
if (!(toolCall === null || toolCall === void 0 ? void 0 : toolCall.id)) {
|
|
138
|
+
(_b = api.logDebugError) === null || _b === void 0 ? void 0 : _b.call(api, "UI__DEBUG_MODE__AI_AGENT_ANSWER__ERROR__MESSAGE");
|
|
139
|
+
}
|
|
140
|
+
if (!(flowNode === null || flowNode === void 0 ? void 0 : flowNode.flow) || !(flowNode === null || flowNode === void 0 ? void 0 : flowNode.node)) {
|
|
141
|
+
throw new Error("Flow Node is required for Handover to AI Agent Tool");
|
|
142
|
+
}
|
|
143
|
+
if (toolCall) {
|
|
144
|
+
if (!((_c = api.checkThink) === null || _c === void 0 ? void 0 : _c.call(api, thisNodeId))) {
|
|
145
|
+
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";
|
|
146
|
+
// Optional Debug Message
|
|
147
|
+
if (debugMessage) {
|
|
148
|
+
(_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));
|
|
149
|
+
}
|
|
150
|
+
// Add Tool Call Message to Transcript
|
|
151
|
+
const toolCallTranscriptStep = {
|
|
152
|
+
role: transcripts_1.TranscriptRole.ASSISTANT,
|
|
153
|
+
type: transcripts_1.TranscriptEntryType.TOOL_CALL,
|
|
154
|
+
source: "system",
|
|
155
|
+
payload: {
|
|
156
|
+
name: toolCall.function.name,
|
|
157
|
+
id: toolCall.id,
|
|
158
|
+
input: toolCall.function.arguments,
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
await api.addTranscriptStep(toolCallTranscriptStep);
|
|
162
|
+
// Add Tool Answer Message to Transcript
|
|
163
|
+
const toolAnswer = {
|
|
164
|
+
role: transcripts_1.TranscriptRole.TOOL,
|
|
165
|
+
type: transcripts_1.TranscriptEntryType.TOOL_ANSWER,
|
|
166
|
+
source: "system",
|
|
167
|
+
payload: {
|
|
168
|
+
toolCallId: toolCall.id,
|
|
169
|
+
name: toolCall.function.name,
|
|
170
|
+
content: `Handover to AI Agent initiated. Reason: ${handoverReason}`,
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
await api.addTranscriptStep(toolAnswer);
|
|
174
|
+
api.resetNextNodes();
|
|
175
|
+
api.updateSessionStateValues({
|
|
176
|
+
lastToolCall: undefined
|
|
177
|
+
});
|
|
178
|
+
await api.executeFlow({
|
|
179
|
+
flowNode: {
|
|
180
|
+
flow: flowNode.flow,
|
|
181
|
+
node: flowNode.node,
|
|
182
|
+
},
|
|
183
|
+
absorbContext: true,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
throw new Error("Infinite Loop Detected");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
//# sourceMappingURL=handoverToAiAgentTool.js.map
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SEND_EMAIL_TOOL = void 0;
|
|
4
|
+
/* Custom modules */
|
|
5
|
+
const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
|
|
6
|
+
const transcripts_1 = require("../../../../interfaces/transcripts/transcripts");
|
|
7
|
+
exports.SEND_EMAIL_TOOL = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
8
|
+
type: "sendEmailTool",
|
|
9
|
+
defaultLabel: "Send Email Tool",
|
|
10
|
+
parentType: ["aiAgentJob", "llmPromptV2"],
|
|
11
|
+
constraints: {
|
|
12
|
+
editable: true,
|
|
13
|
+
deletable: true,
|
|
14
|
+
collapsable: true,
|
|
15
|
+
creatable: true,
|
|
16
|
+
movable: true,
|
|
17
|
+
placement: {
|
|
18
|
+
predecessor: {
|
|
19
|
+
whitelist: []
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
childFlowCreatable: false
|
|
23
|
+
},
|
|
24
|
+
behavior: {
|
|
25
|
+
stopping: true
|
|
26
|
+
},
|
|
27
|
+
preview: {
|
|
28
|
+
type: "text",
|
|
29
|
+
key: "toolId"
|
|
30
|
+
},
|
|
31
|
+
fields: [
|
|
32
|
+
{
|
|
33
|
+
key: "toolId",
|
|
34
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__TOOL_ID__LABEL",
|
|
35
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__TOOL_ID__DESCRIPTION",
|
|
36
|
+
type: "cognigyLLMText",
|
|
37
|
+
defaultValue: "send_email",
|
|
38
|
+
params: {
|
|
39
|
+
required: true,
|
|
40
|
+
rows: 1,
|
|
41
|
+
multiline: false,
|
|
42
|
+
maxLength: 64,
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: "description",
|
|
47
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DESCRIPTION__LABEL",
|
|
48
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DESCRIPTION__DESCRIPTION",
|
|
49
|
+
type: "cognigyLLMText",
|
|
50
|
+
defaultValue: "Create and send a new email message.",
|
|
51
|
+
params: {
|
|
52
|
+
required: true,
|
|
53
|
+
rows: 5,
|
|
54
|
+
multiline: true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: "recipient",
|
|
59
|
+
label: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__RECIPIENT__LABEL",
|
|
60
|
+
description: "UI__NODE_EDITOR__SMTP__EMAIL_NOTIFICATION__RECIPIENT__DESCRIPTION",
|
|
61
|
+
type: "cognigyText",
|
|
62
|
+
params: {
|
|
63
|
+
required: true,
|
|
64
|
+
rows: 1,
|
|
65
|
+
multiline: false,
|
|
66
|
+
maxLength: 255,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
key: "parameters",
|
|
71
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__PARAMETERS__LABEL",
|
|
72
|
+
type: "toolParameters",
|
|
73
|
+
defaultValue: `{
|
|
74
|
+
"type": "object",
|
|
75
|
+
"properties": {
|
|
76
|
+
"subject": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "The subject of the email."
|
|
79
|
+
},
|
|
80
|
+
"message": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"description": "The body of the email."
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"required": ["subject", "message"],
|
|
86
|
+
"additionalProperties": false
|
|
87
|
+
}`,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
key: "debugMessage",
|
|
91
|
+
type: "toggle",
|
|
92
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__LABEL",
|
|
93
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__DEBUG_MESSAGE__DESCRIPTION",
|
|
94
|
+
defaultValue: true,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
key: "condition",
|
|
98
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__LABEL",
|
|
99
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_TOOL__FIELDS__CONDITION__DESCRIPTION",
|
|
100
|
+
type: "cognigyText",
|
|
101
|
+
defaultValue: "",
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
sections: [
|
|
105
|
+
{
|
|
106
|
+
key: "debugging",
|
|
107
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__DEBUG_SETTINGS__LABEL",
|
|
108
|
+
defaultCollapsed: true,
|
|
109
|
+
fields: [
|
|
110
|
+
"debugMessage",
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
key: "advanced",
|
|
115
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__ADVANCED__LABEL",
|
|
116
|
+
defaultCollapsed: true,
|
|
117
|
+
fields: [
|
|
118
|
+
"condition"
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
form: [
|
|
123
|
+
{ type: "field", key: "toolId" },
|
|
124
|
+
{ type: "field", key: "description" },
|
|
125
|
+
{ type: "field", key: "recipient" },
|
|
126
|
+
{ type: "section", key: "debugging" },
|
|
127
|
+
{ type: "section", key: "advanced" },
|
|
128
|
+
],
|
|
129
|
+
appearance: {
|
|
130
|
+
color: "white",
|
|
131
|
+
textColor: "#252525",
|
|
132
|
+
variant: "mini",
|
|
133
|
+
},
|
|
134
|
+
function: async ({ cognigy, config, nodeId, nodeType, organisationId, projectId, childConfigs }) => {
|
|
135
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
136
|
+
const { api, context, input } = cognigy;
|
|
137
|
+
const { debugMessage, recipient, } = config;
|
|
138
|
+
const sessionState = await api.loadSessionState();
|
|
139
|
+
const toolCall = (_a = sessionState.lastToolCall) === null || _a === void 0 ? void 0 : _a.toolCall;
|
|
140
|
+
const aiAgentJobNode = (_b = sessionState.lastToolCall) === null || _b === void 0 ? void 0 : _b.aiAgentJobNode;
|
|
141
|
+
if (!(toolCall === null || toolCall === void 0 ? void 0 : toolCall.id)) {
|
|
142
|
+
(_c = api.logDebugError) === null || _c === void 0 ? void 0 : _c.call(api, "UI__DEBUG_MODE__AI_AGENT_ANSWER__ERROR__MESSAGE");
|
|
143
|
+
}
|
|
144
|
+
if (toolCall && aiAgentJobNode) {
|
|
145
|
+
if (!((_d = api.checkThink) === null || _d === void 0 ? void 0 : _d.call(api, nodeId))) {
|
|
146
|
+
const { subject, message } = toolCall.function.arguments;
|
|
147
|
+
let result;
|
|
148
|
+
try {
|
|
149
|
+
result = await ((_e = api === null || api === void 0 ? void 0 : api.emailNotification) === null || _e === void 0 ? void 0 : _e.call(api, {
|
|
150
|
+
cognigy,
|
|
151
|
+
config: {
|
|
152
|
+
recipient,
|
|
153
|
+
subject,
|
|
154
|
+
message,
|
|
155
|
+
cc: "",
|
|
156
|
+
bcc: "",
|
|
157
|
+
priority: "normal",
|
|
158
|
+
async: false,
|
|
159
|
+
storeLocation: "none",
|
|
160
|
+
inputKey: "",
|
|
161
|
+
contextKey: "",
|
|
162
|
+
stopOnError: false,
|
|
163
|
+
},
|
|
164
|
+
nodeId,
|
|
165
|
+
nodeType,
|
|
166
|
+
organisationId,
|
|
167
|
+
projectId,
|
|
168
|
+
childConfigs,
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
// Log error message to debug mode
|
|
173
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
174
|
+
(_f = api.logDebugError) === null || _f === void 0 ? void 0 : _f.call(api, errorMessage, "UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__ERROR");
|
|
175
|
+
// Pass error message to LLM as result
|
|
176
|
+
result = errorMessage;
|
|
177
|
+
}
|
|
178
|
+
// Optional Debug Message of Email sending and response
|
|
179
|
+
if (debugMessage) {
|
|
180
|
+
const messageLines = [];
|
|
181
|
+
if (recipient) {
|
|
182
|
+
messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__RECIPIENT</b> ${recipient}`);
|
|
183
|
+
}
|
|
184
|
+
if (subject) {
|
|
185
|
+
messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__SUBJECT</b> ${subject}`);
|
|
186
|
+
}
|
|
187
|
+
if (message) {
|
|
188
|
+
messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__MESSAGE</b> ${message}`);
|
|
189
|
+
}
|
|
190
|
+
if (result) {
|
|
191
|
+
const resultString = typeof result === 'string' ? result : JSON.stringify(result, null, 2);
|
|
192
|
+
messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__RESULT</b>\n${resultString}`);
|
|
193
|
+
}
|
|
194
|
+
(_g = api.logDebugMessage) === null || _g === void 0 ? void 0 : _g.call(api, messageLines.join("\n"), "UI__DEBUG_MODE__AI_AGENT__SEND_EMAIL_TOOL__HEADER");
|
|
195
|
+
}
|
|
196
|
+
const { flow, node } = aiAgentJobNode;
|
|
197
|
+
if (flow && node) {
|
|
198
|
+
// Add Tool Call Message to Transcript
|
|
199
|
+
const toolCallTranscriptStep = {
|
|
200
|
+
role: transcripts_1.TranscriptRole.ASSISTANT,
|
|
201
|
+
type: transcripts_1.TranscriptEntryType.TOOL_CALL,
|
|
202
|
+
source: "system",
|
|
203
|
+
payload: {
|
|
204
|
+
name: toolCall.function.name,
|
|
205
|
+
id: toolCall.id,
|
|
206
|
+
input: toolCall.function.arguments,
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
await api.addTranscriptStep(toolCallTranscriptStep);
|
|
210
|
+
// Add Tool Answer Message to Transcript
|
|
211
|
+
const resultString = typeof result === 'string' ? result : JSON.stringify(result);
|
|
212
|
+
const toolAnswer = {
|
|
213
|
+
role: transcripts_1.TranscriptRole.TOOL,
|
|
214
|
+
type: transcripts_1.TranscriptEntryType.TOOL_ANSWER,
|
|
215
|
+
source: "system",
|
|
216
|
+
payload: {
|
|
217
|
+
toolCallId: toolCall.id,
|
|
218
|
+
name: toolCall.function.name,
|
|
219
|
+
content: `Send email result:\n${resultString}`,
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
await api.addTranscriptStep(toolAnswer);
|
|
223
|
+
api.resetNextNodes();
|
|
224
|
+
// remove the call from the session state, because the call has been answered
|
|
225
|
+
api.updateSessionStateValues({
|
|
226
|
+
lastToolCall: undefined
|
|
227
|
+
});
|
|
228
|
+
await api.executeFlow({
|
|
229
|
+
flowNode: {
|
|
230
|
+
flow,
|
|
231
|
+
node,
|
|
232
|
+
},
|
|
233
|
+
absorbContext: true,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
throw new Error("Infinite Loop Detected");
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
//# sourceMappingURL=sendEmailTool.js.map
|
|
@@ -24,7 +24,7 @@ const generateSearchPrompt_1 = require("./helpers/generateSearchPrompt");
|
|
|
24
24
|
const getUserMemory_1 = require("./helpers/getUserMemory");
|
|
25
25
|
const createToolDefinitions_1 = require("./helpers/createToolDefinitions");
|
|
26
26
|
const transcripts_1 = require("../../../../interfaces/transcripts/transcripts");
|
|
27
|
-
exports.AI_AGENT_TOOLS_WHITELIST = ["aiAgentJobDefault", "aiAgentJobTool", "aiAgentJobMCPTool", "knowledgeTool"];
|
|
27
|
+
exports.AI_AGENT_TOOLS_WHITELIST = ["aiAgentJobDefault", "aiAgentJobTool", "aiAgentJobMCPTool", "knowledgeTool", "handoverToAiAgentTool", "sendEmailTool"];
|
|
28
28
|
exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
29
29
|
type: "aiAgentJob",
|
|
30
30
|
defaultLabel: "AI Agent",
|