@cognigy/rest-api-client 0.19.0 → 0.20.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.
Files changed (118) hide show
  1. package/build/RestAPIClient.js +7 -0
  2. package/build/apigroups/AdministrationAPIGroup_2_0.js +6 -1
  3. package/build/apigroups/JWTAuthAPIGroup_2_0.js +12 -0
  4. package/build/apigroups/ResourcesAPIGroup_2_0.js +19 -8
  5. package/build/apigroups/index.js +3 -1
  6. package/build/shared/charts/descriptors/agentAssist/index.js +3 -1
  7. package/build/shared/charts/descriptors/agentAssist/sendData.js +74 -0
  8. package/build/shared/charts/descriptors/analytics/addMemory.js +51 -0
  9. package/build/shared/charts/descriptors/analytics/completeGoal.js +4 -3
  10. package/build/shared/charts/descriptors/analytics/helper.js +20 -0
  11. package/build/shared/charts/descriptors/analytics/index.js +5 -3
  12. package/build/shared/charts/descriptors/analytics/{trackMilestone.js → trackGoal.js} +32 -25
  13. package/build/shared/charts/descriptors/data/copySlotsToContext.js +1 -1
  14. package/build/shared/charts/descriptors/index.js +14 -2
  15. package/build/shared/charts/descriptors/knowledgeSearch/knowledgeSearchV2.js +1 -1
  16. package/build/shared/charts/descriptors/knowledgeSearch/searchExtractOutput.js +26 -16
  17. package/build/shared/charts/descriptors/logic/disableSlotFillers.js +1 -1
  18. package/build/shared/charts/descriptors/logic/enableSlotFillers.js +1 -1
  19. package/build/shared/charts/descriptors/logic/thinkV2.js +111 -4
  20. package/build/shared/charts/descriptors/nlu/cleanText.js +1 -1
  21. package/build/shared/charts/descriptors/nlu/executeCognigyNLU.js +1 -1
  22. package/build/shared/charts/descriptors/nlu/fuzzySearch.js +1 -1
  23. package/build/shared/charts/descriptors/nlu/generativeSlotFiller/generativeSlotFiller.js +1 -1
  24. package/build/shared/charts/descriptors/nlu/generativeSlotFiller/generativeSlotFillerFallback.js +1 -1
  25. package/build/shared/charts/descriptors/nlu/generativeSlotFiller/generativeSlotFillerSuccess.js +1 -1
  26. package/build/shared/charts/descriptors/nlu/generativeSlotFiller/prompt.js +4 -5
  27. package/build/shared/charts/descriptors/nlu/matchPattern.js +1 -1
  28. package/build/shared/charts/descriptors/nlu/regexSlotFiller.js +1 -1
  29. package/build/shared/charts/descriptors/service/GPTConversation.js +1 -1
  30. package/build/shared/charts/descriptors/service/GPTPrompt.js +26 -32
  31. package/build/shared/charts/descriptors/service/LLMEntityExtract.js +1 -1
  32. package/build/shared/charts/descriptors/service/aiAgent/aiAgentHandover.js +92 -0
  33. package/build/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +1146 -0
  34. package/build/shared/charts/descriptors/service/aiAgent/aiAgentJobDefault.js +31 -0
  35. package/build/shared/charts/descriptors/service/aiAgent/aiAgentJobTool.js +139 -0
  36. package/build/shared/charts/descriptors/service/aiAgent/aiAgentToolAnswer.js +120 -0
  37. package/build/shared/charts/descriptors/service/aiAgent/helper.js +222 -0
  38. package/build/shared/charts/descriptors/service/handoverV2.js +68 -13
  39. package/build/shared/charts/descriptors/service/index.js +11 -1
  40. package/build/shared/charts/descriptors/transcripts/addTranscriptStep.js +413 -0
  41. package/build/shared/charts/descriptors/transcripts/getTranscript.js +104 -0
  42. package/build/shared/charts/descriptors/transcripts/index.js +8 -0
  43. package/build/shared/charts/descriptors/voice/mappers/base.mapper.js +20 -0
  44. package/build/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +183 -107
  45. package/build/shared/charts/descriptors/voice/mappers/transfer.mapper.js +6 -9
  46. package/build/shared/charts/descriptors/voice/nodes/continuousAsr.js +3 -4
  47. package/build/shared/charts/descriptors/voicegateway/nodes/callRecording.js +8 -1
  48. package/build/shared/charts/descriptors/voicegateway/nodes/handover.js +4 -2
  49. package/build/shared/charts/descriptors/voicegateway/nodes/hangup.js +4 -2
  50. package/build/shared/charts/descriptors/voicegateway/nodes/helper/utils.js +14 -0
  51. package/build/shared/charts/descriptors/voicegateway/nodes/playURL.js +4 -5
  52. package/build/shared/charts/descriptors/voicegateway/nodes/sendMessage.js +8 -1
  53. package/build/shared/charts/descriptors/voicegateway/nodes/sendMetaData.js +7 -3
  54. package/build/shared/charts/descriptors/voicegateway/nodes/setSessionParams.js +8 -1
  55. package/build/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +15 -4
  56. package/build/shared/charts/descriptors/voicegateway2/nodes/transfer.js +15 -3
  57. package/build/shared/constants.js +7 -1
  58. package/build/shared/handoverClients/interfaces/THandoverEventType.js +1 -0
  59. package/build/shared/helper/logFullConfigToDebugMode.js +1 -1
  60. package/build/shared/helper/nlu/textCleaner.js +1 -1
  61. package/build/shared/interfaces/{restAPI/resources/milestone/v2.0/IMilestoneStep_2_0.js → IEndpointSettings.js} +1 -1
  62. package/build/shared/interfaces/IProfile.js +1 -0
  63. package/build/shared/interfaces/IProfileSchema.js +1 -0
  64. package/build/shared/interfaces/analytics/IAnalyticsSourceData.js +22 -20
  65. package/build/shared/interfaces/{restAPI/resources/milestone/v2.0/IMilestone_2_0.js → analytics/IGoalAnalytics.js} +1 -1
  66. package/build/shared/interfaces/generativeAI/IGenerativeAIModels.js +19 -2
  67. package/build/shared/interfaces/generativeAI/tools.js +3 -0
  68. package/build/shared/interfaces/handover.js +3 -1
  69. package/build/shared/interfaces/messageAPI/endpoints.js +6 -1
  70. package/build/shared/interfaces/messageAPI/handover.js +2 -0
  71. package/build/shared/interfaces/resources/IAiAgent.js +52 -0
  72. package/build/shared/interfaces/resources/IAuditEvent.js +2 -1
  73. package/build/shared/interfaces/resources/IEndpoint.js +2 -1
  74. package/build/shared/interfaces/resources/{IMilestone.js → IGoal.js} +14 -14
  75. package/build/shared/interfaces/resources/ILargeLanguageModel.js +29 -2
  76. package/build/shared/interfaces/resources/INodeDescriptorSet.js +4 -1
  77. package/build/shared/interfaces/resources/TResourceType.js +16 -8
  78. package/build/shared/interfaces/resources/settings/IGenerativeAISettings.js +5 -1
  79. package/build/shared/interfaces/restAPI/{resources/milestone/v2.0/ICloneMilestoneRest_2_0.js → administration/user/v2.0/IGetPinnedResources_2_0.js} +1 -1
  80. package/build/shared/interfaces/restAPI/administration/user/v2.0/IPinResourceRest_2_0.js +3 -0
  81. package/build/shared/interfaces/restAPI/resources/aiAgent/v2.0/IAiAgentHiringTemplate_2_0.js +32 -0
  82. package/build/shared/interfaces/restAPI/resources/aiAgent/v2.0/IAiAgent_2_0.js +3 -0
  83. package/build/shared/interfaces/restAPI/resources/aiAgent/v2.0/ICreateAiAgentRest_2_0.js +3 -0
  84. package/build/shared/interfaces/restAPI/resources/aiAgent/v2.0/IDeleteAiAgentRest_2_0.js +3 -0
  85. package/build/shared/interfaces/restAPI/resources/aiAgent/v2.0/IGetAiAgentHiringTemplates_2_0.js +3 -0
  86. package/build/shared/interfaces/restAPI/resources/aiAgent/v2.0/IHireAiAgent_2_0.js +3 -0
  87. package/build/shared/interfaces/restAPI/resources/aiAgent/v2.0/IIndexAiAgentRest_2_0.js +3 -0
  88. package/build/shared/interfaces/restAPI/resources/aiAgent/v2.0/IReadAiAgentRest_2_0.js +3 -0
  89. package/build/shared/interfaces/restAPI/resources/aiAgent/v2.0/IUpdateAiAgentRest_2_0.js +3 -0
  90. package/build/shared/interfaces/restAPI/resources/{milestone/v2.0/ICreateMilestoneRest_2_0.js → aiAgent/v2.0/IValidateAiAgentNameRest_2_0.js} +1 -1
  91. package/build/shared/interfaces/restAPI/resources/goal/v2.0/ICloneGoalRest_2_0.js +3 -0
  92. package/build/shared/interfaces/{analytics/IMilestoneAnalytics.js → restAPI/resources/goal/v2.0/ICreateGoalRest_2_0.js} +1 -1
  93. package/build/shared/interfaces/restAPI/resources/goal/v2.0/IDeleteGoalRest_2_0.js +3 -0
  94. package/build/shared/interfaces/restAPI/resources/goal/v2.0/IGoalIndexItem_2_0.js +3 -0
  95. package/build/shared/interfaces/restAPI/resources/goal/v2.0/IGoalStepMetric_2_0.js +3 -0
  96. package/build/shared/interfaces/restAPI/resources/goal/v2.0/IGoalStep_2_0.js +3 -0
  97. package/build/shared/interfaces/restAPI/resources/goal/v2.0/IGoal_2_0.js +3 -0
  98. package/build/shared/interfaces/restAPI/resources/goal/v2.0/IIndexGoalsRest_2_0.js +3 -0
  99. package/build/shared/interfaces/restAPI/resources/goal/v2.0/IReadGoalRest_2_0.js +3 -0
  100. package/build/shared/interfaces/restAPI/resources/goal/v2.0/IUpdateGoalRest_2_0.js +3 -0
  101. package/build/shared/interfaces/security/IPermission.js +6 -2
  102. package/build/shared/interfaces/security/IPinnedResource.js +3 -0
  103. package/build/shared/interfaces/security/index.js +1 -1
  104. package/build/shared/interfaces/transcripts/transcripts.js +33 -0
  105. package/package.json +1 -1
  106. package/types/index.d.ts +931 -224
  107. package/build/shared/interfaces/license.js.map +0 -1
  108. package/build/shared/interfaces/restAPI/resources/knowledgeSearchIndex/v2.0/ICreateKnowledgeSearchIndexRest_2_0.js +0 -3
  109. package/build/shared/interfaces/restAPI/resources/knowledgeSearchIndex/v2.0/IDeleteKnowledgeSearchIndexRest_2_0.js +0 -3
  110. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IDeleteMilestoneRest_2_0.js +0 -3
  111. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IIndexMilestonesRest_2_0.js +0 -3
  112. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IMilestoneIndexItem_2_0.js +0 -3
  113. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IMilestoneStepMetric_2_0.js +0 -3
  114. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IReadMilestoneRest_2_0.js +0 -3
  115. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IUpdateMilestoneRest_2_0.js +0 -3
  116. package/build/test.js +0 -27
  117. /package/build/shared/interfaces/restAPI/resources/{knowledgeSearchIndex → aiAgent}/v2.0/index.js +0 -0
  118. /package/build/shared/interfaces/restAPI/resources/{milestone → goal}/v2.0/index.js +0 -0
