@cognigy/rest-api-client 0.13.1 → 0.14.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 (110) hide show
  1. package/.eslintConfig.json +117 -0
  2. package/.eslintrc.json +2 -2
  3. package/CHANGELOG.md +12 -1
  4. package/build/apigroups/ResourcesAPIGroup_2_0.js +25 -4
  5. package/build/shared/charts/descriptors/allFields.js +8 -0
  6. package/build/shared/charts/descriptors/apps/getAppSessionPin.js +9 -9
  7. package/build/shared/charts/descriptors/apps/initAppSession.js +36 -53
  8. package/build/shared/charts/descriptors/apps/setAdaptiveCardAppState.js +5 -18
  9. package/build/shared/charts/descriptors/apps/setAppState.js +6 -6
  10. package/build/shared/charts/descriptors/apps/setHtmlAppState.js +85 -15
  11. package/build/shared/charts/descriptors/apps/utils/buildAppUrl.js +12 -0
  12. package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/azureOpenAIProviderConnection.js +14 -0
  13. package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/index.js +19 -0
  14. package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/openAIProviderConnection.js +11 -0
  15. package/build/shared/charts/descriptors/index.js +9 -6
  16. package/build/shared/charts/descriptors/logic/switch/switch.js +3 -2
  17. package/build/shared/charts/descriptors/message/question/optionalQuestion.js +30 -7
  18. package/build/shared/charts/descriptors/message/question/question.js +200 -28
  19. package/build/shared/charts/descriptors/message/question/utils/evaluateQuestionAnswer.js +6 -0
  20. package/build/shared/charts/descriptors/message/say.js +33 -2
  21. package/build/shared/charts/descriptors/service/completeText.js +316 -0
  22. package/build/shared/charts/descriptors/service/handoverV2.js +48 -2
  23. package/build/shared/charts/descriptors/service/index.js +3 -1
  24. package/build/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +62 -26
  25. package/build/shared/charts/descriptors/voice/mappers/transfer.mapper.js +93 -32
  26. package/build/shared/charts/descriptors/voice/nodes/bargeIn.js +53 -0
  27. package/build/shared/charts/descriptors/voice/nodes/dtmf.js +5 -3
  28. package/build/shared/charts/descriptors/voice/nodes/play.js +14 -5
  29. package/build/shared/charts/descriptors/voice/nodes/sessionSpeechParameters.js +90 -8
  30. package/build/shared/charts/descriptors/voice/nodes/transfer.js +6 -2
  31. package/build/shared/charts/descriptors/voice/utils/helper.js +11 -1
  32. package/build/shared/charts/descriptors/voicegateway/nodes/agentAssist.js +2 -2
  33. package/build/shared/charts/descriptors/voicegateway/nodes/handover.js +5 -1
  34. package/build/shared/charts/descriptors/voicegateway2/nodes/play.js +20 -5
  35. package/build/shared/charts/descriptors/voicegateway2/nodes/refer.js +3 -3
  36. package/build/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +150 -33
  37. package/build/shared/charts/descriptors/voicegateway2/nodes/transfer.js +95 -7
  38. package/build/shared/charts/descriptors/voicegateway2/utils/helper.js +18 -11
  39. package/build/shared/charts/descriptors/voicegateway2/utils/strip-nulls.js +4 -1
  40. package/build/shared/charts/helpers/generativeAI/getRephraseWithAIFields.js +100 -0
  41. package/build/shared/charts/helpers/generativeAI/rephraseSentenceWithAi.js +44 -0
  42. package/build/shared/constants.js +2 -1
  43. package/build/shared/errors/BadGatewayError.js +2 -1
  44. package/build/shared/errors/BadRequestError.js +2 -1
  45. package/build/shared/errors/ForbiddenError.js +2 -1
  46. package/build/shared/errors/GatewayTimeoutError.js +2 -1
  47. package/build/shared/errors/MethodNotAllowedError.js +2 -1
  48. package/build/shared/errors/NetworkError.js +2 -1
  49. package/build/shared/errors/PayloadTooLargeError.js +2 -1
  50. package/build/shared/errors/PaymentRequiredError.js +2 -1
  51. package/build/shared/errors/ServiceUnavailableError.js +2 -1
  52. package/build/shared/errors/UnauthorizedError.js +2 -1
  53. package/build/shared/errors/baseError.js +27 -4
  54. package/build/shared/errors/conflict.js +2 -1
  55. package/build/shared/errors/databaseConnectError.js +2 -2
  56. package/build/shared/errors/databaseQueryError.js +2 -2
  57. package/build/shared/errors/databaseRead.js +2 -2
  58. package/build/shared/errors/databaseWrite.js +2 -2
  59. package/build/shared/errors/exportError.js +2 -2
  60. package/build/shared/errors/fileRead.js +2 -2
  61. package/build/shared/errors/fileWrite.js +2 -2
  62. package/build/shared/errors/importError.js +1 -1
  63. package/build/shared/errors/inputOutputError.js +2 -2
  64. package/build/shared/errors/internalServerError.js +2 -1
  65. package/build/shared/errors/invalidArgument.js +2 -2
  66. package/build/shared/errors/missingArgument.js +2 -2
  67. package/build/shared/errors/notImplementedError.js +2 -1
  68. package/build/shared/errors/process.js +2 -2
  69. package/build/shared/errors/resourceNotFound.js +5 -1
  70. package/build/shared/errors/smtpConnectError.js +2 -2
  71. package/build/shared/errors/timeoutError.js +2 -2
  72. package/build/shared/interfaces/ai.js +16 -0
  73. package/build/shared/interfaces/analytics/IAnalyticsDataGoals.js +3 -0
  74. package/build/shared/interfaces/endpointInterface.js +1 -0
  75. package/build/shared/interfaces/filemanager/IRuntimeFile.js +30 -0
  76. package/build/shared/interfaces/filemanager/index.js +1 -0
  77. package/build/shared/interfaces/handover.js +40 -3
  78. package/build/shared/interfaces/messageAPI/endpoints.js +2 -0
  79. package/build/shared/interfaces/messageAPI/handover.js +6 -0
  80. package/build/shared/interfaces/resources/IAgentAssistConfig.js +56 -0
  81. package/build/shared/interfaces/resources/IConnectionSchema.js +2 -1
  82. package/build/shared/interfaces/resources/IExtension.js +2 -1
  83. package/build/shared/interfaces/resources/IFlow.js +2 -1
  84. package/build/shared/interfaces/resources/ILexicon.js +15 -2
  85. package/build/shared/interfaces/resources/ILocale.js +25 -3
  86. package/build/shared/interfaces/resources/INodeDescriptorSet.js +2 -1
  87. package/build/shared/interfaces/resources/TResourceType.js +3 -0
  88. package/build/shared/interfaces/resources/intent/IIntent.js +5 -2
  89. package/build/shared/interfaces/resources/intent/IIntentRelation.js +3 -1
  90. package/build/shared/interfaces/resources/settings/IAgentSettings.js +9 -4
  91. package/build/shared/interfaces/resources/settings/IGenerativeAISettings.js +136 -0
  92. package/build/shared/interfaces/resources/settings/ISharedSettings.js +1 -1
  93. package/build/shared/interfaces/resources/settings/index.js +7 -1
  94. package/build/shared/interfaces/resources/yesNoIntent/IYesNoItem.js +5 -5
  95. package/build/shared/interfaces/restAPI/administration/liveAgent/v2.0/ICognigyLiveAgentMiddleware_2_0.js +3 -0
  96. package/build/shared/interfaces/restAPI/resources/agentAssist/v2.0/IAgentAssistConfig_2_0.js +3 -0
  97. package/build/shared/interfaces/restAPI/resources/agentAssist/v2.0/ICreateAgentAssistConfigRest_2_0.js +3 -0
  98. package/build/shared/interfaces/restAPI/resources/agentAssist/v2.0/IDeleteAgentAssistConfigRest_2_0.js +3 -0
  99. package/build/shared/interfaces/restAPI/resources/agentAssist/v2.0/IIndexAgentAssistConfigsRest_2_0.js +3 -0
  100. package/build/shared/interfaces/restAPI/resources/agentAssist/v2.0/IReadAgentAssistConfigRest_2_0.js +3 -0
  101. package/build/shared/interfaces/restAPI/resources/agentAssist/v2.0/IUpdateAgentAssistConfigRest_2_0.js +3 -0
  102. package/build/shared/interfaces/restAPI/resources/agentAssist/v2.0/index.js +3 -0
  103. package/build/shared/interfaces/restAPI/resources/flow/v2.0/sentence/IGenerateSentencesRest_2_0.js +3 -0
  104. package/build/shared/interfaces/restAPI/resources/locales/v2.0/yesNoIntents/ITrainYesNoIntentsProjectRest_2_0.js +3 -0
  105. package/build/shared/interfaces/restAPI/resources/locales/v2.0/yesNoIntents/IYesNoIntents_2_0.js +4 -4
  106. package/build/shared/interfaces/security/IACL.js +1 -1
  107. package/build/shared/interfaces/security/IPermission.js +2 -0
  108. package/build/shared/interfaces/security/IRole.js +4 -0
  109. package/package.json +2 -2
  110. package/types/index.d.ts +925 -388
