@botonic/plugin-flow-builder 0.56.1 → 0.57.0-alpha.1
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/lib/cjs/api.d.ts +2 -2
- package/lib/cjs/api.js +17 -17
- package/lib/cjs/api.js.map +1 -1
- package/lib/cjs/bot-context-manager.d.ts +17 -0
- package/lib/cjs/bot-context-manager.js +93 -0
- package/lib/cjs/bot-context-manager.js.map +1 -0
- package/lib/cjs/constants.d.ts +2 -1
- package/lib/cjs/constants.js +3 -2
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/content-fields/contact-reasons-conditional-matcher.d.ts +4 -0
- package/lib/cjs/content-fields/contact-reasons-conditional-matcher.js +12 -0
- package/lib/cjs/content-fields/contact-reasons-conditional-matcher.js.map +1 -0
- package/lib/cjs/content-fields/flow-contact-reasons-conditional.d.ts +14 -0
- package/lib/cjs/content-fields/flow-contact-reasons-conditional.js +65 -0
- package/lib/cjs/content-fields/flow-contact-reasons-conditional.js.map +1 -0
- package/lib/cjs/content-fields/flow-handoff.d.ts +7 -1
- package/lib/cjs/content-fields/flow-handoff.js +39 -3
- package/lib/cjs/content-fields/flow-handoff.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/contact-reasons-conditional.d.ts +16 -0
- package/lib/cjs/content-fields/hubtype-fields/contact-reasons-conditional.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/contact-reasons-conditional.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/handoff.d.ts +11 -1
- package/lib/cjs/content-fields/hubtype-fields/handoff.js +7 -0
- package/lib/cjs/content-fields/hubtype-fields/handoff.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +2 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.js +1 -0
- package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +2 -1
- package/lib/cjs/content-fields/index.d.ts +3 -2
- package/lib/cjs/content-fields/index.js +3 -1
- package/lib/cjs/content-fields/index.js.map +1 -1
- package/lib/cjs/flow-factory.js +2 -0
- package/lib/cjs/flow-factory.js.map +1 -1
- package/lib/cjs/index.d.ts +5 -9
- package/lib/cjs/index.js +16 -67
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types.d.ts +2 -2
- package/lib/cjs/types.js.map +1 -1
- package/lib/esm/api.d.ts +2 -2
- package/lib/esm/api.js +17 -17
- package/lib/esm/api.js.map +1 -1
- package/lib/esm/bot-context-manager.d.ts +17 -0
- package/lib/esm/bot-context-manager.js +93 -0
- package/lib/esm/bot-context-manager.js.map +1 -0
- package/lib/esm/constants.d.ts +2 -1
- package/lib/esm/constants.js +3 -2
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/content-fields/contact-reasons-conditional-matcher.d.ts +4 -0
- package/lib/esm/content-fields/contact-reasons-conditional-matcher.js +12 -0
- package/lib/esm/content-fields/contact-reasons-conditional-matcher.js.map +1 -0
- package/lib/esm/content-fields/flow-contact-reasons-conditional.d.ts +14 -0
- package/lib/esm/content-fields/flow-contact-reasons-conditional.js +65 -0
- package/lib/esm/content-fields/flow-contact-reasons-conditional.js.map +1 -0
- package/lib/esm/content-fields/flow-handoff.d.ts +7 -1
- package/lib/esm/content-fields/flow-handoff.js +39 -3
- package/lib/esm/content-fields/flow-handoff.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/contact-reasons-conditional.d.ts +16 -0
- package/lib/esm/content-fields/hubtype-fields/contact-reasons-conditional.js +3 -0
- package/lib/esm/content-fields/hubtype-fields/contact-reasons-conditional.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/handoff.d.ts +11 -1
- package/lib/esm/content-fields/hubtype-fields/handoff.js +7 -0
- package/lib/esm/content-fields/hubtype-fields/handoff.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +2 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.js +1 -0
- package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +2 -1
- package/lib/esm/content-fields/index.d.ts +3 -2
- package/lib/esm/content-fields/index.js +3 -1
- package/lib/esm/content-fields/index.js.map +1 -1
- package/lib/esm/flow-factory.js +2 -0
- package/lib/esm/flow-factory.js.map +1 -1
- package/lib/esm/index.d.ts +5 -9
- package/lib/esm/index.js +16 -67
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types.d.ts +2 -2
- package/lib/esm/types.js.map +1 -1
- package/package.json +2 -2
- package/src/api.ts +19 -19
- package/src/bot-context-manager.ts +153 -0
- package/src/constants.ts +2 -1
- package/src/content-fields/contact-reasons-conditional-matcher.ts +24 -0
- package/src/content-fields/flow-contact-reasons-conditional.tsx +90 -0
- package/src/content-fields/flow-handoff.tsx +54 -7
- package/src/content-fields/hubtype-fields/contact-reasons-conditional.ts +18 -0
- package/src/content-fields/hubtype-fields/handoff.ts +17 -1
- package/src/content-fields/hubtype-fields/node-types.ts +1 -0
- package/src/content-fields/hubtype-fields/nodes.ts +2 -0
- package/src/content-fields/index.ts +3 -0
- package/src/flow-factory.ts +7 -0
- package/src/index.ts +26 -117
- package/src/types.ts +1 -2
package/lib/cjs/api.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BotContext } from '@botonic/core';
|
|
2
2
|
import { type HtBotActionNode, type HtCaptureUserInputNode, type HtFlowBuilderData, type HtFlowWebview, type HtKeywordNode, type HtNodeComponent, type HtNodeLink, type HtNodeWithContent, type HtRatingButton, type HtRatingNode, type HtSmartIntentNode, type HtWhatsappRequestContactInfoNode } from './content-fields/hubtype-fields';
|
|
3
3
|
import { type FlowBuilderApiOptions } from './types';
|
|
4
4
|
export declare class FlowBuilderApi {
|
|
5
5
|
url: string;
|
|
6
6
|
flowUrl: string;
|
|
7
7
|
flow: HtFlowBuilderData;
|
|
8
|
-
|
|
8
|
+
botContext: BotContext;
|
|
9
9
|
private constructor();
|
|
10
10
|
static create(options: FlowBuilderApiOptions): Promise<FlowBuilderApi>;
|
|
11
11
|
private getFlow;
|
package/lib/cjs/api.js
CHANGED
|
@@ -12,12 +12,12 @@ class FlowBuilderApi {
|
|
|
12
12
|
static async create(options) {
|
|
13
13
|
const newApi = new FlowBuilderApi();
|
|
14
14
|
newApi.url = options.url;
|
|
15
|
-
newApi.
|
|
15
|
+
newApi.botContext = options.botContext;
|
|
16
16
|
// TODO: Refactor later to combine logic from `FlowBuilderApi.create`, `resolveFlowUrl` and `getAccessToken` to be in one place
|
|
17
17
|
if (process.env.NODE_ENV === types_1.ProcessEnvNodeEnvs.DEVELOPMENT) {
|
|
18
18
|
await newApi.updateSessionWithUserInfo(options.accessToken);
|
|
19
19
|
}
|
|
20
|
-
const updatedRequest = newApi.
|
|
20
|
+
const updatedRequest = newApi.botContext;
|
|
21
21
|
newApi.flowUrl = options.flowUrl.replace('{bot_id}', updatedRequest.session.bot.id);
|
|
22
22
|
newApi.flow = options.flow ?? (await newApi.getFlow(options.accessToken));
|
|
23
23
|
return newApi;
|
|
@@ -33,8 +33,8 @@ class FlowBuilderApi {
|
|
|
33
33
|
const response = await axios_1.default.get(url, {
|
|
34
34
|
headers: { Authorization: `Bearer ${token}` },
|
|
35
35
|
});
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
36
|
+
this.botContext.session.organization_id = response.data.organization_id;
|
|
37
|
+
this.botContext.session.bot.id = response.data.bot_id;
|
|
38
38
|
}
|
|
39
39
|
getNodeByFlowId(id) {
|
|
40
40
|
const subFlow = this.flow.flows.find(subFlow => subFlow.id === id);
|
|
@@ -172,20 +172,20 @@ class FlowBuilderApi {
|
|
|
172
172
|
return !!this.getCaptureUserInputId();
|
|
173
173
|
}
|
|
174
174
|
getCaptureUserInputId() {
|
|
175
|
-
return this.
|
|
175
|
+
return this.botContext.session.capture_user_input?.node_id;
|
|
176
176
|
}
|
|
177
177
|
setCaptureUserInputId(id) {
|
|
178
|
-
if (this.
|
|
179
|
-
this.
|
|
178
|
+
if (this.botContext.session.capture_user_input) {
|
|
179
|
+
this.botContext.session.capture_user_input.node_id = id;
|
|
180
180
|
}
|
|
181
|
-
this.
|
|
181
|
+
this.botContext.session.capture_user_input = { node_id: id };
|
|
182
182
|
}
|
|
183
183
|
removeCaptureUserInputId() {
|
|
184
|
-
this.
|
|
184
|
+
this.botContext.session.capture_user_input = undefined;
|
|
185
185
|
}
|
|
186
186
|
setUserExtraDataVariable(key, value) {
|
|
187
|
-
if (this.
|
|
188
|
-
this.
|
|
187
|
+
if (this.botContext.session.user.extra_data) {
|
|
188
|
+
this.botContext.session.user.extra_data[key] = value;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
getCaptureUserInputNode() {
|
|
@@ -196,16 +196,16 @@ class FlowBuilderApi {
|
|
|
196
196
|
return this.getNodeById(captureUserInputId);
|
|
197
197
|
}
|
|
198
198
|
getSessionWhatsappRequestContactId() {
|
|
199
|
-
return this.
|
|
199
|
+
return this.botContext.session.whatsapp_request_contact?.id;
|
|
200
200
|
}
|
|
201
201
|
setWhatsappRequestContactId(id) {
|
|
202
|
-
if (this.
|
|
203
|
-
this.
|
|
202
|
+
if (this.botContext.session.whatsapp_request_contact) {
|
|
203
|
+
this.botContext.session.whatsapp_request_contact.id = id;
|
|
204
204
|
}
|
|
205
|
-
this.
|
|
205
|
+
this.botContext.session.whatsapp_request_contact = { id };
|
|
206
206
|
}
|
|
207
207
|
removeWhatsappRequestContactId() {
|
|
208
|
-
this.
|
|
208
|
+
this.botContext.session.whatsapp_request_contact = undefined;
|
|
209
209
|
}
|
|
210
210
|
getWhatsappRequestContactInfoNode() {
|
|
211
211
|
const whatsappRequestContactId = this.getSessionWhatsappRequestContactId();
|
|
@@ -217,7 +217,7 @@ class FlowBuilderApi {
|
|
|
217
217
|
getResolvedLocale() {
|
|
218
218
|
const flowLocales = this.flow.locales;
|
|
219
219
|
const defaultLocaleCode = this.flow.default_locale_code;
|
|
220
|
-
return new flow_locale_1.FlowLocale(this.
|
|
220
|
+
return new flow_locale_1.FlowLocale(this.botContext, flowLocales, defaultLocaleCode).resolve();
|
|
221
221
|
}
|
|
222
222
|
isPushFlowPayload(payload) {
|
|
223
223
|
return payload?.startsWith(constants_1.PUSH_FLOW_PAYLOAD) ?? false;
|
package/lib/cjs/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":";;;;AACA,0DAAyB;AAEzB,2CAKoB;AACpB,oEAiBwC;AACxC,mCAIgB;AAChB,qDAAgD;AAEhD,MAAa,cAAc;IAMzB,gBAAuB,CAAC;IAExB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAA8B;QAChD,MAAM,MAAM,GAAG,IAAI,cAAc,EAAE,CAAA;QAEnC,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACxB,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":";;;;AACA,0DAAyB;AAEzB,2CAKoB;AACpB,oEAiBwC;AACxC,mCAIgB;AAChB,qDAAgD;AAEhD,MAAa,cAAc;IAMzB,gBAAuB,CAAC;IAExB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAA8B;QAChD,MAAM,MAAM,GAAG,IAAI,cAAc,EAAE,CAAA;QAEnC,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACxB,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;QACtC,+HAA+H;QAC/H,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,0BAAkB,CAAC,WAAW,EAAE,CAAC;YAC5D,MAAM,MAAM,CAAC,yBAAyB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QAC7D,CAAC;QACD,MAAM,cAAc,GAAG,MAAM,CAAC,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AwB,EAAE,CAAC;YAC9B,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CACrB,wBAAwB,CACzB,CAAA;IACH,CAAC;IAED,iBAAiB;QACf,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAA;QACrC,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAA;QAEvD,OAAO,IAAI,wBAAU,CACnB,IAAI,CAAC,UAAU,EACf,WAAW,EACX,iBAAiB,CAClB,CAAC,OAAO,EAAE,CAAA;IACb,CAAC;IAED,iBAAiB,CAAC,OAAgB;QAChC,OAAO,OAAO,EAAE,UAAU,CAAC,6BAAiB,CAAC,IAAI,KAAK,CAAA;IACxD,CAAC;CACF;AA9SD,wCA8SC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type BotContext } from '@botonic/core';
|
|
2
|
+
import type { FlowBuilderApi } from './api';
|
|
3
|
+
import type { SmartIntentsInferenceConfig } from './user-input/smart-intent';
|
|
4
|
+
export declare class BotContextManager {
|
|
5
|
+
private readonly cmsApi;
|
|
6
|
+
private readonly smartIntentsConfig;
|
|
7
|
+
constructor(cmsApi: FlowBuilderApi, smartIntentsConfig: SmartIntentsInferenceConfig);
|
|
8
|
+
prepareInputForRoutes(botContext: BotContext): Promise<void>;
|
|
9
|
+
private updateFirstInteractionOnPushFlowPayload;
|
|
10
|
+
private resolvePayloadFromUserTextInput;
|
|
11
|
+
private resolveWhatsappContactRequestPayload;
|
|
12
|
+
private resolveOnCloseHandoffPayload;
|
|
13
|
+
private convertWhatsappAiAgentEmptyPayloads;
|
|
14
|
+
private removePayloadSourceSuffix;
|
|
15
|
+
private resolveBotActionPayload;
|
|
16
|
+
private removeSourceSuffix;
|
|
17
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BotContextManager = void 0;
|
|
4
|
+
const core_1 = require("@botonic/core");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const content_fields_1 = require("./content-fields");
|
|
7
|
+
const hubtype_fields_1 = require("./content-fields/hubtype-fields");
|
|
8
|
+
const user_input_1 = require("./user-input");
|
|
9
|
+
const input_1 = require("./utils/input");
|
|
10
|
+
class BotContextManager {
|
|
11
|
+
constructor(cmsApi, smartIntentsConfig) {
|
|
12
|
+
this.cmsApi = cmsApi;
|
|
13
|
+
this.smartIntentsConfig = smartIntentsConfig;
|
|
14
|
+
}
|
|
15
|
+
async prepareInputForRoutes(botContext) {
|
|
16
|
+
// When AI Agent is executed in Whatsapp, button payloads come as referral and must be converted to text being processed by the agent.
|
|
17
|
+
this.convertWhatsappAiAgentEmptyPayloads(botContext);
|
|
18
|
+
// If the payload is a push-flow payload, set first interaction to false
|
|
19
|
+
this.updateFirstInteractionOnPushFlowPayload(botContext);
|
|
20
|
+
this.resolveWhatsappContactRequestPayload(botContext);
|
|
21
|
+
this.resolveOnCloseHandoffPayload(botContext);
|
|
22
|
+
await this.resolvePayloadFromUserTextInput(botContext);
|
|
23
|
+
this.cmsApi.removeCaptureUserInputId();
|
|
24
|
+
this.removePayloadSourceSuffix(botContext);
|
|
25
|
+
this.resolveBotActionPayload(botContext);
|
|
26
|
+
}
|
|
27
|
+
async updateFirstInteractionOnPushFlowPayload(botContext) {
|
|
28
|
+
if (this.cmsApi.isPushFlowPayload(botContext.input.payload)) {
|
|
29
|
+
botContext.session.is_first_interaction = false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async resolvePayloadFromUserTextInput(botContext) {
|
|
33
|
+
const checkUserTextInput = (0, input_1.inputHasTextOrTranscript)(botContext.input) && !botContext.input.payload;
|
|
34
|
+
if (!checkUserTextInput) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const resolvedLocale = this.cmsApi.getResolvedLocale();
|
|
38
|
+
const nextPayload = await (0, user_input_1.getNextPayloadByUserInput)(this.cmsApi, resolvedLocale, botContext, this.smartIntentsConfig);
|
|
39
|
+
botContext.input.payload = nextPayload;
|
|
40
|
+
}
|
|
41
|
+
resolveWhatsappContactRequestPayload(botContext) {
|
|
42
|
+
if (botContext.input.type !== core_1.INPUT.CONTACT ||
|
|
43
|
+
botContext.input.origin !== core_1.WhatsappInputOrigin.ContactRequest) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const whatsappRequestContactInfoNode = this.cmsApi.getWhatsappRequestContactInfoNode();
|
|
47
|
+
if (whatsappRequestContactInfoNode) {
|
|
48
|
+
botContext.input.payload = this.cmsApi.getPayload(whatsappRequestContactInfoNode.content.button.target);
|
|
49
|
+
}
|
|
50
|
+
this.cmsApi.removeWhatsappRequestContactId();
|
|
51
|
+
}
|
|
52
|
+
resolveOnCloseHandoffPayload(botContext) {
|
|
53
|
+
if (botContext.input.payload?.startsWith(constants_1.ON_CLOSE_HANDOFF_PAYLOAD)) {
|
|
54
|
+
const handoffNodeId = botContext.input.payload.split(constants_1.SEPARATOR)[1];
|
|
55
|
+
const handoffNode = this.cmsApi.getNodeById(handoffNodeId);
|
|
56
|
+
if (handoffNode && handoffNode.type === hubtype_fields_1.HtNodeWithContentType.HANDOFF) {
|
|
57
|
+
const flowHandoff = content_fields_1.FlowHandoff.fromHubtypeCMS(handoffNode, this.cmsApi.getResolvedLocale(), this.cmsApi);
|
|
58
|
+
botContext.input.payload = flowHandoff.resolveOnClosePayload(botContext);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
convertWhatsappAiAgentEmptyPayloads(botContext) {
|
|
63
|
+
if (botContext.session.user.provider === core_1.PROVIDER.WHATSAPP) {
|
|
64
|
+
const shouldUseReferral = botContext.input.referral &&
|
|
65
|
+
botContext.input.payload?.startsWith(constants_1.EMPTY_PAYLOAD);
|
|
66
|
+
if (shouldUseReferral) {
|
|
67
|
+
botContext.input.type = core_1.INPUT.TEXT;
|
|
68
|
+
botContext.input.data = botContext.input.referral;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
removePayloadSourceSuffix(botContext) {
|
|
73
|
+
if (botContext.input.payload) {
|
|
74
|
+
botContext.input.payload = this.removeSourceSuffix(botContext.input.payload);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
resolveBotActionPayload(botContext) {
|
|
78
|
+
if (botContext.input.payload &&
|
|
79
|
+
this.cmsApi.isBotAction(botContext.input.payload)) {
|
|
80
|
+
const cmsBotAction = this.cmsApi.getNodeById(botContext.input.payload);
|
|
81
|
+
botContext.input.payload =
|
|
82
|
+
this.cmsApi.createPayloadWithParams(cmsBotAction);
|
|
83
|
+
// Re-execute convertWhatsappAiAgentEmptyPayloads function to handle
|
|
84
|
+
// the case that a BotAction has a payload equals to EMPTY_PAYLOAD
|
|
85
|
+
this.convertWhatsappAiAgentEmptyPayloads(botContext);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
removeSourceSuffix(payload) {
|
|
89
|
+
return payload.split(constants_1.SOURCE_INFO_SEPARATOR)[0];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.BotContextManager = BotContextManager;
|
|
93
|
+
//# sourceMappingURL=bot-context-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot-context-manager.js","sourceRoot":"","sources":["../../src/bot-context-manager.ts"],"names":[],"mappings":";;;AAAA,wCAKsB;AAGtB,2CAKoB;AACpB,qDAA8C;AAC9C,oEAIwC;AACxC,6CAAwD;AAExD,yCAAwD;AAExD,MAAa,iBAAiB;IAC5B,YACmB,MAAsB,EACtB,kBAA+C;QAD/C,WAAM,GAAN,MAAM,CAAgB;QACtB,uBAAkB,GAAlB,kBAAkB,CAA6B;IAC/D,CAAC;IAEJ,KAAK,CAAC,qBAAqB,CAAC,UAAsB;QAChD,sIAAsI;QACtI,IAAI,CAAC,mCAAmC,CAAC,UAAU,CAAC,CAAA;QAE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AAU,CAAC,yBAAa,CAAC,CAAA;YAErD,IAAI,iBAAiB,EAAE,CAAC;gBACtB,UAAU,CAAC,KAAK,CAAC,IAAI,GAAG,YAAK,CAAC,IAAI,CAAA;gBAClC,UAAU,CAAC,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAA;YACnD,CAAC;QACH,CAAC;IACH,CAAC;IAEO,yBAAyB,CAAC,UAAsB;QACtD,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YAC7B,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAChD,UAAU,CAAC,KAAK,CAAC,OAAO,CACzB,CAAA;QACH,CAAC;IACH,CAAC;IAEO,uBAAuB,CAAC,UAAsB;QACpD,IACE,UAAU,CAAC,KAAK,CAAC,OAAO;YACxB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,EACjD,CAAC;YACD,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAC1C,UAAU,CAAC,KAAK,CAAC,OAAO,CACzB,CAAA;YAED,UAAU,CAAC,KAAK,CAAC,OAAO;gBACtB,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAA;YAEnD,oEAAoE;YACpE,kEAAkE;YAClE,IAAI,CAAC,mCAAmC,CAAC,UAAU,CAAC,CAAA;QACtD,CAAC;IACH,CAAC;IAEO,kBAAkB,CAAC,OAAe;QACxC,OAAO,OAAO,CAAC,KAAK,CAAC,iCAAqB,CAAC,CAAC,CAAC,CAAC,CAAA;IAChD,CAAC;CACF;AAhID,8CAgIC"}
|
package/lib/cjs/constants.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export declare const FLOW_BUILDER_API_URL_PROD: string;
|
|
2
2
|
export declare const SEPARATOR = "|";
|
|
3
3
|
export declare const SOURCE_INFO_SEPARATOR = "|source_";
|
|
4
|
-
export declare const EMPTY_PAYLOAD = "fb-empty-payload";
|
|
5
4
|
export declare const VARIABLE_PATTERN_GLOBAL: RegExp;
|
|
6
5
|
export declare const ACCESS_TOKEN_VARIABLE_KEY = "_access_token";
|
|
7
6
|
export declare const REG_EXP_PATTERN: RegExp;
|
|
8
7
|
export declare const UUID_REGEXP: RegExp;
|
|
8
|
+
export declare const EMPTY_PAYLOAD = "fb-empty-payload";
|
|
9
|
+
export declare const ON_CLOSE_HANDOFF_PAYLOAD = "fb-on-close-handoff";
|
|
9
10
|
export declare const AGENT_RATING_PAYLOAD = "agent-rating";
|
|
10
11
|
export declare const PUSH_FLOW_PAYLOAD = "push-flow";
|
|
11
12
|
export declare const MAIN_FLOW_NAME = "Main";
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FALLBACK_FLOW_NAME = exports.AI_AGENTS_FLOW_NAME = exports.MAIN_FLOW_NAME = exports.PUSH_FLOW_PAYLOAD = exports.AGENT_RATING_PAYLOAD = exports.
|
|
3
|
+
exports.FALLBACK_FLOW_NAME = exports.AI_AGENTS_FLOW_NAME = exports.MAIN_FLOW_NAME = exports.PUSH_FLOW_PAYLOAD = exports.AGENT_RATING_PAYLOAD = exports.ON_CLOSE_HANDOFF_PAYLOAD = exports.EMPTY_PAYLOAD = exports.UUID_REGEXP = exports.REG_EXP_PATTERN = exports.ACCESS_TOKEN_VARIABLE_KEY = exports.VARIABLE_PATTERN_GLOBAL = exports.SOURCE_INFO_SEPARATOR = exports.SEPARATOR = exports.FLOW_BUILDER_API_URL_PROD = void 0;
|
|
4
4
|
exports.FLOW_BUILDER_API_URL_PROD = process.env.HUBTYPE_API_URL || 'https://api.hubtype.com';
|
|
5
5
|
exports.SEPARATOR = '|';
|
|
6
6
|
exports.SOURCE_INFO_SEPARATOR = `${exports.SEPARATOR}source_`;
|
|
7
|
-
exports.EMPTY_PAYLOAD = 'fb-empty-payload';
|
|
8
7
|
exports.VARIABLE_PATTERN_GLOBAL = /{([^{}]+)}/g;
|
|
9
8
|
exports.ACCESS_TOKEN_VARIABLE_KEY = '_access_token';
|
|
10
9
|
exports.REG_EXP_PATTERN = /^\/(.*)\/([gimyus]*)$/;
|
|
11
10
|
exports.UUID_REGEXP = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
12
11
|
/* ********** PAYLOADS ********** */
|
|
12
|
+
exports.EMPTY_PAYLOAD = 'fb-empty-payload';
|
|
13
|
+
exports.ON_CLOSE_HANDOFF_PAYLOAD = 'fb-on-close-handoff';
|
|
13
14
|
exports.AGENT_RATING_PAYLOAD = 'agent-rating';
|
|
14
15
|
exports.PUSH_FLOW_PAYLOAD = 'push-flow';
|
|
15
16
|
/* ********** FLOW NAMES ********** */
|
package/lib/cjs/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,yBAAyB,GACpC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;AAC7C,QAAA,SAAS,GAAG,GAAG,CAAA;AACf,QAAA,qBAAqB,GAAG,GAAG,iBAAS,SAAS,CAAA;AAC7C,QAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,yBAAyB,GACpC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;AAC7C,QAAA,SAAS,GAAG,GAAG,CAAA;AACf,QAAA,qBAAqB,GAAG,GAAG,iBAAS,SAAS,CAAA;AAC7C,QAAA,uBAAuB,GAAG,aAAa,CAAA;AACvC,QAAA,yBAAyB,GAAG,eAAe,CAAA;AAC3C,QAAA,eAAe,GAAG,uBAAuB,CAAA;AACzC,QAAA,WAAW,GACtB,iEAAiE,CAAA;AAEnE,oCAAoC;AACvB,QAAA,aAAa,GAAG,kBAAkB,CAAA;AAClC,QAAA,wBAAwB,GAAG,qBAAqB,CAAA;AAChD,QAAA,oBAAoB,GAAG,cAAc,CAAA;AACrC,QAAA,iBAAiB,GAAG,WAAW,CAAA;AAE5C,sCAAsC;AACzB,QAAA,cAAc,GAAG,MAAM,CAAA;AACvB,QAAA,mBAAmB,GAAG,WAAW,CAAA;AACjC,QAAA,kBAAkB,GAAG,UAAU,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HubtypeCaseContactReason } from '@botonic/core';
|
|
2
|
+
import type { HtContactReasonBranch } from './hubtype-fields/contact-reasons-conditional';
|
|
3
|
+
export declare function contactReasonMatchesBranch(sessionContactReason: HubtypeCaseContactReason, branch: HtContactReasonBranch): boolean;
|
|
4
|
+
export declare function findMatchingContactReasonBranch(sessionContactReasons: HubtypeCaseContactReason[], contactReasonBranches: HtContactReasonBranch[]): HtContactReasonBranch | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contactReasonMatchesBranch = contactReasonMatchesBranch;
|
|
4
|
+
exports.findMatchingContactReasonBranch = findMatchingContactReasonBranch;
|
|
5
|
+
function contactReasonMatchesBranch(sessionContactReason, branch) {
|
|
6
|
+
return (sessionContactReason.project_id === branch.project_id &&
|
|
7
|
+
sessionContactReason.name === branch.name);
|
|
8
|
+
}
|
|
9
|
+
function findMatchingContactReasonBranch(sessionContactReasons, contactReasonBranches) {
|
|
10
|
+
return contactReasonBranches.find(branch => sessionContactReasons.some(sessionContactReason => contactReasonMatchesBranch(sessionContactReason, branch)));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=contact-reasons-conditional-matcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-reasons-conditional-matcher.js","sourceRoot":"","sources":["../../../src/content-fields/contact-reasons-conditional-matcher.ts"],"names":[],"mappings":";;AAIA,gEAQC;AAED,0EASC;AAnBD,SAAgB,0BAA0B,CACxC,oBAA8C,EAC9C,MAA6B;IAE7B,OAAO,CACL,oBAAoB,CAAC,UAAU,KAAK,MAAM,CAAC,UAAU;QACrD,oBAAoB,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,CAC1C,CAAA;AACH,CAAC;AAED,SAAgB,+BAA+B,CAC7C,qBAAiD,EACjD,qBAA8C;IAE9C,OAAO,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CACzC,qBAAqB,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAChD,0BAA0B,CAAC,oBAAoB,EAAE,MAAM,CAAC,CACzD,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type BotContext } from '@botonic/core';
|
|
2
|
+
import { ContentFieldsBase } from './content-fields-base';
|
|
3
|
+
import type { HtNodeLink } from './hubtype-fields/common';
|
|
4
|
+
import type { HtContactReasonBranch, HtContactReasonsNode } from './hubtype-fields/contact-reasons-conditional';
|
|
5
|
+
export declare class FlowContactReasonsConditional extends ContentFieldsBase {
|
|
6
|
+
contactReasons: HtContactReasonBranch[];
|
|
7
|
+
conditionalResult: string;
|
|
8
|
+
defaultTarget: HtNodeLink;
|
|
9
|
+
static fromHubtypeCMS(component: HtContactReasonsNode, botContext: BotContext): FlowContactReasonsConditional;
|
|
10
|
+
private setFollowUp;
|
|
11
|
+
trackFlow(botContext: BotContext): Promise<void>;
|
|
12
|
+
processContent(botContext: BotContext): Promise<void>;
|
|
13
|
+
toBotonic(): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowContactReasonsConditional = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const core_1 = require("@botonic/core");
|
|
6
|
+
const tracking_1 = require("../tracking");
|
|
7
|
+
const contact_reasons_conditional_matcher_1 = require("./contact-reasons-conditional-matcher");
|
|
8
|
+
const content_fields_base_1 = require("./content-fields-base");
|
|
9
|
+
class FlowContactReasonsConditional extends content_fields_base_1.ContentFieldsBase {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.contactReasons = [];
|
|
13
|
+
this.conditionalResult = '';
|
|
14
|
+
}
|
|
15
|
+
static fromHubtypeCMS(component, botContext) {
|
|
16
|
+
const newContactReasonsConditional = new FlowContactReasonsConditional(component.id);
|
|
17
|
+
newContactReasonsConditional.contactReasons =
|
|
18
|
+
component.content.contact_reasons;
|
|
19
|
+
newContactReasonsConditional.defaultTarget =
|
|
20
|
+
component.content.default_target;
|
|
21
|
+
newContactReasonsConditional.setFollowUp(botContext);
|
|
22
|
+
return newContactReasonsConditional;
|
|
23
|
+
}
|
|
24
|
+
setFollowUp(botContext) {
|
|
25
|
+
const sessionContactReasons = botContext.session._hubtype_case_contact_reasons;
|
|
26
|
+
const matchingBranch = sessionContactReasons
|
|
27
|
+
? (0, contact_reasons_conditional_matcher_1.findMatchingContactReasonBranch)(sessionContactReasons, this.contactReasons)
|
|
28
|
+
: undefined;
|
|
29
|
+
if (matchingBranch) {
|
|
30
|
+
this.conditionalResult = matchingBranch.name;
|
|
31
|
+
this.followUp = matchingBranch.target;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.conditionalResult = 'default';
|
|
35
|
+
this.followUp = this.defaultTarget;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async trackFlow(botContext) {
|
|
39
|
+
const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } = (0, tracking_1.getCommonFlowContentEventArgsForContentId)(botContext, this.id);
|
|
40
|
+
const eventContactReasonsConditional = {
|
|
41
|
+
action: core_1.EventAction.ConditionalContactReasons,
|
|
42
|
+
flowThreadId,
|
|
43
|
+
flowId,
|
|
44
|
+
flowName,
|
|
45
|
+
flowNodeId,
|
|
46
|
+
flowNodeContentId,
|
|
47
|
+
flowNodeIsMeaningful: false,
|
|
48
|
+
contactReasons: botContext.session._hubtype_case_contact_reasons?.map(contactReason => contactReason.name) || [],
|
|
49
|
+
result: this.conditionalResult,
|
|
50
|
+
};
|
|
51
|
+
const { action, ...eventArgs } = eventContactReasonsConditional;
|
|
52
|
+
await (0, tracking_1.trackEvent)(botContext, action, eventArgs);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
async processContent(botContext) {
|
|
56
|
+
await this.filterContent(botContext, this);
|
|
57
|
+
await this.trackFlow(botContext);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
toBotonic() {
|
|
61
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.FlowContactReasonsConditional = FlowContactReasonsConditional;
|
|
65
|
+
//# sourceMappingURL=flow-contact-reasons-conditional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-contact-reasons-conditional.js","sourceRoot":"","sources":["../../../src/content-fields/flow-contact-reasons-conditional.tsx"],"names":[],"mappings":";;;;AAAA,wCAIsB;AAEtB,0CAGoB;AACpB,+FAAuF;AACvF,+DAAyD;AAOzD,MAAa,6BAA8B,SAAQ,uCAAiB;IAApE;;QACS,mBAAc,GAA4B,EAAE,CAAA;QAC5C,sBAAiB,GAAW,EAAE,CAAA;IAqEvC,CAAC;IAlEC,MAAM,CAAC,cAAc,CACnB,SAA+B,EAC/B,UAAsB;QAEtB,MAAM,4BAA4B,GAAG,IAAI,6BAA6B,CACpE,SAAS,CAAC,EAAE,CACb,CAAA;QACD,4BAA4B,CAAC,cAAc;YACzC,SAAS,CAAC,OAAO,CAAC,eAAe,CAAA;QACnC,4BA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AAE,GAAG,8BAA8B,CAAA;QAC/D,MAAM,IAAA,qBAAU,EAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;QAC/C,OAAM;IACR,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,UAAsB;QACzC,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QAC1C,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QAChC,OAAM;IACR,CAAC;IAED,SAAS;QACP,OAAO,kDAAK,CAAA;IACd,CAAC;CACF;AAvED,sEAuEC"}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { type BotContext } from '@botonic/core';
|
|
2
2
|
import type { FlowBuilderApi } from '../api';
|
|
3
3
|
import { ContentFieldsBase } from './content-fields-base';
|
|
4
|
-
import type
|
|
4
|
+
import { type HtHandoffNode, type HtNodeLink, type HtQueueLocale } from './hubtype-fields';
|
|
5
5
|
export declare class FlowHandoff extends ContentFieldsBase {
|
|
6
6
|
queue?: HtQueueLocale;
|
|
7
7
|
onFinishPayload?: string;
|
|
8
8
|
handoffAutoAssign: boolean;
|
|
9
9
|
hasQueuePositionChangedNotificationsEnabled: boolean;
|
|
10
|
+
hasDifferentiatedCloseTypes: boolean;
|
|
11
|
+
resolvedByAgent?: HtNodeLink;
|
|
12
|
+
discardedByAgent?: HtNodeLink;
|
|
13
|
+
discardedByUser?: HtNodeLink;
|
|
14
|
+
discardedBySystem?: HtNodeLink;
|
|
10
15
|
isTestIntegration: boolean;
|
|
11
16
|
static fromHubtypeCMS(cmsHandoff: HtHandoffNode, locale: string, cmsApi: FlowBuilderApi): FlowHandoff;
|
|
12
17
|
private static getOnFinishPayload;
|
|
18
|
+
resolveOnClosePayload(botContext: BotContext): string;
|
|
13
19
|
doHandoff(botContext: BotContext): Promise<void>;
|
|
14
20
|
trackFlow(_botContext: BotContext): Promise<void>;
|
|
15
21
|
processContent(botContext: BotContext): Promise<void>;
|
|
@@ -4,26 +4,62 @@ exports.FlowHandoff = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const core_1 = require("@botonic/core");
|
|
6
6
|
const react_1 = require("@botonic/react");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
7
8
|
const tracking_1 = require("../tracking");
|
|
8
9
|
const content_fields_base_1 = require("./content-fields-base");
|
|
10
|
+
const hubtype_fields_1 = require("./hubtype-fields");
|
|
9
11
|
class FlowHandoff extends content_fields_base_1.ContentFieldsBase {
|
|
10
12
|
static fromHubtypeCMS(cmsHandoff, locale, cmsApi) {
|
|
11
13
|
const newHandoff = new FlowHandoff(cmsHandoff.id);
|
|
12
14
|
newHandoff.code = cmsHandoff.code;
|
|
13
15
|
newHandoff.queue = FlowHandoff.getQueueByLocale(locale, cmsHandoff.content.queue);
|
|
14
|
-
newHandoff.
|
|
16
|
+
newHandoff.hasDifferentiatedCloseTypes =
|
|
17
|
+
cmsHandoff.content.has_differentiated_close_types;
|
|
18
|
+
newHandoff.resolvedByAgent = cmsHandoff.content.resolved_by_agent;
|
|
19
|
+
newHandoff.discardedByAgent = cmsHandoff.content.discarded_by_agent;
|
|
20
|
+
newHandoff.discardedByUser = cmsHandoff.content.discarded_by_user;
|
|
21
|
+
newHandoff.discardedBySystem = cmsHandoff.content.discarded_by_system;
|
|
15
22
|
newHandoff.handoffAutoAssign = cmsHandoff.content.has_auto_assign;
|
|
16
23
|
newHandoff.hasQueuePositionChangedNotificationsEnabled =
|
|
17
24
|
cmsHandoff.content.has_queue_position_changed_notifications_enabled;
|
|
18
|
-
newHandoff.
|
|
25
|
+
newHandoff.onFinishPayload = FlowHandoff.getOnFinishPayload(cmsHandoff, cmsApi);
|
|
26
|
+
newHandoff.followUp = undefined;
|
|
19
27
|
return newHandoff;
|
|
20
28
|
}
|
|
21
29
|
static getOnFinishPayload(cmsHandoff, cmsApi) {
|
|
22
|
-
if (cmsHandoff.
|
|
30
|
+
if (cmsHandoff.content.has_differentiated_close_types) {
|
|
31
|
+
return `${constants_1.ON_CLOSE_HANDOFF_PAYLOAD}${constants_1.SEPARATOR}${cmsHandoff.id}`;
|
|
32
|
+
}
|
|
33
|
+
else if (cmsHandoff.target?.id) {
|
|
23
34
|
return cmsApi.getPayload(cmsHandoff.target);
|
|
24
35
|
}
|
|
25
36
|
return undefined;
|
|
26
37
|
}
|
|
38
|
+
resolveOnClosePayload(botContext) {
|
|
39
|
+
const contactReasons = botContext.session._hubtype_case_contact_reasons || [];
|
|
40
|
+
if (contactReasons.some(reason => reason.name === hubtype_fields_1.DiscardType.ByAgent)) {
|
|
41
|
+
if (this.discardedByAgent?.id) {
|
|
42
|
+
return this.discardedByAgent.id;
|
|
43
|
+
}
|
|
44
|
+
console.error('No discarded by agent target found');
|
|
45
|
+
}
|
|
46
|
+
if (contactReasons.some(reason => reason.name === hubtype_fields_1.DiscardType.ByUser)) {
|
|
47
|
+
if (this.discardedByUser?.id) {
|
|
48
|
+
return this.discardedByUser.id;
|
|
49
|
+
}
|
|
50
|
+
console.error('No discarded by user target found');
|
|
51
|
+
}
|
|
52
|
+
if (contactReasons.some(reason => reason.name === hubtype_fields_1.DiscardType.BySystem)) {
|
|
53
|
+
if (this.discardedBySystem?.id) {
|
|
54
|
+
return this.discardedBySystem.id;
|
|
55
|
+
}
|
|
56
|
+
console.error('No discarded by system target found');
|
|
57
|
+
}
|
|
58
|
+
if (this.resolvedByAgent?.id) {
|
|
59
|
+
return this.resolvedByAgent.id;
|
|
60
|
+
}
|
|
61
|
+
throw new Error('No resolved by agent target found');
|
|
62
|
+
}
|
|
27
63
|
async doHandoff(botContext) {
|
|
28
64
|
const handOffBuilder = new core_1.HandOffBuilder(botContext.session);
|
|
29
65
|
handOffBuilder.withAutoAssignOnWaiting(this.handoffAutoAssign);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-handoff.js","sourceRoot":"","sources":["../../../src/content-fields/flow-handoff.tsx"],"names":[],"mappings":";;;;AAAA,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C,CAAC;IACH,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,SAAS,CAAC,WAAuB;QACrC,+EAA+E;IACjF,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,UAAsB;QACzC,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QAC1C,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QAChC,OAAM;IACR,CAAC;IAED,SAAS,CAAC,UAAsB;QAC9B,OAAO,IAAA,YAAK,EAAC,UAAU,CAAC,OAAO,CAAC,IAAI,IAAA,gBAAS,EAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAClE,uBAAC,uBAAe,IAAe,eAAe,EAAE,IAAI,IAA9B,IAAI,CAAC,EAAE,CAA2B,CACzD,CAAC,CAAC,CAAC,CACF,kDAAK,CACN,CAAA;IACH,CAAC;CACF;AA1ID,kCA0IC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HtBaseNode, HtNodeLink } from './common';
|
|
2
|
+
import type { HtNodeWithContentType } from './node-types';
|
|
3
|
+
export interface HtContactReasonBranch {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
project_id: string;
|
|
7
|
+
project_name: string;
|
|
8
|
+
target: HtNodeLink;
|
|
9
|
+
}
|
|
10
|
+
export interface HtContactReasonsNode extends HtBaseNode {
|
|
11
|
+
type: HtNodeWithContentType.CONTACT_REASONS_CONDITION;
|
|
12
|
+
content: {
|
|
13
|
+
contact_reasons: HtContactReasonBranch[];
|
|
14
|
+
default_target: HtNodeLink;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-reasons-conditional.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/contact-reasons-conditional.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import type { HtBaseNode, HtPayloadLocale, HtQueueLocale } from './common';
|
|
1
|
+
import type { HtBaseNode, HtNodeLink, HtPayloadLocale, HtQueueLocale } from './common';
|
|
2
2
|
import type { HtNodeWithContentType } from './node-types';
|
|
3
|
+
export declare enum DiscardType {
|
|
4
|
+
ByAgent = "discarded",
|
|
5
|
+
ByUser = "discarded_by_user",
|
|
6
|
+
BySystem = "discarded_by_system"
|
|
7
|
+
}
|
|
3
8
|
export interface HtHandoffNode extends HtBaseNode {
|
|
4
9
|
type: HtNodeWithContentType.HANDOFF;
|
|
5
10
|
content: {
|
|
@@ -7,5 +12,10 @@ export interface HtHandoffNode extends HtBaseNode {
|
|
|
7
12
|
payload: HtPayloadLocale[];
|
|
8
13
|
has_auto_assign: boolean;
|
|
9
14
|
has_queue_position_changed_notifications_enabled: boolean;
|
|
15
|
+
has_differentiated_close_types: boolean;
|
|
16
|
+
resolved_by_agent?: HtNodeLink;
|
|
17
|
+
discarded_by_agent?: HtNodeLink;
|
|
18
|
+
discarded_by_user?: HtNodeLink;
|
|
19
|
+
discarded_by_system?: HtNodeLink;
|
|
10
20
|
};
|
|
11
21
|
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiscardType = void 0;
|
|
4
|
+
var DiscardType;
|
|
5
|
+
(function (DiscardType) {
|
|
6
|
+
DiscardType["ByAgent"] = "discarded";
|
|
7
|
+
DiscardType["ByUser"] = "discarded_by_user";
|
|
8
|
+
DiscardType["BySystem"] = "discarded_by_system";
|
|
9
|
+
})(DiscardType || (exports.DiscardType = DiscardType = {}));
|
|
3
10
|
//# sourceMappingURL=handoff.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/handoff.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/handoff.ts"],"names":[],"mappings":";;;AAQA,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,2CAA4B,CAAA;IAC5B,+CAAgC,CAAA;AAClC,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB"}
|
|
@@ -20,7 +20,8 @@ export declare enum HtNodeWithContentType {
|
|
|
20
20
|
GO_TO_FLOW = "go-to-flow",
|
|
21
21
|
CAPTURE_USER_INPUT = "capture-user-input",
|
|
22
22
|
CUSTOM_CONDITION = "custom-condition",
|
|
23
|
-
DO_NOTHING = "do-nothing"
|
|
23
|
+
DO_NOTHING = "do-nothing",
|
|
24
|
+
CONTACT_REASONS_CONDITION = "contact-reasons-condition"
|
|
24
25
|
}
|
|
25
26
|
export declare enum HtNodeWithoutContentType {
|
|
26
27
|
URL = "url",
|
|
@@ -25,6 +25,7 @@ var HtNodeWithContentType;
|
|
|
25
25
|
HtNodeWithContentType["CAPTURE_USER_INPUT"] = "capture-user-input";
|
|
26
26
|
HtNodeWithContentType["CUSTOM_CONDITION"] = "custom-condition";
|
|
27
27
|
HtNodeWithContentType["DO_NOTHING"] = "do-nothing";
|
|
28
|
+
HtNodeWithContentType["CONTACT_REASONS_CONDITION"] = "contact-reasons-condition";
|
|
28
29
|
})(HtNodeWithContentType || (exports.HtNodeWithContentType = HtNodeWithContentType = {}));
|
|
29
30
|
var HtNodeWithoutContentType;
|
|
30
31
|
(function (HtNodeWithoutContentType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-types.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/node-types.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"node-types.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/node-types.ts"],"names":[],"mappings":";;;AAAA,IAAY,qBAwBX;AAxBD,WAAY,qBAAqB;IAC/B,8CAAqB,CAAA;IACrB,4CAAmB,CAAA;IACnB,wCAAe,CAAA;IACf,sCAAa,CAAA;IACb,4CAAmB,CAAA;IACnB,sDAA6B,CAAA;IAC7B,8CAAqB,CAAA;IACrB,8CAAqB,CAAA;IACrB,wCAAe,CAAA;IACf,sEAA6C,CAAA;IAC7C,4EAAmD,CAAA;IACnD,wFAA+D,CAAA;IAC/D,gEAAuC,CAAA;IACvC,kDAAyB,CAAA;IACzB,8CAAqB,CAAA;IACrB,4DAAmC,CAAA;IACnC,0CAAiB,CAAA;IACjB,4CAAmB,CAAA;IACnB,kDAAyB,CAAA;IACzB,kEAAyC,CAAA;IACzC,8DAAqC,CAAA;IACrC,kDAAyB,CAAA;IACzB,gFAAuD,CAAA;AACzD,CAAC,EAxBW,qBAAqB,qCAArB,qBAAqB,QAwBhC;AAED,IAAY,wBAGX;AAHD,WAAY,wBAAwB;IAClC,uCAAW,CAAA;IACX,+CAAmB,CAAA;AACrB,CAAC,EAHW,wBAAwB,wCAAxB,wBAAwB,QAGnC;AAED,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,4CAA2B,CAAA;AAC7B,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB"}
|