@@ -2,9 +2,178 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setSessionConfig = exports.vg2PayloadToActivityParams = exports.voiceConfigParamsToVoiceSettings = void 0;
4
4
  /* Node modules */
5
- const path_1 = require("path");
5
+ const base_mapper_1 = require("./base.mapper");
6
6
  const strip_nulls_1 = require("../../voicegateway2/utils/strip-nulls");
7
7
  const helper_1 = require("../utils/helper");
8
+ class SessionConfigMapper extends base_mapper_1.BaseMapper {
9
+ buildUser(sessionParams, userNoInput) {
10
+ const { userNoInputRetries, userNoInputMode, userNoInputSpeech, userNoInputTimeout, userNoInputUrl, userNoInputTimeoutEnable } = userNoInput || {};
11
+ const { user: sessionParamsUser } = sessionParams || {};
12
+ const { noInputSpeech, noInputUrl, noInputRetries, noInputTimeout, noInputMode } = sessionParamsUser || {};
13
+ const user = {};
14
+ /* verify if there are No User Input Configs to set */
15
+ if (userNoInput || sessionParamsUser) {
16
+ /* Either userNoInputTimeoutEnable is true, or the 'user' object is defined in the session params */
17
+ if (userNoInputTimeoutEnable === true || this.has(sessionParamsUser)) {
18
+ user.noInputMode = noInputMode || userNoInputMode;
19
+ switch (user.noInputMode) {
20
+ case "speech":
21
+ user.noInputSpeech = noInputSpeech || userNoInputSpeech;
22
+ break;
23
+ case "play":
24
+ user.noInputUrl = noInputUrl || userNoInputUrl;
25
+ break;
26
+ default:
27
+ break;
28
+ }
29
+ const retries = Number(noInputRetries) || Number(userNoInputRetries);
30
+ /* User No Input Retries. min: 0, max: 999 - if invalid range: set to 1 */
31
+ if (retries < 0 || retries > 999 || isNaN(retries)) {
32
+ user.noInputRetries = 1;
33
+ }
34
+ else {
35
+ user.noInputRetries = retries;
36
+ }
37
+ const timeout = Number(noInputTimeout) || Number(userNoInputTimeout);
38
+ if (timeout < 0 || isNaN(timeout)) {
39
+ user.noInputTimeout = 10;
40
+ }
41
+ else {
42
+ user.noInputTimeout = timeout / 1000;
43
+ }
44
+ }
45
+ else if (userNoInputTimeoutEnable === false && !this.has(sessionParamsUser)) {
46
+ user.noInputTimeout = 0;
47
+ }
48
+ }
49
+ if (sessionParams === null || sessionParams === void 0 ? void 0 : sessionParams.user) {
50
+ delete sessionParams.user;
51
+ }
52
+ return user;
53
+ }
54
+ buildFlow(sessionParams, flowNoInput) {
55
+ const { flowNoInputMode, flowNoInputRetries, flowNoInputSpeech, flowNoInputTimeout, flowNoInputTimeoutEnable, flowNoInputUrl, flowNoInputFail } = flowNoInput || {};
56
+ const { flow: sessionParamsFlow } = sessionParams || {};
57
+ const { flowNoInputEnable: spEnable, flowNoInputFail: spFail, flowNoInputMode: spMode, flowNoInputRetries: spRetries, flowNoInputSpeech: spSpeech, flowNoInputTimeout: spTimeout, flowNoInputUrl: spUrl } = sessionParamsFlow || {};
58
+ const flow = {};
59
+ // verify if there are No Flow Input Configs to set
60
+ if (flowNoInput || sessionParamsFlow) {
61
+ const enabled = spEnable === true || flowNoInputTimeoutEnable === true;
62
+ flow.flowNoInputEnable = enabled;
63
+ if (!enabled)
64
+ return flow;
65
+ if (enabled) {
66
+ flow.flowNoInputMode = spMode || flowNoInputMode;
67
+ flow.flowNoInputFail = spFail || flowNoInputFail;
68
+ switch (flow.flowNoInputMode) {
69
+ case "speech":
70
+ flow.flowNoInputSpeech = spSpeech || flowNoInputSpeech;
71
+ break;
72
+ case "play":
73
+ flow.flowNoInputUrl = spUrl || flowNoInputUrl;
74
+ break;
75
+ default:
76
+ break;
77
+ }
78
+ const retries = Number(spRetries) || Number(flowNoInputRetries);
79
+ /* User No Input Retries. min: 0, max: 999 - if invalid range: set to 1 */
80
+ if (retries <= 1 || retries > 999 || isNaN(retries)) {
81
+ flow.flowNoInputRetries = 1;
82
+ }
83
+ else {
84
+ flow.flowNoInputRetries = retries;
85
+ }
86
+ const timeout = Number(spTimeout) || Number(flowNoInputTimeout);
87
+ if (timeout < 0 || isNaN(timeout)) {
88
+ flow.flowNoInputTimeout = 10;
89
+ }
90
+ else {
91
+ flow.flowNoInputTimeout = timeout / 1000;
92
+ }
93
+ }
94
+ else if (!enabled && !this.has(sessionParamsFlow)) {
95
+ flow.flowNoInputTimeout = 0;
96
+ }
97
+ }
98
+ if (sessionParams === null || sessionParams === void 0 ? void 0 : sessionParams.flow) {
99
+ delete sessionParams.flow;
100
+ }
101
+ return flow;
102
+ }
103
+ buildBarge(sessionParams, dtmf, bargeIn) {
104
+ const { dtmf: sessionParamsDtmf, bargeIn: sessionParamsBargeIn } = sessionParams || {};
105
+ const { bargeInOnSpeech, bargeInOnDtmf, bargeInMinimunWords } = bargeIn || {};
106
+ const { bargeInOnSpeech: spSpeech, bargeInOnDtmf: spDtmf, bargeInMinimunWords: spMinWordCount } = sessionParamsBargeIn || {};
107
+ const { dtmfEnable, dtmfInterDigitTimeout, dtmfMaxDigits, dtmfMinDigits, dtmfSubmitDigit } = dtmf || {};
108
+ const { dtmfEnable: spEnable, dtmfInterDigitTimeout: spTimeout, dtmfMaxDigits: spMaxDigits, dtmfMinDigits: spMinDigits, dtmfSubmitDigit: spSubmitDigit } = sessionParamsDtmf || {};
109
+ let barge = {};
110
+ if (this.has(bargeIn) || this.has(sessionParamsBargeIn)) {
111
+ const speechEnabled = spSpeech || bargeInOnSpeech;
112
+ const dtmfEnabled = spDtmf || bargeInOnDtmf;
113
+ barge = {
114
+ enable: speechEnabled || bargeInOnDtmf,
115
+ actionHook: "voice",
116
+ dtmfBargein: dtmfEnabled,
117
+ input: [],
118
+ };
119
+ if (dtmfEnabled) {
120
+ barge.input.push("digits");
121
+ }
122
+ if (speechEnabled) {
123
+ const minWords = spMinWordCount || bargeInMinimunWords || 1;
124
+ /* Barge in minimum words. min: 1, max: 5, default: 1 */
125
+ if (minWords >= 1 && minWords <= 5) {
126
+ barge.minBargeinWordCount = minWords;
127
+ }
128
+ barge.input.push("speech");
129
+ }
130
+ }
131
+ if (dtmfEnable || spEnable) {
132
+ barge = Object.assign(Object.assign({}, barge), { maxDigits: 1, minDigits: Number(spMinDigits) || Number(dtmfMinDigits) || 1, finishOnKey: spSubmitDigit || dtmfSubmitDigit });
133
+ const timeout = Number(spTimeout) || Number(dtmfInterDigitTimeout) || 0;
134
+ if (timeout > 0) {
135
+ barge.interDigitTimeout = timeout / 1000;
136
+ }
137
+ /* Max digits. min: 1, max: - default: 1 */
138
+ const max = Number(spMaxDigits) || Number(dtmfMaxDigits);
139
+ if (max >= 1) {
140
+ barge.maxDigits = max;
141
+ }
142
+ }
143
+ if (sessionParams === null || sessionParams === void 0 ? void 0 : sessionParams.bargeIn) {
144
+ delete sessionParams.bargeIn;
145
+ }
146
+ if (sessionParams === null || sessionParams === void 0 ? void 0 : sessionParams.dtmf) {
147
+ delete sessionParams.dtmf;
148
+ }
149
+ return barge;
150
+ }
151
+ recognizerApplyContinuousAsr(sessionParams, recognizer, continuousAsr) {
152
+ const { continuousAsr: sessionParamsContinuousAsr } = sessionParams || {};
153
+ const { asrEnabled, asrDigit, asrTimeout = 0 } = continuousAsr || {};
154
+ const { asrDigit: spAsrDigit, asrEnabled: spAsrEnabled, asrTimeout: spAsrTimeout = 0 } = sessionParamsContinuousAsr || {};
155
+ // verify if there are Continuous ASR Configs to set
156
+ if (spAsrEnabled || asrEnabled) {
157
+ recognizer.asrDtmfTerminationDigit = spAsrDigit || asrDigit;
158
+ const timeout = Number(spAsrTimeout || asrTimeout);
159
+ recognizer.asrTimeout = timeout / 1000 || undefined;
160
+ }
161
+ if (sessionParams === null || sessionParams === void 0 ? void 0 : sessionParams.continuousAsr) {
162
+ delete sessionParams.continuousAsr;
163
+ }
164
+ return recognizer;
165
+ }
166
+ isDtmfEnabled(sessionParams, dtmf) {
167
+ const { dtmf: sessionParamsDtmf } = sessionParams || {};
168
+ const { dtmfEnable } = dtmf || {};
169
+ const { dtmfEnable: spEnable } = sessionParamsDtmf || {};
170
+ if (dtmf && (typeof dtmfEnable === "boolean" || typeof spEnable === "boolean")) {
171
+ return dtmfEnable === true || spEnable === true;
172
+ }
173
+ return undefined;
174
+ }
175
+ }
176
+ const mapper = new SessionConfigMapper("voiceGateway2");
8
177
  function voiceConfigParamsToVoiceSettings(config, api) {
9
178
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
10
179
  let voiceSettings = {};
@@ -81,6 +250,9 @@ function voiceConfigParamsToVoiceSettings(config, api) {
81
250
  }
82
251
  });