@@ -0,0 +1,316 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COMPLETE_TEXT = void 0;
4
+ /* Custom modules */
5
+ const createNodeDescriptor_1 = require("../../createNodeDescriptor");
6
+ exports.COMPLETE_TEXT = (0, createNodeDescriptor_1.createNodeDescriptor)({
7
+ type: "completeText",
8
+ defaultLabel: {
9
+ default: "Complete Text",
10
+ },
11
+ summary: {
12
+ default: "Generates a new text based on a given prompt",
13
+ deDE: "Erzeugt einen neuen Text auf Grundlage eines vorhandenen Kontext"
14
+ },
15
+ fields: [
16
+ {
17
+ key: "prompt",
18
+ label: {
19
+ default: "Prompt",
20
+ deDE: "Kontext"
21
+ },
22
+ type: "cognigyText",
23
+ description: {
24
+ default: "The prompt to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.",
25
+ deDE: "Die Eingabeaufforderung, für die Vervollständigungen generiert werden sollen, codiert als Zeichenfolge, Array von Zeichenfolgen, Array von Token oder Array von Token-Arrays."
26
+ },
27
+ params: {
28
+ required: true,
29
+ multiline: true
30
+ },
31
+ defaultValue: ""
32
+ },
33
+ {
34
+ key: "samplingMethod",
35
+ label: "Sampling Method",
36
+ type: "select",
37
+ defaultValue: "temperature",
38
+ params: {
39
+ options: [
40
+ {
41
+ label: "Temperature",
42
+ value: "temperature"
43
+ },
44
+ {
45
+ label: "Top Percentage",
46
+ value: "topP"
47
+ }
48
+ ]
49
+ }
50
+ },
51
+ {
52
+ key: "temperature",
53
+ label: {
54
+ default: "Temperature",
55
+ deDE: "Temperatur"
56
+ },
57
+ type: "slider",
58
+ description: {
59
+ default: "What sampling temperature to use. Higher values means the model will take more risks",
60
+ deDE: "Welche Probenahmetemperatur soll verwendet werden. Höhere Werte bedeuten, dass das Modell mehr Risiken eingeht"
61
+ },
62
+ defaultValue: 0.7,
63
+ params: {
64
+ min: 0,
65
+ max: 1,
66
+ step: 0.1
67
+ },
68
+ condition: {
69
+ key: "samplingMethod",
70
+ value: "temperature",
71
+ }
72
+ },
73
+ {
74
+ key: "topP",
75
+ label: {
76
+ default: "Top Percentage",
77
+ deDE: "Maximaler Prozentsatz"
78
+ },
79
+ type: "slider",
80
+ description: {
81
+ default: "An alternative to sampling with temperature, called nucleus sampling",
82
+ deDE: "Eine Alternative zum Sampling mit Temperatur, genannt Nucleus Sampling"
83
+ },
84
+ defaultValue: 1,
85
+ params: {
86
+ min: 0,
87
+ max: 1,
88
+ step: 0.1
89
+ },
90
+ condition: {
91
+ key: "samplingMethod",
92
+ value: "topP",
93
+ }
94
+ },
95
+ {
96
+ key: "maxTokens",
97
+ label: {
98
+ default: "Maximal Tokens",
99
+ deDE: "Maximale Zeichen"
100
+ },
101
+ type: "slider",
102
+ description: {
103
+ default: "The maximum number of tokens to generate in the completion",
104
+ deDE: "Die maximale Anzahl von Token, die beim Abschluss generiert werden sollen"
105
+ },
106
+ defaultValue: 100,
107
+ params: {
108
+ min: 1,
109
+ max: 4000,
110
+ step: 1
111
+ }
112
+ },
113
+ {
114
+ key: "frequencyPenalty",
115
+ label: {
116
+ default: "Frequency Penalty",
117
+ deDE: "Frequenzregelung"
118
+ },
119
+ type: "slider",
120
+ description: {
121
+ default: "Number between -2.0 and 2.0",
122
+ deDE: "Zahl zwischen -2,0 und 2,0"
123
+ },
124
+ defaultValue: 0,
125
+ params: {
126
+ min: -2,
127
+ max: 2,
128
+ step: 0.1
129
+ }
130
+ },
131
+ {
132
+ key: "presencePenalty",
133
+ label: {
134
+ default: "Presence Penalty",
135
+ deDE: "Gegenwartsregelung"
136
+ },
137
+ type: "slider",
138
+ description: {
139
+ default: "Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics",
140
+ deDE: "Zahl zwischen -2,0 und 2,0. Positive Werte bestrafen neue Token basierend darauf, ob sie bisher im Text erschienen sind, und erhöhen die Wahrscheinlichkeit, dass das Modell über neue Themen spricht"
141
+ },
142
+ defaultValue: 0,
143
+ params: {
144
+ min: -2,
145
+ max: 2,
146
+ step: 0.1
147
+ }
148
+ },
149
+ {
150
+ key: "useStop",
151
+ label: {
152
+ default: "Use Stops",
153
+ deDE: "Stopps verwenden"
154
+ },
155
+ type: "toggle",
156
+ description: {
157
+ default: "Whether to use a list of stop words to let the Generative AI know where the sentence stops",
158
+ deDE: "Ob eine Liste von Stoppwörtern verwendet werden soll, um der Generativen AI mitzuteilen, wo der Satz endet"
159
+ },
160
+ defaultValue: false
161
+ },
162
+ {
163
+ key: "stop",
164
+ label: {
165
+ default: "Stops",
166
+ deDE: "Stopps"
167
+ },
168
+ type: "textArray",
169
+ description: {
170
+ default: "Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence",
171
+ deDE: "Bis zu 4 Sequenzen, bei denen die API aufhört, weitere Token zu generieren. Der zurückgegebene Text enthält nicht die Stoppsequenz"
172
+ },
173
+ condition: {
174
+ key: "useStop",
175
+ value: true
176
+ }
177
+ },
178
+ {
179
+ key: "timeout",
180
+ label: {
181
+ default: "Timeout",
182
+ },
183
+ defaultValue: 5000,
184
+ type: "number",
185
+ description: {
186
+ default: "The maximum amount of milliseconds to wait for a response from the Generative AI Provider",
187
+ },
188
+ },
189
+ {
190
+ key: "storeLocation",
191
+ type: "select",
192
+ label: {
193
+ default: "Where to store the result",
194
+ deDE: "Wo das Ergebnis gespeichert werden soll"
195
+ },
196
+ defaultValue: "input",
197
+ params: {
198
+ options: [
199
+ {
200
+ label: "Input",
201
+ value: "input"
202
+ },
203
+ {
204
+ label: "Context",
205
+ value: "context"
206
+ }
207
+ ],
208
+ required: true
209
+ },
210
+ },
211
+ {
212
+ key: "inputKey",
213
+ type: "cognigyText",
214
+ label: {
215
+ default: "Input Key to store Result",
216
+ deDE: "Input Key zum Speichern des Ergebnisses"
217
+ },
218
+ defaultValue: "generativeAi",
219
+ condition: {
220
+ key: "storeLocation",
221
+ value: "input",
222
+ }
223
+ },
224
+ {
225
+ key: "contextKey",
226
+ type: "cognigyText",
227
+ label: {
228
+ default: "Context Key to store Result",
229
+ deDE: "Context Key zum Speichern des Ergebnisses"
230
+ },
231
+ defaultValue: "generativeAi",
232
+ condition: {
233
+ key: "storeLocation",
234
+ value: "context",
235
+ }
236
+ },
237
+ ],
238
+ sections: [
239
+ {
240
+ key: "advanced",
241
+ label: {
242
+ default: "Advanced",
243
+ deDE: "Erweitert"
244
+ },
245
+ defaultCollapsed: true,
246
+ fields: [
247
+ "model",
248
+ "samplingMethod",
249
+ "temperature",
250
+ "topP",
251
+ "maxTokens",
252
+ "presencePenalty",
253
+ "frequencyPenalty",
254
+ "useStop",
255
+ "stop",
256
+ "timeout",
257
+ ]
258
+ },
259
+ {
260
+ key: "storage",
261
+ label: {
262
+ default: "Storage Option",
263
+ deDE: "Speicheroption"
264
+ },
265
+ defaultCollapsed: true,
266
+ fields: [
267
+ "storeLocation",
268
+ "inputKey",
269
+ "contextKey",
270
+ ]
271
+ }
272
+ ],
273
+ form: [
274
+ { type: "field", key: "prompt" },
275
+ { type: "section", key: "advanced" },
276
+ { type: "section", key: "storage" },
277
+ ],
278
+ appearance: {},
279
+ tags: ["service"],
280
+ function: async ({ cognigy, config }) => {
281
+ const { api } = cognigy;
282
+ const { prompt, temperature, maxTokens, topP, presencePenalty, frequencyPenalty, useStop, stop, storeLocation, contextKey, inputKey, timeout, } = config;
283
+ try {
284
+ const data = {
285
+ prompt,
286
+ temperature,
287
+ maxTokens,
288
+ topP,
289
+ presencePenalty,
290
+ frequencyPenalty,
291
+ timeoutInMs: timeout,
292
+ };
293
+ if (useStop) {
294
+ data["stop"] = stop;
295
+ }
296
+ const response = await api.runGenerativeAIPrompt(data);
297
+ if (storeLocation === "context") {
298
+ api.addToContext(contextKey, response, "simple");
299
+ }
300
+ else {
301
+ // @ts-ignore
302
+ api.addToInput(inputKey, response);
303
+ }
304
+ }
305
+ catch (error) {
306
+ if (storeLocation === "context") {
307
+ api.addToContext(contextKey, { error: error }, "simple");
308
+ }
309
+ else {
310
+ // @ts-ignore
311
+ api.addToInput(inputKey, { error: error });
312
+ }
313
+ }
314
+ }
315
+ });
316
+ //# sourceMappingURL=completeText.js.map
@@ -57,6 +57,13 @@ exports.HANDOVER_V2 = (0, createNodeDescriptor_1.createNodeDescriptor)({
57
57
  ],
58
58
  },