83
252
  }
253
+ else {
254
+ voiceSettings.stt.altLanguages = [];
255
+ }
84
256
  }
85
257
  if (config.sttVendor === "google") {
86
258
  if (config.recognizeLanguagesGoogle) {
@@ -93,6 +265,9 @@ function voiceConfigParamsToVoiceSettings(config, api) {
93
265
  }
94
266
  });
95
267
  }
268
+ else {
269
+ voiceSettings.stt.altLanguages = [];
270
+ }
96
271
  }
97
272
  if (config.ttsVendor === "elevenlabs") {
98
273
  voiceSettings.tts.ttsModel = config.ttsModel;
@@ -112,7 +287,8 @@ function voiceConfigParamsToVoiceSettings(config, api) {
112
287
  flowNoInputRetries: config.flowNoInputRetries,
113
288
  flowNoInputSpeech: config.flowNoInputSpeech,
114
289
  flowNoInputUrl: config.flowNoInputUrl,
115
- flowNoInputTimeoutEnable: config.flowNoInputTimeoutEnable
290
+ flowNoInputTimeoutEnable: config.flowNoInputTimeoutEnable,
291
+ flowNoInputFail: config.flowNoInputFail
116
292
  };
117
293
  // Check if userNoInputTimeout has a value and userNoInputTimeoutEnable is null or undefined to cover generic nodes
118
294
  if (((_j = voiceSettings === null || voiceSettings === void 0 ? void 0 : voiceSettings.userNoInput) === null || _j === void 0 ? void 0 : _j.userNoInputTimeout) && (voiceSettings.userNoInput.userNoInputTimeoutEnable === null || voiceSettings.userNoInput.userNoInputTimeoutEnable === undefined)) {
@@ -173,10 +349,6 @@ function voiceConfigParamsToVoiceSettings(config, api) {
173
349
  if (!(0, helper_1.isValidUrl)(config.atmosphereUrl)) {
174
350
  throw new Error(`Audio file URL is invalid ${config.atmosphereUrl}`);
175
351
  }
176
- const extension = (0, path_1.extname)(config.atmosphereUrl);
177
- if ([".mp3"].indexOf(extension) === -1) {
178
- throw new Error(`Audio file must be from type .mp3 Extension was: ${extension}`);
179
- }
180
352
  }
181
353
  voiceSettings.atmosphereNoise = {
182
354
  action: config.atmosphereAction,
@@ -223,8 +395,6 @@ exports.setSessionConfig = {
223
395
  handleVGInput(voiceSettings, sessionParams, api) {
224
396
  var _a, _b;
225
397
  const { bargeIn, continuousAsr, stt, tts, userNoInput, dtmf, vad, azureConfig, atmosphereNoise, silenceOverlay, flowNoInput } = voiceSettings;
226
- const user = {};
227
- const flow = {};
228
398
  const synthesizer = {};
229
399
  const recognizer = {};
230
400
  //verify if there are STT Configs to set
@@ -275,106 +445,12 @@ exports.setSessionConfig = {
275
445
  };
276
446
  }
277
447
  }
278
- //verify if there are No User Input Configs to set
279
- if (userNoInput) {
280
- const { userNoInputRetries, userNoInputMode, userNoInputSpeech, userNoInputTimeout, userNoInputUrl, userNoInputTimeoutEnable } = userNoInput || {};
281
- if (userNoInputTimeoutEnable === true) {
282
- user.noInputMode = userNoInputMode;
283
- if (userNoInputMode === "speech" && userNoInputSpeech)
284
- user.noInputSpeech = userNoInputSpeech;
285
- if (userNoInputMode === "play" && userNoInputUrl)
286
- user.noInputUrl = userNoInputUrl;
287
- /* User No Input Retries. min: 0, max: 999*/
288
- if (userNoInputRetries < 0 || userNoInputRetries > 999) {
289
- user.noInputRetries = 1;
290
- }
291
- else {
292
- user.noInputRetries = userNoInputRetries !== null && userNoInputRetries !== void 0 ? userNoInputRetries : 1;
293
- }
294
- user.noInputTimeout = userNoInputTimeout
295
- ? userNoInputTimeout / 1000
296
- : 10;
297
- }
298
- else if (userNoInputTimeoutEnable === false) {
299
- user.noInputTimeout = 0;
300
- }
301
- }
302
- //verify if there are No Flow Input Configs to set
303
- if (flowNoInput) {
304
- const { flowNoInputMode, flowNoInputRetries, flowNoInputSpeech, flowNoInputTimeout, flowNoInputTimeoutEnable, flowNoInputUrl } = flowNoInput || {};
305
- flow.flowNoInputEnable = flowNoInputTimeoutEnable;
306
- if (flowNoInputTimeoutEnable === true) {
307
- flow.flowNoInputMode = flowNoInputMode;
308
- if (flowNoInputMode === "speech" && flowNoInputSpeech)
309
- flow.flowNoInputSpeech = flowNoInputSpeech;
310
- if (flowNoInputMode === "play" && flowNoInputUrl)
311
- flow.flowNoInputUrl = flowNoInputUrl;
312
- /* User No Input Retries. min: 0, max: 999*/
313
- if (flowNoInputRetries < 0 || flowNoInputRetries > 999) {
314
- flow.flowNoInputRetries = 1;
315
- }
316
- else {
317
- flow.flowNoInputRetries = flowNoInputRetries !== null && flowNoInputRetries !== void 0 ? flowNoInputRetries : 1;
318
- }
319
- flow.flowNoInputTimeout = flowNoInputTimeout
320
- ? flowNoInputTimeout / 1000
321
- : 10;
322
- }
323
- else if (flowNoInputTimeoutEnable === false) {
324
- flow.flowNoInputTimeout = undefined;
325
- }
326
- }
327
- // verify if there are Continuous ASR Configs to set
328
- if (continuousAsr === null || continuousAsr === void 0 ? void 0 : continuousAsr.asrEnabled) {
329
- recognizer.asrDtmfTerminationDigit = continuousAsr.asrDigit;
330
- recognizer.asrTimeout = continuousAsr.asrTimeout
331
- ? continuousAsr.asrTimeout / 1000
332
- : undefined;
333
- }
334
- // verify if there are Barge In Configs to set
335
- let barge = {};
336
- if (bargeIn) {
337
- const { bargeInOnSpeech, bargeInOnDtmf, bargeInMinimunWords = 1 } = bargeIn;
338
- barge = {
339
- enable: bargeInOnSpeech || bargeInOnDtmf,
340
- actionHook: "voice",
341
- dtmfBargein: bargeInOnDtmf,
342
- input: [],
343
- };
344
- if (bargeInOnDtmf) {
345
- barge.input.push("digits");
346
- }
347
- if (bargeInOnSpeech) {
348
- /* Barge in minimum words. min: 1, max: 5, default: 1 */
349
- if (bargeInMinimunWords >= 1 && bargeInMinimunWords <= 5) {
350
- barge.minBargeinWordCount = bargeInMinimunWords;
351
- }
352
- barge.input.push("speech");
353
- }
354
- }
355
- let enableDTMF;
356
- // verify if there are DTMF Configs to set
357
- if (dtmf) {
358
- const { dtmfEnable, dtmfInterDigitTimeout = 0, dtmfMaxDigits, dtmfMinDigits, dtmfSubmitDigit } = dtmf;
359
- enableDTMF = dtmfEnable;
360
- if (dtmfEnable) {
361
- barge = Object.assign(Object.assign({}, barge), { maxDigits: 1, minDigits: dtmfMinDigits || 1, finishOnKey: dtmfSubmitDigit });
362
- if (typeof dtmfInterDigitTimeout === "number") {
363
- if (dtmfInterDigitTimeout > 0) {
364
- barge.interDigitTimeout = dtmfInterDigitTimeout / 1000;
365
- }
366
- }
367
- /* Max digits. min: 1, max: - default: 1 */
368
- if (dtmfMaxDigits >= 1) {
369
- barge.maxDigits = dtmf.dtmfMaxDigits;
370
- }
371
- }
372
- }
448
+ mapper.recognizerApplyContinuousAsr(sessionParams, recognizer, continuousAsr);
373
449
  // Check if there are configs for synthesizer, recognizer and bargeIn
374
450
  let voiceConfig = {
375
451
  synthesizer: synthesizer || undefined,
376
452
  recognizer: recognizer || undefined,
377
- bargeIn: barge || undefined,
453
+ bargeIn: mapper.buildBarge(sessionParams, dtmf, bargeIn) || undefined,
378
454
  };
379
455
  if (voiceConfig.synthesizer && !voiceConfig.synthesizer.azureServiceEndpoint) {
380
456
  voiceConfig.synthesizer.azureServiceEndpoint = "";
@@ -392,9 +468,9 @@ exports.setSessionConfig = {
392
468
  }
393
469
  // Check if there are configs for No User Input and DTMF
394
470
  const cognigyConfig = {
395
- user: user || undefined,
396
- flow: flow || undefined,
397
- dtmf: enableDTMF,
471
+ user: mapper.buildUser(sessionParams, userNoInput) || undefined,
472
+ flow: mapper.buildFlow(sessionParams, flowNoInput) || undefined,
473
+ dtmf: mapper.isDtmfEnabled(sessionParams, dtmf),
398
474
  };
399
475
  if (tts && typeof tts.ttsDisableCache === "boolean") {
400
476
  cognigyConfig.disableTtsCache = tts.ttsDisableCache;
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.prepareTransferParams = exports.transfer = void 0;
4
- /* Node modules */
5
- const path_1 = require("path");
6
4
  /* Custom modules */
7
5
  const helper_1 = require("../../../descriptors/voicegateway2/utils/helper");
8
6
  const helper_2 = require("../utils/helper");
9
7
  exports.transfer = {
10
- handleInput(endpointType, params, isGenericNode, recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting) {
8
+ handleInput(endpointType, params, isGenericNode = false, recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, anchorMedia) {
11
9
  try {
12
10
  switch (endpointType) {
13
11
  case "bandwidth":
@@ -26,14 +24,14 @@ exports.transfer = {
26
24
  return this.handleAudioCodesInput((0, exports.prepareTransferParams)(params), endpointType);
27
25
  case "voiceGateway2":
28
26
  default:
29
- return this.handleVGInput((0, exports.prepareTransferParams)(params), recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting);
27
+ return this.handleVGInput((0, exports.prepareTransferParams)(params), recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, anchorMedia);
30
28
  }
31
29
  }
32
30
  catch (error) {
33
31
  throw Error(error.message);
34
32
  }
35
33
  },
36
- handleVGInput(transferParam, recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting) {
34
+ handleVGInput(transferParam, recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, anchorMedia) {
37
35
  const { transferType, transferTarget, transferReason, referredBy, useTransferSipHeaders, transferSipHeaders, dialMusic, dialTranscriptionWebhook, dialCallerId, amdEnabled, amdRedirectOnMachineDetected, amdRedirectText, dialTimeout, sttLabel } = transferParam;
38
36
  const payload = {
39
37
  _voiceGateway2: {
@@ -128,10 +126,6 @@ exports.transfer = {
128
126
  if (!(0, helper_2.isValidUrl)(dialMusic)) {
129
127
  throw new Error(`Audio file URL is invalid ${dialMusic}`);
130
128
  }
131
- const extension = (0, path_1.extname)(dialMusic);
132
- if ([".mp3", ".wav"].indexOf(extension) === -1) {
133
- throw new Error(`Audio file must be from type .mp3 or .wav. Extension was: ${extension}`);
134
- }
135
129
  dialVerb.dialMusic = dialMusic;
136
130
  }
137
131
  if (dialCallerId === null || dialCallerId === void 0 ? void 0 : dialCallerId.length) {
@@ -140,6 +134,9 @@ exports.transfer = {
140
134
  }
141
135
  dialVerb.callerId = dialCallerId;
142
136
  }
137
+ if (anchorMedia) {
138
+ dialVerb.anchorMedia = anchorMedia;
139
+ }
143
140
  payload._voiceGateway2.json["dial"] = dialVerb;
144
141
  break;
145
142
  case "refer":
@@ -46,14 +46,13 @@ exports.CONTINUOUS_ASR = (0, createNodeDescriptor_1.createNodeDescriptor)({
46
46
  label: "UI__NODE_EDITOR__CONTINUOUS_ASR__FIELDS__ASR_TIMEOUT__LABEL",
47
47
  description: "UI__NODE_EDITOR__CONTINUOUS_ASR__FIELDS__ASR_TIMEOUT__DESCRIPTION",
48
48
  defaultValue: 3000,
49
+ params: {
50
+ min: 2000
51
+ },
49
52
  condition: {
50
53
  key: "asrEnabled",
51
54
  value: true,
52
55
  },
53
- params: {
54
- min: 500,
55
- max: 60000,
56
- },
57
56
  },
58
57
  ],
59
58
  function: async ({ cognigy, config }) => {
@@ -5,6 +5,7 @@ exports.callRecordingNode = void 0;
5
5
  const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
6
6
  /** Helper Modules */
7
7
  const design_1 = require("../utils/design");
8
+ const utils_1 = require("./helper/utils");
8
9
  exports.callRecordingNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
9
10
  type: "callRecording",
10
11
  defaultLabel: "Call Recording",
@@ -75,7 +76,7 @@ exports.callRecordingNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
75
76
  key: "activity",
76
77
  type: "text",
77
78
  },
78
- function: async ({ cognigy, config }) => {
79
+ function: async ({ cognigy, config, nodeId }) => {
79
80
  const { api } = cognigy;
80
81
  const { activity, callRecordingDestUsername, callRecordingId, callRecordingServer, } = config;
81
82
  let activities = [];
@@ -106,6 +107,12 @@ exports.callRecordingNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
106
107
  default:
107
108
  api.log("error", "Invalid activity");
108
109
  }
110
+ const { isFeatureAccmEnabled } = api.getEndpointSettings();
111
+ if (isFeatureAccmEnabled) {
112
+ return api.say(null, {
113
+ _cognigy: (0, utils_1.buildPayloadAccm)("callRecording", config, nodeId)
114
+ });
115
+ }
109
116
  api.output(null, {
110
117
  _cognigy: {
111
118
  _voiceGateway: {
@@ -6,6 +6,7 @@ const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
6
6
  /** Helper Modules */
7
7
  const design_1 = require("../utils/design");
8
8
  const transfer_mapper_1 = require("../../voice/mappers/transfer.mapper");
9
+ const utils_1 = require("./helper/utils");
9
10
  exports.handoverNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
10
11
  type: "handover",
11
12
  defaultLabel: "Transfer",
@@ -116,7 +117,7 @@ exports.handoverNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
116
117
  key: "advanced"
117
118
  }
118
119
  ],
119
- function: async ({ cognigy, config }) => {
120
+ function: async ({ cognigy, config, nodeId }) => {
120
121
  const { api, input } = cognigy;
121
122
  const { handoverReason, transferTarget, transferReferredByURL, useTransferSipHeaders, transferSipHeaders, transferNotifications, transferNotificationsHangupMS } = config;
122
123
  const transferParams = {
@@ -133,7 +134,8 @@ exports.handoverNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
133
134
  api.say("Transferring a call is not supported in the Interaction Panel, please use the AudioCodes endpoint.", null);
134
135
  return;
135
136
  }
136
- const payload = transfer_mapper_1.transfer.handleInput("audioCodes", transferParams, false);
137
+ const { isFeatureAccmEnabled } = api.getEndpointSettings();
138
+ const payload = isFeatureAccmEnabled ? (0, utils_1.buildPayloadAccm)("handover", transferParams, nodeId) : transfer_mapper_1.transfer.handleInput("audioCodes", transferParams);
137
139
  api.say(null, {
138
140
  _cognigy: payload
139
141
  });
@@ -6,6 +6,7 @@ const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
6
6
  /** Helper Modules */
7
7
  const design_1 = require("../utils/design");
8
8
  const hangup_mapper_1 = require("../../voice/mappers/hangup.mapper");
9
+ const utils_1 = require("./helper/utils");
9
10
  exports.hangupNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
10
11
  type: "hangup",
11
12
  defaultLabel: "Hang Up",
@@ -31,11 +32,12 @@ exports.hangupNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
31
32
  form: [
32
33
  { type: "field", key: "hangupReason" }
33
34
  ],
34
- function: async ({ cognigy, config }) => {
35
+ function: async ({ cognigy, config, nodeId }) => {
35
36
  const { api } = cognigy;
36
37
  const { hangupReason } = config;
37
38
  try {
38
- const payload = hangup_mapper_1.hangUp.handleInput("audioCodes", hangupReason);
39
+ const { isFeatureAccmEnabled } = api.getEndpointSettings();
40
+ const payload = isFeatureAccmEnabled ? (0, utils_1.buildPayloadAccm)("hangup", config, nodeId) : hangup_mapper_1.hangUp.handleInput("audioCodes", hangupReason);
39
41
  api.say(null, {
40
42
  _cognigy: payload
41
43
  });
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildPayloadAccm = void 0;
4
+ const buildPayloadAccm = (task, nodeData, nodeId) => ({
5
+ _accm: {
6
+ json: {
7
+ task,
8
+ nodeId,
9
+ [task]: nodeData
10
+ }
11
+ }
12
+ });
13
+ exports.buildPayloadAccm = buildPayloadAccm;
14
+ //# sourceMappingURL=utils.js.map
@@ -7,6 +7,7 @@ const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
7
7
  const play_mapper_1 = require("../../voice/mappers/play.mapper");
8
8
  const design_1 = require("../utils/design");
9
9
  const paramUtils_1 = require("../utils/paramUtils");
10
+ const utils_1 = require("./helper/utils");
10
11
  exports.playURLNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
11
12
  type: "playURL",
12
13
  defaultLabel: "Play URL",
@@ -111,15 +112,13 @@ exports.playURLNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
111
112
  appearance: {
112
113
  color: design_1.nodeColor
113
114
  },
114
- function: async ({ cognigy, config }) => {
115
+ function: async ({ cognigy, config, nodeId }) => {
115
116
  const { api } = cognigy;
116
117
  const { playUrlUrl, playUrlMediaFormat } = config;
117
118
  if (playUrlUrl && playUrlMediaFormat) {
118
119
  try {
119
- const payload = play_mapper_1.play.handleInput({
120
- endpointType: 'audioCodes',
121
- config
122
- });
120
+ const { isFeatureAccmEnabled } = api.getEndpointSettings();
121
+ const payload = isFeatureAccmEnabled ? (0, utils_1.buildPayloadAccm)("playURL", config, nodeId) : play_mapper_1.play.handleInput({ endpointType: 'audioCodes', config });
123
122
  api.say(null, {
124
123
  _cognigy: payload
125
124
  });
@@ -6,6 +6,7 @@ const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
6
6
  /** Helper Modules */
7
7
  const design_1 = require("../utils/design");
8
8
  const paramUtils_1 = require("../utils/paramUtils");
9
+ const utils_1 = require("./helper/utils");
9
10
  exports.sendMessageNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
10
11
  type: "sendMessage",
11
12
  defaultLabel: "Send Message",
@@ -244,9 +245,15 @@ exports.sendMessageNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
244
245
  appearance: {
245
246
  color: design_1.nodeColor
246
247
  },
247
- function: async ({ cognigy, config }) => {
248
+ function: async ({ cognigy, config, nodeId }) => {
248
249
  const { api } = cognigy;
249
250
  const { text, activityParams, setActivityParams } = config;
251
+ const { isFeatureAccmEnabled } = api.getEndpointSettings();
252
+ if (isFeatureAccmEnabled && text) {
253
+ return api.say(null, {
254
+ _cognigy: (0, utils_1.buildPayloadAccm)("sendMessage", config, nodeId)
255
+ });
256
+ }
250
257
  let compiledParams = activityParams || {};
251
258
  if (setActivityParams) {
252
259
  (0, paramUtils_1.compileParams)(config, compiledParams);
@@ -6,6 +6,7 @@ const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
6
6
  const sendMetadata_mapper_1 = require("../../voice/mappers/sendMetadata.mapper");
7
7
  /** Helper Modules */
8
8
  const design_1 = require("../utils/design");
9
+ const utils_1 = require("./helper/utils");
9
10
  exports.sendMetaDataNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
10
11
  type: "sendMetaData",
11
12
  defaultLabel: "Send Meta Data",
@@ -28,13 +29,16 @@ exports.sendMetaDataNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
28
29
  form: [
29
30
  { type: "field", key: "metaData" }
30
31
  ],
31
- function: async ({ cognigy, config }) => {
32
+ function: async ({ cognigy, config, nodeId }) => {
32
33
  const { api } = cognigy;
33
- if (!config.metaData)
34
+ if (!config.metaData) {
34
35
  return;
36
+ }
35
37
  try {
38
+ const { isFeatureAccmEnabled } = api.getEndpointSettings();
39
+ const payload = isFeatureAccmEnabled ? (0, utils_1.buildPayloadAccm)("sendMetadata", config, nodeId) : sendMetadata_mapper_1.sendMetadata.handleInput("audioCodes", config.metaData);
36
40
  api.output(null, {
37
- _cognigy: sendMetadata_mapper_1.sendMetadata.handleInput("audioCodes", config.metaData)
41
+ _cognigy: payload
38
42
  });
39
43
  }
40
44
  catch (error) {
@@ -6,6 +6,7 @@ const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
6
6
  /** Helper Modules */
7
7
  const design_1 = require("../utils/design");
8
8
  const paramUtils_1 = require("../utils/paramUtils");
9
+ const utils_1 = require("./helper/utils");
9
10
  exports.setSessionParamsNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
10
11
  type: "setSessionParams",
11
12
  defaultLabel: "Set Session Parameters",
@@ -47,9 +48,15 @@ exports.setSessionParamsNode = (0, createNodeDescriptor_1.createNodeDescriptor)(
47
48
  { type: "section", key: "params_google" },
48
49
  { type: "section", key: "advanced" },
49
50
  ],
50
- function: async ({ cognigy, config }) => {
51
+ function: async ({ cognigy, config, nodeId }) => {
51
52
  const { api } = cognigy;
52
53
  const { sessionParams } = config;
54
+ const { isFeatureAccmEnabled } = api.getEndpointSettings();
55
+ if (isFeatureAccmEnabled) {
56
+ return api.say(null, {
57
+ _cognigy: (0, utils_1.buildPayloadAccm)("setSessionParams", config, nodeId)
58
+ });
59
+ }
53
60
  let compiledParams = sessionParams || {};
54
61
  (0, paramUtils_1.compileParams)(config, compiledParams);
55
62
  // output the activity to the voice gateway