59
59
  },
60
+ {
61
+ key: "additionalCategoryIds",
62
+ type: "cognigyTextArray",
63
+ label: "Additional Category Ids",
64
+ description: "Additional Category Ids to be passed to Ring Central Engage handover provider",
65
+ defaultValue: []
66
+ },
60
67
  {
61
68
  key: "sendResolveEvent",
62
69
  type: "toggle",
@@ -72,7 +79,7 @@ exports.HANDOVER_V2 = (0, createNodeDescriptor_1.createNodeDescriptor)({
72
79
  {
73
80
  key: "agentAssistInitMessage",
74
81
  type: "cognigyText",
75
- label: "Initial Whisper Assist Trigger",
82
+ label: "Initial Agent Assist Trigger",
76
83
  description: "If an Assist Flow is configured, this trigger message is sent to it as an input upon Live Agent handover"
77
84
  },
78
85
  {
@@ -109,6 +116,25 @@ exports.HANDOVER_V2 = (0, createNodeDescriptor_1.createNodeDescriptor)({
109
116
  description: "The details that should be displayed to the Live Chat Agent.",
110
117
  defaultValue: "[]",
111
118
  },
119
+ {
120
+ key: "eightByEightChannelId",
121
+ type: "cognigyText",
122
+ label: "8x8 Channel Id",
123
+ description: "The 8x8 Channel Id that should be used.",
124
+ },
125
+ {
126
+ key: "eightByEightQueueId",
127
+ type: "cognigyText",
128
+ label: "8x8 Queue Id",
129
+ description: "The 8x8 Queue Id that should be used.",
130
+ },
131
+ {
132
+ key: "eightByEightJSONProps",
133
+ type: "json",
134
+ label: "8x8 JSON properties",
135
+ description: "Extend 8x8 properties with custom JSON.",
136
+ defaultValue: [],
137
+ },
112
138
  ],
113
139
  sections: [
114
140
  {
@@ -156,6 +182,24 @@ exports.HANDOVER_V2 = (0, createNodeDescriptor_1.createNodeDescriptor)({
156
182
  "salesforcePrechatEntities",
157
183
  "salesforcePrechatDetails"
158
184
  ]
185
+ },
186
+ {
187
+ key: "eightByEightSettings",
188
+ label: "8x8 Settings",
189
+ defaultCollapsed: true,
190
+ fields: [
191
+ "eightByEightChannelId",
192
+ "eightByEightQueueId",
193
+ "eightByEightJSONProps"
194
+ ]
195
+ },
196
+ {
197
+ key: "ringCentralEngageSettings",
198
+ label: "Ring Central Engage Settings",
199
+ defaultCollapsed: true,
200
+ fields: [
201
+ "additionalCategoryIds",
202
+ ]
159
203
  }
160
204
  ],
161
205
  form: [
@@ -169,7 +213,9 @@ exports.HANDOVER_V2 = (0, createNodeDescriptor_1.createNodeDescriptor)({
169
213
  key: "liveAgentSettings"
170
214
  },
171
215
  { type: "section", key: "chatwootSettings" },
172
- { type: "section", key: "salesforceSettings" }
216
+ { type: "section", key: "salesforceSettings" },
217
+ { type: "section", key: "eightByEightSettings" },
218
+ { type: "section", key: "ringCentralEngageSettings" },
173
219
  ]
174
220
  .filter(element => !!element),
175
221
  tags: ["service", "livechat", "chat", "hand over"],
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ON_SCHEDULING_ERROR = exports.ON_SCHEDULED = exports.TRIGGER_FUNCTION = exports.HTTP_CONNECTION_OAUTH2 = exports.HTTP_CONNECTION_APIKEYXKEY = exports.HTTP_CONNECTION_APIKEYAUTHKEY = exports.HTTP_CONNECTION_BASIC = exports.HTTP_REQUEST = exports.CHECK_AGENT_AVAILABILITY = exports.HANDOVER_V2 = exports.HANDOVER = void 0;
3
+ exports.COMPLETE_TEXT = exports.ON_SCHEDULING_ERROR = exports.ON_SCHEDULED = exports.TRIGGER_FUNCTION = exports.HTTP_CONNECTION_OAUTH2 = exports.HTTP_CONNECTION_APIKEYXKEY = exports.HTTP_CONNECTION_APIKEYAUTHKEY = exports.HTTP_CONNECTION_BASIC = exports.HTTP_REQUEST = exports.CHECK_AGENT_AVAILABILITY = exports.HANDOVER_V2 = exports.HANDOVER = void 0;
4
4
  var handover_1 = require("./handover");
5
5
  Object.defineProperty(exports, "HANDOVER", { enumerable: true, get: function () { return handover_1.HANDOVER; } });
6
6
  var handoverV2_1 = require("./handoverV2");
@@ -21,4 +21,6 @@ var onScheduled_1 = require("./triggerFunction/onScheduled");
21
21
  Object.defineProperty(exports, "ON_SCHEDULED", { enumerable: true, get: function () { return onScheduled_1.ON_SCHEDULED; } });
22
22
  var onSchedulingError_1 = require("./triggerFunction/onSchedulingError");
23
23
  Object.defineProperty(exports, "ON_SCHEDULING_ERROR", { enumerable: true, get: function () { return onSchedulingError_1.ON_SCHEDULING_ERROR; } });
24
+ var completeText_1 = require("./completeText");
25
+ Object.defineProperty(exports, "COMPLETE_TEXT", { enumerable: true, get: function () { return completeText_1.COMPLETE_TEXT; } });
24
26
  //# sourceMappingURL=index.js.map
@@ -5,12 +5,13 @@ const strip_nulls_1 = require("../../voicegateway2/utils/strip-nulls");
5
5
  const helper_1 = require("../utils/helper");
6
6
  const constants_1 = require("../utils/constants");
7
7
  function voiceConfigParamsToVoiceSettings(config, api) {
8
+ var _a, _b, _c;
8
9
  let voiceSettings = {};
9
10
  if (config.bargeInOnSpeech || config.bargeInOnDtmf) {
10
11
  voiceSettings.bargeIn = {
11
12
  bargeInEnable: false,
12
- bargeInOnDtmf: config.bargeInOnDtmf ? true : false,
13
- bargeInOnSpeech: config.bargeInOnSpeech ? true : false,
13
+ bargeInOnDtmf: (_a = config.bargeInOnDtmf) !== null && _a !== void 0 ? _a : false,
14
+ bargeInOnSpeech: (_b = config.bargeInOnSpeech) !== null && _b !== void 0 ? _b : false,
14
15
  bargeInMinimunWords: config.bargeInMinWordCount,
15
16
  };
16
17
  }
@@ -35,7 +36,10 @@ function voiceConfigParamsToVoiceSettings(config, api) {
35
36
  ttsVendor: config.ttsVendor,
36
37
  ttsLanguage: config.ttsLanguage,
37
38
  ttsVoice: config.ttsVoice,
39
+ azureServiceEndpoint: config.azureTtsDeploymentId
38
40
  };
41
+ if (config.ttsVendor === 'microsoft' && config.azureTtsDeploymentId)
42
+ voiceSettings.tts.azureServiceEndpoint = config.azureTtsDeploymentId;
39
43
  // userNoInput
40
44
  voiceSettings.userNoInput = {
41
45
  userNoInputMode: config.userNoInputMode,
@@ -44,17 +48,14 @@ function voiceConfigParamsToVoiceSettings(config, api) {
44
48
  userNoInputSpeech: config.userNoInputSpeech,
45
49
  userNoInputUrl: config.userNoInputUrl,
46
50
  };
47
- // dtmf
48
51
  voiceSettings.dtmf = {
49
52
  dtmfEnable: config.dtmfEnable,
50
53
  dtmfInterDigitTimeout: config.dtmfInterDigitTimeout,
51
54
  dtmfMaxDigits: config.dtmfMaxDigits,
52
55
  dtmfMinDigits: config.dtmfMinDigits,
53
- dtmfSubmitDigit: config.dtmfSubmitDigit,
56
+ dtmfSubmitDigit: (_c = config.dtmfSubmitDigit) === null || _c === void 0 ? void 0 : _c.trim(),
54
57
  };
55
58
  if (config === null || config === void 0 ? void 0 : config.dtmfEnable) {
56
- if (config.dtmfSubmitDigit)
57
- voiceSettings.dtmf.dtmfSubmitDigit = config.dtmfSubmitDigit.trim();
58
59
  if (voiceSettings.dtmf.dtmfSubmitDigit &&
59
60
  !(0, helper_1.isValidDTMF)(voiceSettings.dtmf.dtmfSubmitDigit)) {
60
61
  if (api)
@@ -87,6 +88,19 @@ function voiceConfigParamsToVoiceSettings(config, api) {
87
88
  delete voiceSettings.continuousAsr.asrDigit;
88
89
  }
89
90
  }
91
+ // Azure configurations
92
+ if ((config.sttVendor === "microsoft" && config.azureSttContextId) ||
93
+ (config.sttVendor === "microsoft" && config.azureTtsDeploymentId)) {
94
+ voiceSettings.azureConfig = {
95
+ azureSttContextId: config.azureSttContextId
96
+ ? config.azureSttContextId.trim()
97
+ : undefined,
98
+ azureEnableAudioLogging: config.azureEnableAudioLogging || undefined,
99
+ azureTtsDeploymentId: config.azureTtsDeploymentId
100
+ ? config.azureTtsDeploymentId.trim()
101
+ : undefined,
102
+ };
103
+ }
90
104
  return (0, strip_nulls_1.stripNulls)(voiceSettings);
91
105
  }
92
106
  exports.voiceConfigParamsToVoiceSettings = voiceConfigParamsToVoiceSettings;
@@ -115,7 +129,8 @@ exports.setSessionConfig = {
115
129
  }
116
130
  },
117
131
  handleVGInput(voiceSettings) {
118
- const { bargeIn, continuousAsr, stt, tts, userNoInput, dtmf, vad } = voiceSettings;
132
+ var _a;
133
+ const { bargeIn, continuousAsr, stt, tts, userNoInput, dtmf, vad, azureConfig, } = voiceSettings;
119
134
  const user = {};
120
135
  const synthesizer = {};
121
136
  const recognizer = {};
@@ -129,18 +144,21 @@ exports.setSessionConfig = {
129
144
  }
130
145
  recognizer.vendor = (stt === null || stt === void 0 ? void 0 : stt.sttVendor) ? stt.sttVendor : "default";
131
146
  recognizer.punctuation = stt === null || stt === void 0 ? void 0 : stt.sttDisablePunctuation;
132
- if (vad && vad.enable) {
133
- recognizer.vad = {
134
- enable: true,
135
- mode: vad.mode,
136
- voiceMs: vad.voiceMs,
137
- };
147
+ recognizer.azureSttEndpointId = azureConfig === null || azureConfig === void 0 ? void 0 : azureConfig.azureSttContextId;
148
+ recognizer.audioLogging = azureConfig === null || azureConfig === void 0 ? void 0 : azureConfig.azureEnableAudioLogging;
149
+ if (vad) {
150
+ recognizer.vad = { enable: vad.enable };
151
+ if (vad.enable) {
152
+ recognizer.vad.mode = vad.mode;
153
+ recognizer.vad.voiceMs = vad.voiceMs;
154
+ }
138
155
  }
139
156
  //verify if there are TTS Configs to set
140
157
  if (tts) {
141
158
  synthesizer.vendor = tts.ttsVendor;
142
159
  synthesizer.language = tts.ttsLanguage;
143
160
  synthesizer.voice = tts.ttsVoice;
161
+ synthesizer.azureServiceEndpoint = tts.azureServiceEndpoint ? tts.azureServiceEndpoint : "";
144
162
  }
145
163
  //verify if there are No User Input Configs to set
146
164
  if (userNoInput) {
@@ -155,17 +173,20 @@ exports.setSessionConfig = {
155
173
  ? userNoInput.userNoInputTimeout / 1000
156
174
  : 10;
157
175
  }
158
- //verify if there are Continuous ASR Configs to set
176
+ // verify if there are Continuous ASR Configs to set
159
177
  if (continuousAsr === null || continuousAsr === void 0 ? void 0 : continuousAsr.asrEnabled) {
160
178
  recognizer.asrDtmfTerminationDigit = continuousAsr.asrDigit;
161
179
  recognizer.asrTimeout = continuousAsr.asrTimeout
162
180
  ? continuousAsr.asrTimeout / 1000
163
181
  : undefined;
164
182
  }
165
- //verify if there are Barge In Configs to set
183
+ // verify if there are Barge In Configs to set
166
184
  if (bargeIn) {
167
185
  barge.enable = bargeIn.bargeInEnable;
168
- barge.minBargeinWordCount = bargeIn.bargeInMinimunWords;
186
+ /* Barge in minimum words. min: 1, max: 5, default: 1 */
187
+ bargeIn.bargeInMinimunWords >= 1 && bargeIn.bargeInMinimunWords <= 5
188
+ ? (barge.minBargeinWordCount = bargeIn.bargeInMinimunWords)
189
+ : (barge.minBargeinWordCount = 1);
169
190
  barge.input = [];
170
191
  barge.actionHook = "voice";
171
192
  barge.dtmfBargein = bargeIn.bargeInOnDtmf;
@@ -178,32 +199,36 @@ exports.setSessionConfig = {
178
199
  barge.input.push("speech");
179
200
  }
180
201
  }
181
- //verify if there are DTMF Configs to set
202
+ // verify if there are DTMF Configs to set
182
203
  if (dtmf) {
183
204
  dtmfParam = dtmf.dtmfEnable;
184
205
  if (dtmf.dtmfEnable) {
206
+ barge.enable = (_a = barge.enable) !== null && _a !== void 0 ? _a : false;
185
207
  barge.interDigitTimeout =
186
208
  dtmf.dtmfInterDigitTimeout && dtmf.dtmfInterDigitTimeout >= 0
187
209
  ? dtmf.dtmfInterDigitTimeout === 0
188
210
  ? 0
189
211
  : dtmf.dtmfInterDigitTimeout / 1000
190
212
  : undefined;
213
+ /* Max digits. min: 1, max: - default: 1 */
191
214
  barge.maxDigits =
192
- dtmf.dtmfMaxDigits && dtmf.dtmfMaxDigits >= 1
193
- ? dtmf.dtmfMaxDigits
194
- : undefined;
215
+ dtmf.dtmfMaxDigits >= 1 ? (barge.maxDigits = dtmf.dtmfMaxDigits) : 1;
195
216
  barge.minDigits = dtmf.dtmfMinDigits || 1;
196
217
  barge.finishOnKey = dtmf.dtmfSubmitDigit;
197
218
  }
198
219
  }
199
- //Check if there are configs for synthesizer, recognizer and bargeIn
220
+ // Check if there are configs for synthesizer, recognizer and bargeIn
200
221
  const voiceConfig = {
201
- synthesizer: synthesizer ? synthesizer : undefined,
202
- recognizer: recognizer ? recognizer : undefined,
203
- bargeIn: barge ? barge : undefined,
222
+ synthesizer: synthesizer || undefined,
223
+ recognizer: recognizer || undefined,
224
+ bargeIn: barge || undefined,
204
225
  };
205
226
  (0, strip_nulls_1.stripNulls)(voiceConfig);
206
- //Check if there are configs for No User Input and DTMF
227
+ if (voiceConfig.synthesizer && !voiceConfig.synthesizer.azureServiceEndpoint)
228
+ voiceConfig.synthesizer.azureServiceEndpoint = "";
229
+ if (voiceConfig.recognizer && !voiceConfig.recognizer.azureSttEndpointId)
230
+ voiceConfig.recognizer.azureSttEndpointId = "";
231
+ // Check if there are configs for No User Input and DTMF
207
232
  const cognigyConfig = {
208
233
  user: user ? user : undefined,
209
234
  dtmf: dtmfParam,
@@ -225,7 +250,7 @@ exports.setSessionConfig = {
225
250
  return payload;
226
251
  },
227
252
  handleAudioCodesInput(voiceSettings) {
228
- const { bargeIn, continuousAsr, stt, tts, userNoInput, dtmf } = voiceSettings;
253
+ const { bargeIn, continuousAsr, stt, tts, userNoInput, dtmf, azureConfig } = voiceSettings;
229
254
  const sessionParams = {};
230
255
  if (stt) {
231
256
  sessionParams.sttLanguage = stt.sttLanguage;
@@ -241,6 +266,10 @@ exports.setSessionConfig = {
241
266
  if (tts) {
242
267
  sessionParams.ttsLanguage = tts.ttsLanguage;
243
268
  sessionParams.voiceName = tts.ttsVoice;
269
+ if (tts.azureServiceEndpoint) {
270
+ sessionParams.ttsDeploymentId = tts.azureServiceEndpoint;
271
+ }
272
+ ;
244
273
  }
245
274
  if (dtmf) {
246
275
  sessionParams.sendDTMF = dtmf.dtmfEnable;
@@ -278,6 +307,13 @@ exports.setSessionConfig = {
278
307
  sessionParams.userNoInputRetries > 0)
279
308
  sessionParams.userNoInputUrl = userNoInput.userNoInputUrl;
280
309
  }
310
+ if (azureConfig === null || azureConfig === void 0 ? void 0 : azureConfig.azureSttContextId) {
311
+ sessionParams.sttContextId = azureConfig.azureSttContextId;
312
+ if (azureConfig.azureEnableAudioLogging) {
313
+ sessionParams.azureEnableAudioLogging =
314
+ azureConfig.azureEnableAudioLogging;
315
+ }
316
+ }
281
317
  const activities = {
282
318
  type: "event",
283
319
  name: "config",