@botonic/plugin-flow-builder 0.22.3 → 0.22.4-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/{action.d.ts → action/index.d.ts} +1 -2
- package/lib/cjs/action/index.js +72 -0
- package/lib/cjs/action/index.js.map +1 -0
- package/lib/cjs/action/intent.d.ts +4 -0
- package/lib/cjs/action/intent.js +33 -0
- package/lib/cjs/action/intent.js.map +1 -0
- package/lib/cjs/action/keyword.d.ts +3 -0
- package/lib/cjs/action/keyword.js +21 -0
- package/lib/cjs/action/keyword.js.map +1 -0
- package/lib/cjs/action/tracking.d.ts +3 -0
- package/lib/cjs/action/tracking.js +13 -0
- package/lib/cjs/action/tracking.js.map +1 -0
- package/lib/cjs/action/user-input.d.ts +4 -0
- package/lib/cjs/action/user-input.js +28 -0
- package/lib/cjs/action/user-input.js.map +1 -0
- package/lib/cjs/api.d.ts +4 -4
- package/lib/cjs/api.js +4 -10
- package/lib/cjs/api.js.map +1 -1
- package/lib/cjs/content-fields/content-fields-base.d.ts +2 -1
- package/lib/cjs/content-fields/content-fields-base.js +3 -0
- package/lib/cjs/content-fields/content-fields-base.js.map +1 -1
- package/lib/cjs/content-fields/flow-handoff.d.ts +15 -0
- package/lib/cjs/content-fields/flow-handoff.js +60 -0
- package/lib/cjs/content-fields/flow-handoff.js.map +1 -0
- package/lib/cjs/content-fields/index.d.ts +3 -1
- package/lib/cjs/content-fields/index.js +3 -1
- package/lib/cjs/content-fields/index.js.map +1 -1
- package/lib/cjs/functions/conditional-queue-status.d.ts +10 -1
- package/lib/cjs/functions/conditional-queue-status.js +11 -16
- package/lib/cjs/functions/conditional-queue-status.js.map +1 -1
- package/lib/cjs/helpers.d.ts +0 -2
- package/lib/cjs/helpers.js +1 -6
- package/lib/cjs/helpers.js.map +1 -1
- package/lib/cjs/index.d.ts +5 -7
- package/lib/cjs/index.js +15 -11
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/{action.d.ts → action/index.d.ts} +1 -2
- package/lib/esm/action/index.js +66 -0
- package/lib/esm/action/index.js.map +1 -0
- package/lib/esm/action/intent.d.ts +4 -0
- package/lib/esm/action/intent.js +29 -0
- package/lib/esm/action/intent.js.map +1 -0
- package/lib/esm/action/keyword.d.ts +3 -0
- package/lib/esm/action/keyword.js +17 -0
- package/lib/esm/action/keyword.js.map +1 -0
- package/lib/esm/action/tracking.d.ts +3 -0
- package/lib/esm/action/tracking.js +9 -0
- package/lib/esm/action/tracking.js.map +1 -0
- package/lib/esm/action/user-input.d.ts +4 -0
- package/lib/esm/action/user-input.js +24 -0
- package/lib/esm/action/user-input.js.map +1 -0
- package/lib/esm/api.d.ts +4 -4
- package/lib/esm/api.js +4 -10
- package/lib/esm/api.js.map +1 -1
- package/lib/esm/content-fields/content-fields-base.d.ts +2 -1
- package/lib/esm/content-fields/content-fields-base.js +3 -0
- package/lib/esm/content-fields/content-fields-base.js.map +1 -1
- package/lib/esm/content-fields/flow-handoff.d.ts +15 -0
- package/lib/esm/content-fields/flow-handoff.js +55 -0
- package/lib/esm/content-fields/flow-handoff.js.map +1 -0
- package/lib/esm/content-fields/index.d.ts +3 -1
- package/lib/esm/content-fields/index.js +1 -0
- package/lib/esm/content-fields/index.js.map +1 -1
- package/lib/esm/functions/conditional-queue-status.d.ts +10 -1
- package/lib/esm/functions/conditional-queue-status.js +8 -14
- package/lib/esm/functions/conditional-queue-status.js.map +1 -1
- package/lib/esm/helpers.d.ts +0 -2
- package/lib/esm/helpers.js +0 -4
- package/lib/esm/helpers.js.map +1 -1
- package/lib/esm/index.d.ts +5 -7
- package/lib/esm/index.js +16 -12
- package/lib/esm/index.js.map +1 -1
- package/package.json +2 -1
- package/src/action/index.tsx +102 -0
- package/src/action/intent.ts +48 -0
- package/src/action/keyword.ts +28 -0
- package/src/action/tracking.ts +12 -0
- package/src/action/user-input.ts +40 -0
- package/src/api.ts +6 -14
- package/src/content-fields/content-fields-base.ts +8 -0
- package/src/content-fields/flow-handoff.tsx +106 -0
- package/src/content-fields/index.ts +3 -0
- package/src/functions/conditional-queue-status.ts +19 -16
- package/src/helpers.ts +0 -9
- package/src/index.ts +28 -20
- package/lib/cjs/action.js +0 -52
- package/lib/cjs/action.js.map +0 -1
- package/lib/cjs/handoff.d.ts +0 -3
- package/lib/cjs/handoff.js +0 -53
- package/lib/cjs/handoff.js.map +0 -1
- package/lib/esm/action.js +0 -46
- package/lib/esm/action.js.map +0 -1
- package/lib/esm/handoff.d.ts +0 -3
- package/lib/esm/handoff.js +0 -49
- package/lib/esm/handoff.js.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/action.tsx +0 -77
- package/src/content-fields/.DS_Store +0 -0
- package/src/handoff.ts +0 -76
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ActionRequest } from '@botonic/react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { FlowContent } from '
|
|
3
|
+
import { FlowContent } from '../content-fields';
|
|
4
4
|
type FlowBuilderActionProps = {
|
|
5
5
|
contents: FlowContent[];
|
|
6
|
-
isHandoff?: boolean;
|
|
7
6
|
};
|
|
8
7
|
export declare class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
|
|
9
8
|
static contextType: React.Context<{
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowBuilderMultichannelAction = exports.FlowBuilderAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const types_1 = require("@botonic/plugin-hubtype-analytics/lib/cjs/types");
|
|
6
|
+
const react_1 = require("@botonic/react");
|
|
7
|
+
const react_2 = tslib_1.__importDefault(require("react"));
|
|
8
|
+
const content_fields_1 = require("../content-fields");
|
|
9
|
+
const helpers_1 = require("../helpers");
|
|
10
|
+
const tracking_1 = require("./tracking");
|
|
11
|
+
const user_input_1 = require("./user-input");
|
|
12
|
+
class FlowBuilderAction extends react_2.default.Component {
|
|
13
|
+
static async botonicInit(request) {
|
|
14
|
+
const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
|
|
15
|
+
const locale = flowBuilderPlugin.getLocale(request.session);
|
|
16
|
+
const targetNode = await getTargetNode(flowBuilderPlugin.cmsApi, locale, request);
|
|
17
|
+
const contents = await flowBuilderPlugin.getContentsByNode(targetNode, locale);
|
|
18
|
+
const renderContents = contents.filter(async (content) => {
|
|
19
|
+
if (content instanceof content_fields_1.FlowHandoff) {
|
|
20
|
+
await content.doHandoff(request);
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
});
|
|
25
|
+
return { contents: renderContents };
|
|
26
|
+
}
|
|
27
|
+
render() {
|
|
28
|
+
const { contents } = this.props;
|
|
29
|
+
return contents.map(content => content.toBotonic(content.id));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.FlowBuilderAction = FlowBuilderAction;
|
|
33
|
+
FlowBuilderAction.contextType = react_1.RequestContext;
|
|
34
|
+
class FlowBuilderMultichannelAction extends FlowBuilderAction {
|
|
35
|
+
render() {
|
|
36
|
+
const { contents } = this.props;
|
|
37
|
+
return (react_2.default.createElement(react_1.Multichannel, { text: { buttonsAsText: false } }, contents.map(content => content.toBotonic(content.id))));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.FlowBuilderMultichannelAction = FlowBuilderMultichannelAction;
|
|
41
|
+
async function getTargetNode(cmsApi, locale, request) {
|
|
42
|
+
const contentId = request.input.payload;
|
|
43
|
+
let targetNode;
|
|
44
|
+
if (!contentId) {
|
|
45
|
+
targetNode = await (0, user_input_1.getNodeByUserInput)(cmsApi, locale, request);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
targetNode = cmsApi.getNodeById(contentId);
|
|
49
|
+
}
|
|
50
|
+
if (targetNode) {
|
|
51
|
+
const event = {
|
|
52
|
+
event_type: types_1.EventName.botFaq,
|
|
53
|
+
event_data: {
|
|
54
|
+
faq_name: targetNode.code,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
await (0, tracking_1.trackEvent)(request, event);
|
|
58
|
+
return targetNode;
|
|
59
|
+
}
|
|
60
|
+
return await getFallbackNode(cmsApi, request);
|
|
61
|
+
}
|
|
62
|
+
async function getFallbackNode(cmsApi, request) {
|
|
63
|
+
const isFirstFallbackOption = request.session.user.extra_data.isFirstFallbackOption || true;
|
|
64
|
+
const fallbackNode = cmsApi.getFallbackNode(isFirstFallbackOption);
|
|
65
|
+
request.session.user.extra_data.isFirstFallbackOption = !isFirstFallbackOption;
|
|
66
|
+
const event = {
|
|
67
|
+
event_type: types_1.EventName.fallback,
|
|
68
|
+
};
|
|
69
|
+
await (0, tracking_1.trackEvent)(request, event);
|
|
70
|
+
return fallbackNode;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/action/index.tsx"],"names":[],"mappings":";;;;AAAA,2EAIwD;AACxD,0CAA4E;AAC5E,0DAAyB;AAGzB,sDAA4D;AAE5D,wCAAiD;AACjD,yCAAuC;AACvC,6CAAiD;AAMjD,MAAa,iBAAkB,SAAQ,eAAK,CAAC,SAAiC;IAG5E,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,OAAsB;QAC7C,MAAM,iBAAiB,GAAG,IAAA,8BAAoB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC/D,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAE3D,MAAM,UAAU,GAAG,MAAM,aAAa,CACpC,iBAAiB,CAAC,MAAM,EACxB,MAAM,EACN,OAAO,CACR,CAAA;QAED,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CACxD,UAAU,EACV,MAAM,CACP,CAAA;QAED,MAAM,cAAc,GAAG,Q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ChE;IACD,IAAI,UAAU,EAAE;QACd,MAAM,KAAK,GAAgB;YACzB,UAAU,EAAE,iBAAS,CAAC,MAAM;YAC5B,UAAU,EAAE;gBACV,QAAQ,EAAE,UAAU,CAAC,IAAI;aAC1B;SACF,CAAA;QACD,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QAChC,OAAO,UAAU,CAAA;KAClB;IACD,OAAO,MAAM,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAC/C,CAAC;AAED,KAAK,UAAU,eAAe,CAAC,MAAsB,EAAE,OAAsB;IAC3E,MAAM,qBAAqB,GACzB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,IAAI,IAAI,CAAA;IAC/D,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAA;IAClE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,GAAG,CAAC,qBAAqB,CAAA;IAE9E,MAAM,KAAK,GAAkB;QAC3B,UAAU,EAAE,iBAAS,CAAC,QAAQ;KAC/B,CAAA;IACD,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAChC,OAAO,YAAY,CAAA;AACrB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ActionRequest } from '@botonic/react';
|
|
2
|
+
import { FlowBuilderApi } from '../api';
|
|
3
|
+
import { HtNodeWithContent } from '../content-fields/hubtype-fields';
|
|
4
|
+
export declare function getNodeByIntent(cmsApi: FlowBuilderApi, locale: string, request: ActionRequest): Promise<HtNodeWithContent | undefined>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNodeByIntent = void 0;
|
|
4
|
+
const types_1 = require("@botonic/plugin-hubtype-analytics/lib/cjs/types");
|
|
5
|
+
const tracking_1 = require("./tracking");
|
|
6
|
+
async function getNodeByIntent(cmsApi, locale, request) {
|
|
7
|
+
var _a;
|
|
8
|
+
const intentNode = cmsApi.getIntentNode(request.input, locale);
|
|
9
|
+
const eventBotAiModel = {
|
|
10
|
+
event_type: types_1.EventName.botAiModel,
|
|
11
|
+
event_data: {
|
|
12
|
+
intent: request.input.intent,
|
|
13
|
+
confidence: request.input.confidence,
|
|
14
|
+
confidence_successful: true,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
if (isIntentValid(intentNode, request, cmsApi) && ((_a = intentNode === null || intentNode === void 0 ? void 0 : intentNode.target) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
18
|
+
await (0, tracking_1.trackEvent)(request, eventBotAiModel);
|
|
19
|
+
return cmsApi.getNodeById(intentNode.target.id);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
eventBotAiModel.event_data.confidence_successful = false;
|
|
23
|
+
await (0, tracking_1.trackEvent)(request, eventBotAiModel);
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.getNodeByIntent = getNodeByIntent;
|
|
28
|
+
function isIntentValid(intentNode, request, cmsApi) {
|
|
29
|
+
return (intentNode &&
|
|
30
|
+
request.input.confidence &&
|
|
31
|
+
cmsApi.hasMetConfidenceThreshold(intentNode, request.input.confidence));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=intent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intent.js","sourceRoot":"","sources":["../../../src/action/intent.ts"],"names":[],"mappings":";;;AAAA,2EAGwD;AAQxD,yCAAuC;AAEhC,KAAK,UAAU,eAAe,CACnC,MAAsB,EACtB,MAAc,EACd,OAAsB;;IAEtB,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IAC9D,MAAM,eAAe,GAAoB;QACvC,UAAU,EAAE,iBAAS,CAAC,UAAU;QAChC,UAAU,EAAE;YACV,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAgB;YACtC,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,UAAoB;YAC9C,qBAAqB,EAAE,IAAI;SAC5B;KACF,CAAA;IACD,IAAI,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,KAAI,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,0CAAE,EAAE,CAAA,EAAE;QACxE,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,eAAe,CAAC,CAAA;QAC1C,OAAO,MAAM,CAAC,WAAW,CAAoB,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;KACnE;SAAM;QACL,eAAe,CAAC,UAAU,CAAC,qBAAqB,GAAG,KAAK,CAAA;QACxD,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,eAAe,CAAC,CAAA;QAC1C,OAAO,SAAS,CAAA;KACjB;AACH,CAAC;AAtBD,0CAsBC;AAED,SAAS,aAAa,CACpB,UAAoC,EACpC,OAAsB,EACtB,MAAsB;IAEtB,OAAO,CACL,UAAU;QACV,OAAO,CAAC,KAAK,CAAC,UAAU;QACxB,MAAM,CAAC,yBAAyB,CAAC,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CACvE,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ActionRequest } from '@botonic/react';
|
|
2
|
+
import { FlowBuilderApi } from '../api';
|
|
3
|
+
export declare function getNodeByKeyword(cmsApi: FlowBuilderApi, locale: string, request: ActionRequest, userInput: string): Promise<import("../content-fields/hubtype-fields").HtNodeWithContent | undefined>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNodeByKeyword = void 0;
|
|
4
|
+
const types_1 = require("@botonic/plugin-hubtype-analytics/lib/cjs/types");
|
|
5
|
+
const tracking_1 = require("./tracking");
|
|
6
|
+
async function getNodeByKeyword(cmsApi, locale, request, userInput) {
|
|
7
|
+
const keywordNode = cmsApi.getNodeByKeyword(userInput, locale);
|
|
8
|
+
const eventBotKeywordModel = {
|
|
9
|
+
event_type: types_1.EventName.botKeywordsModel,
|
|
10
|
+
event_data: {
|
|
11
|
+
confidence_successful: true,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
if (keywordNode) {
|
|
15
|
+
await (0, tracking_1.trackEvent)(request, eventBotKeywordModel);
|
|
16
|
+
return keywordNode;
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
exports.getNodeByKeyword = getNodeByKeyword;
|
|
21
|
+
//# sourceMappingURL=keyword.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyword.js","sourceRoot":"","sources":["../../../src/action/keyword.ts"],"names":[],"mappings":";;;AAAA,2EAGwD;AAIxD,yCAAuC;AAEhC,KAAK,UAAU,gBAAgB,CACpC,MAAsB,EACtB,MAAc,EACd,OAAsB,EACtB,SAAiB;IAEjB,MAAM,WAAW,GAAG,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IAC9D,MAAM,oBAAoB,GAAyB;QACjD,UAAU,EAAE,iBAAS,CAAC,gBAAgB;QACtC,UAAU,EAAE;YACV,qBAAqB,EAAE,IAAI;SAC5B;KACF,CAAA;IACD,IAAI,WAAW,EAAE;QACf,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,oBAAoB,CAAC,CAAA;QAC/C,OAAO,WAAW,CAAA;KACnB;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAlBD,4CAkBC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trackEvent = void 0;
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
async function trackEvent(request, event) {
|
|
6
|
+
const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
|
|
7
|
+
if (flowBuilderPlugin.trackEvent) {
|
|
8
|
+
await flowBuilderPlugin.trackEvent(request, event.event_type, event);
|
|
9
|
+
}
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
exports.trackEvent = trackEvent;
|
|
13
|
+
//# sourceMappingURL=tracking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../../src/action/tracking.ts"],"names":[],"mappings":";;;AAGA,wCAAiD;AAE1C,KAAK,UAAU,UAAU,CAAC,OAAsB,EAAE,KAAmB;IAC1E,MAAM,iBAAiB,GAAG,IAAA,8BAAoB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,IAAI,iBAAiB,CAAC,UAAU,EAAE;QAChC,MAAM,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;KACrE;IACD,OAAM;AACR,CAAC;AAND,gCAMC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ActionRequest } from '@botonic/react';
|
|
2
|
+
import { FlowBuilderApi } from '../api';
|
|
3
|
+
import { HtNodeWithContent } from '../content-fields/hubtype-fields';
|
|
4
|
+
export declare function getNodeByUserInput(cmsApi: FlowBuilderApi, locale: string, request: ActionRequest): Promise<HtNodeWithContent | undefined>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNodeByUserInput = void 0;
|
|
4
|
+
const types_1 = require("@botonic/plugin-hubtype-analytics/lib/cjs/types");
|
|
5
|
+
const intent_1 = require("./intent");
|
|
6
|
+
const keyword_1 = require("./keyword");
|
|
7
|
+
const tracking_1 = require("./tracking");
|
|
8
|
+
async function getNodeByUserInput(cmsApi, locale, request) {
|
|
9
|
+
if (request.session.is_first_interaction) {
|
|
10
|
+
const startNode = cmsApi.getStartNode();
|
|
11
|
+
const event = {
|
|
12
|
+
event_type: types_1.EventName.botStart,
|
|
13
|
+
};
|
|
14
|
+
await (0, tracking_1.trackEvent)(request, event);
|
|
15
|
+
return startNode;
|
|
16
|
+
}
|
|
17
|
+
if (request.input.data) {
|
|
18
|
+
const nodeByIntent = await (0, intent_1.getNodeByIntent)(cmsApi, locale, request);
|
|
19
|
+
if (nodeByIntent)
|
|
20
|
+
return nodeByIntent;
|
|
21
|
+
const keywordNode = await (0, keyword_1.getNodeByKeyword)(cmsApi, locale, request, request.input.data);
|
|
22
|
+
if (keywordNode)
|
|
23
|
+
return keywordNode;
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
exports.getNodeByUserInput = getNodeByUserInput;
|
|
28
|
+
//# sourceMappingURL=user-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-input.js","sourceRoot":"","sources":["../../../src/action/user-input.ts"],"names":[],"mappings":";;;AAAA,2EAGwD;AAKxD,qCAA0C;AAC1C,uCAA4C;AAC5C,yCAAuC;AAEhC,KAAK,UAAU,kBAAkB,CACtC,MAAsB,EACtB,MAAc,EACd,OAAsB;IAEtB,IAAI,OAAO,CAAC,OAAO,CAAC,oBAAoB,EAAE;QACxC,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAA;QACvC,MAAM,KAAK,GAAkB;YAC3B,UAAU,EAAE,iBAAS,CAAC,QAAQ;SAC/B,CAAA;QACD,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QAChC,OAAO,SAAS,CAAA;KACjB;IAED,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE;QACtB,MAAM,YAAY,GAAG,MAAM,IAAA,wBAAe,EAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACnE,IAAI,YAAY;YAAE,OAAO,YAAY,CAAA;QAErC,MAAM,WAAW,GAAG,MAAM,IAAA,0BAAgB,EACxC,MAAM,EACN,MAAM,EACN,OAAO,EACP,OAAO,CAAC,KAAK,CAAC,IAAI,CACnB,CAAA;QACD,IAAI,WAAW;YAAE,OAAO,WAAW,CAAA;KACpC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AA3BD,gDA2BC"}
|
package/lib/cjs/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Input } from '@botonic/core';
|
|
2
|
-
import { HtFlowBuilderData, HtNodeComponent, HtNodeWithContent } from './content-fields/hubtype-fields';
|
|
2
|
+
import { HtFlowBuilderData, HtIntentNode, HtNodeComponent, HtNodeWithContent } from './content-fields/hubtype-fields';
|
|
3
3
|
import { FlowBuilderApiOptions } from './types';
|
|
4
4
|
export declare class FlowBuilderApi {
|
|
5
5
|
url: string;
|
|
@@ -11,9 +11,9 @@ export declare class FlowBuilderApi {
|
|
|
11
11
|
getNodeByCode(code: string): HtNodeComponent;
|
|
12
12
|
getStartNode(): HtNodeWithContent;
|
|
13
13
|
getFallbackNode(alternate: boolean): HtNodeWithContent;
|
|
14
|
-
|
|
15
|
-
private
|
|
16
|
-
|
|
14
|
+
getIntentNode(input: Input, locale: string): HtIntentNode | undefined;
|
|
15
|
+
private nodeContainsIntent;
|
|
16
|
+
hasMetConfidenceThreshold(node: HtIntentNode, predictedConfidence: number): boolean;
|
|
17
17
|
getNodeByKeyword(userInput: string, locale: string): HtNodeWithContent | undefined;
|
|
18
18
|
private matchKeywords;
|
|
19
19
|
private containsAnyKeywords;
|
package/lib/cjs/api.js
CHANGED
|
@@ -54,18 +54,12 @@ class FlowBuilderApi {
|
|
|
54
54
|
? this.getNodeById(fallbackFirstMessage.id)
|
|
55
55
|
: this.getNodeById(fallbackSecondMessage.id);
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
getIntentNode(input, locale) {
|
|
58
58
|
try {
|
|
59
|
-
const
|
|
59
|
+
const intentsNodes = this.flow.nodes.filter(node => node.type === hubtype_fields_1.HtNodeWithContentType.INTENT);
|
|
60
60
|
const inputIntent = input.intent;
|
|
61
|
-
const inputConfidence = input.confidence;
|
|
62
61
|
if (inputIntent) {
|
|
63
|
-
|
|
64
|
-
this.hasIntent(node, inputIntent, locale) &&
|
|
65
|
-
inputConfidence &&
|
|
66
|
-
this.hasMetConfidenceThreshold(node, inputConfidence));
|
|
67
|
-
return ((matchedIntentNode === null || matchedIntentNode === void 0 ? void 0 : matchedIntentNode.target) &&
|
|
68
|
-
this.getNodeById(matchedIntentNode === null || matchedIntentNode === void 0 ? void 0 : matchedIntentNode.target.id));
|
|
62
|
+
return intentsNodes.find(node => inputIntent && this.nodeContainsIntent(node, inputIntent, locale));
|
|
69
63
|
}
|
|
70
64
|
}
|
|
71
65
|
catch (error) {
|
|
@@ -73,7 +67,7 @@ class FlowBuilderApi {
|
|
|
73
67
|
}
|
|
74
68
|
return undefined;
|
|
75
69
|
}
|
|
76
|
-
|
|
70
|
+
nodeContainsIntent(node, intent, locale) {
|
|
77
71
|
return node.content.intents.some(i => i.locale === locale && i.values.includes(intent));
|
|
78
72
|
}
|
|
79
73
|
hasMetConfidenceThreshold(node, predictedConfidence) {
|
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,oEAUwC;AAGxC,MAAa,cAAc;IAIzB,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,IAAI,GAAG,MAAA,OAAO,CAAC,IAAI,mCAAI,CAAC,MAAM,MAA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mB,EACnB,KAAa,EACb,MAAc;QAEd,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CACvC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,IAAI,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CACtE,CAAA;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAA;IACxB,CAAC;IAEO,mBAAmB,CAAC,KAAa,EAAE,QAAkB;QAC3D,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;IAC1D,CAAC;CACF;AA1ID,wCA0IC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { HtMediaFileLocale, HtTextLocale, HtVideoLocale } from './hubtype-fields';
|
|
1
|
+
import { HtMediaFileLocale, HtQueueLocale, HtTextLocale, HtVideoLocale } from './hubtype-fields';
|
|
2
2
|
export declare abstract class ContentFieldsBase {
|
|
3
3
|
readonly id: string;
|
|
4
4
|
constructor(id: string);
|
|
5
5
|
static getTextByLocale(locale: string, text: HtTextLocale[]): string;
|
|
6
6
|
static getImageByLocale(locale: string, image: HtMediaFileLocale[]): string;
|
|
7
7
|
static getVideoByLocale(locale: string, video: HtVideoLocale[]): string;
|
|
8
|
+
static getQueueByLocale(locale: string, queues: HtQueueLocale[]): HtQueueLocale | undefined;
|
|
8
9
|
}
|
|
@@ -20,6 +20,9 @@ class ContentFieldsBase {
|
|
|
20
20
|
const result = video.find(v => v.locale === locale);
|
|
21
21
|
return (_a = result === null || result === void 0 ? void 0 : result.url) !== null && _a !== void 0 ? _a : '';
|
|
22
22
|
}
|
|
23
|
+
static getQueueByLocale(locale, queues) {
|
|
24
|
+
return queues.find(queue => queue.locale === locale);
|
|
25
|
+
}
|
|
23
26
|
}
|
|
24
27
|
exports.ContentFieldsBase = ContentFieldsBase;
|
|
25
28
|
//# sourceMappingURL=content-fields-base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-fields-base.js","sourceRoot":"","sources":["../../../src/content-fields/content-fields-base.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"content-fields-base.js","sourceRoot":"","sources":["../../../src/content-fields/content-fields-base.ts"],"names":[],"mappings":";;;AAOA,MAAsB,iBAAiB;IACrC,YAA4B,EAAU;QAAV,OAAE,GAAF,EAAE,CAAQ;IAAG,CAAC;IAE1C,MAAM,CAAC,eAAe,CAAC,MAAc,EAAE,IAAoB;;QACzD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAA;QAClD,OAAO,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,mCAAI,EAAE,CAAA;IAC9B,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,KAA0B;;QAChE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAA;QACnD,OAAO,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,mCAAI,EAAE,CAAA;IAC3B,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,KAAsB;;QAC5D,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAA;QACnD,OAAO,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,mCAAI,EAAE,CAAA;IAC1B,CAAC;IAED,MAAM,CAAC,gBAAgB,CACrB,MAAc,EACd,MAAuB;QAEvB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAA;IACtD,CAAC;CACF;AAxBD,8CAwBC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ActionRequest } from '@botonic/react';
|
|
3
|
+
import { FlowBuilderApi } from '../api';
|
|
4
|
+
import { ContentFieldsBase } from './content-fields-base';
|
|
5
|
+
import { HtHandoffNode, HtQueueLocale } from './hubtype-fields';
|
|
6
|
+
export declare class FlowHandoff extends ContentFieldsBase {
|
|
7
|
+
code: string;
|
|
8
|
+
queue?: HtQueueLocale;
|
|
9
|
+
onFinishPayload?: string;
|
|
10
|
+
handoffAutoAssign: boolean;
|
|
11
|
+
static fromHubtypeCMS(cmsHandoff: HtHandoffNode, locale: string, cmsApi: FlowBuilderApi): FlowHandoff;
|
|
12
|
+
private static getOnFinishPayload;
|
|
13
|
+
doHandoff(request: ActionRequest): Promise<void>;
|
|
14
|
+
toBotonic(): JSX.Element;
|
|
15
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowHandoff = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@botonic/core");
|
|
6
|
+
const types_1 = require("@botonic/plugin-hubtype-analytics/lib/cjs/types");
|
|
7
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
8
|
+
const tracking_1 = require("../action/tracking");
|
|
9
|
+
const conditional_queue_status_1 = require("../functions/conditional-queue-status");
|
|
10
|
+
const content_fields_base_1 = require("./content-fields-base");
|
|
11
|
+
class FlowHandoff extends content_fields_base_1.ContentFieldsBase {
|
|
12
|
+
static fromHubtypeCMS(cmsHandoff, locale, cmsApi) {
|
|
13
|
+
const newHandoff = new FlowHandoff(cmsHandoff.id);
|
|
14
|
+
newHandoff.code = cmsHandoff.code;
|
|
15
|
+
newHandoff.queue = this.getQueueByLocale(locale, cmsHandoff.content.queue);
|
|
16
|
+
newHandoff.onFinishPayload = this.getOnFinishPayload(cmsHandoff, locale, cmsApi);
|
|
17
|
+
newHandoff.handoffAutoAssign = cmsHandoff.content.has_auto_assign;
|
|
18
|
+
return newHandoff;
|
|
19
|
+
}
|
|
20
|
+
static getOnFinishPayload(cmsHandoff, locale, cmsApi) {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
if ((_a = cmsHandoff.target) === null || _a === void 0 ? void 0 : _a.id) {
|
|
23
|
+
const handoffTargetNode = cmsApi.getNodeById((_b = cmsHandoff.target) === null || _b === void 0 ? void 0 : _b.id);
|
|
24
|
+
if (handoffTargetNode === null || handoffTargetNode === void 0 ? void 0 : handoffTargetNode.id)
|
|
25
|
+
return handoffTargetNode === null || handoffTargetNode === void 0 ? void 0 : handoffTargetNode.id;
|
|
26
|
+
}
|
|
27
|
+
const payloadId = (_c = cmsHandoff.content.payload.find(payload => payload.locale === locale)) === null || _c === void 0 ? void 0 : _c.id;
|
|
28
|
+
if (!payloadId)
|
|
29
|
+
return undefined;
|
|
30
|
+
const actionPayload = cmsApi.getNodeById(payloadId);
|
|
31
|
+
return actionPayload.content.payload;
|
|
32
|
+
}
|
|
33
|
+
async doHandoff(request) {
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
const handOffBuilder = new core_1.HandOffBuilder(request.session);
|
|
36
|
+
handOffBuilder.withAutoAssignOnWaiting(this.handoffAutoAssign);
|
|
37
|
+
if (this.onFinishPayload) {
|
|
38
|
+
handOffBuilder.withOnFinishPayload(this.onFinishPayload);
|
|
39
|
+
}
|
|
40
|
+
if (this.queue) {
|
|
41
|
+
const availabilityData = await (0, conditional_queue_status_1.getQueueAvailability)(this.queue.id);
|
|
42
|
+
const event = {
|
|
43
|
+
event_type: types_1.EventName.handoffSuccess,
|
|
44
|
+
event_data: {
|
|
45
|
+
queue_open: availabilityData.open,
|
|
46
|
+
available_agents: availabilityData.available_agents > 0,
|
|
47
|
+
threshold_reached: availabilityData.availability_threshold_waiting_cases > 0,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
await (0, tracking_1.trackEvent)(request, event);
|
|
51
|
+
handOffBuilder.withQueue(this.queue.id);
|
|
52
|
+
await handOffBuilder.handOff();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
toBotonic() {
|
|
56
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.FlowHandoff = FlowHandoff;
|
|
60
|
+
//# sourceMappingURL=flow-handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-handoff.js","sourceRoot":"","sources":["../../../src/content-fields/flow-handoff.tsx"],"names":[],"mappings":";;;;AAAA,wCAA8C;AAC9C,2EAGwD;AAExD,0DAAyB;AAEzB,iDAA+C;AAE/C,oFAA4E;AAC5E,+DAAyD;AAmBzD,MAAa,WAAY,SAAQ,uCAAiB;IAMhD,MAAM,CAAC,cAAc,CACnB,UAAyB,EACzB,MAAc,EACd,MAAsB;QAEtB,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;QACjD,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;QACjC,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC1E,UAAU,CAAC,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAClD,UAAU,EACV,MAAM,EACN,MAAM,CACP,CAAA;QACD,UAAU,CAAC,iBAAiB,GAAG,UAAU,CAAC,OAAO,CAAC,eAAe,CAAA;QAEjE,OAAO,UAAU,CAAA;IACnB,CAAC;IAEO,MAAM,CAAC,kBAAkB,CAC/B,UAAyB,EACzB,MAAc,EACd,MAAsB;;QAEtB,IAAI,MAAA,UAAU,CAAC,MAAM,0CAAE,EAAE,EAAE;YACzB,MAAM,iBAA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AAA;YACD,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,KAAK,CAAC,CAAA;YAEhC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YACvC,MAAM,cAAc,CAAC,OAAO,EAAE,CAAA;SAC/B;IACH,CAAC;IAED,SAAS;QACP,OAAO,6DAAK,CAAA;IACd,CAAC;CACF;AA3ED,kCA2EC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FlowCarousel } from './flow-carousel';
|
|
2
|
+
import { FlowHandoff } from './flow-handoff';
|
|
2
3
|
import { FlowImage } from './flow-image';
|
|
3
4
|
import { FlowText } from './flow-text';
|
|
4
5
|
import { FlowVideo } from './flow-video';
|
|
@@ -7,4 +8,5 @@ export { ContentFieldsBase } from './content-fields-base';
|
|
|
7
8
|
export { FlowButton } from './flow-button';
|
|
8
9
|
export { FlowElement } from './flow-element';
|
|
9
10
|
export { FlowCarousel, FlowImage, FlowText, FlowVideo, FlowWhatsappButtonList };
|
|
10
|
-
export
|
|
11
|
+
export { FlowHandoff } from './flow-handoff';
|
|
12
|
+
export type FlowContent = FlowCarousel | FlowImage | FlowText | FlowVideo | FlowWhatsappButtonList | FlowHandoff;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowWhatsappButtonList = exports.FlowVideo = exports.FlowText = exports.FlowImage = exports.FlowCarousel = exports.FlowElement = exports.FlowButton = exports.ContentFieldsBase = void 0;
|
|
3
|
+
exports.FlowHandoff = exports.FlowWhatsappButtonList = exports.FlowVideo = exports.FlowText = exports.FlowImage = exports.FlowCarousel = exports.FlowElement = exports.FlowButton = exports.ContentFieldsBase = void 0;
|
|
4
4
|
const flow_carousel_1 = require("./flow-carousel");
|
|
5
5
|
Object.defineProperty(exports, "FlowCarousel", { enumerable: true, get: function () { return flow_carousel_1.FlowCarousel; } });
|
|
6
6
|
const flow_image_1 = require("./flow-image");
|
|
@@ -17,4 +17,6 @@ var flow_button_1 = require("./flow-button");
|
|
|
17
17
|
Object.defineProperty(exports, "FlowButton", { enumerable: true, get: function () { return flow_button_1.FlowButton; } });
|
|
18
18
|
var flow_element_1 = require("./flow-element");
|
|
19
19
|
Object.defineProperty(exports, "FlowElement", { enumerable: true, get: function () { return flow_element_1.FlowElement; } });
|
|
20
|
+
var flow_handoff_1 = require("./flow-handoff");
|
|
21
|
+
Object.defineProperty(exports, "FlowHandoff", { enumerable: true, get: function () { return flow_handoff_1.FlowHandoff; } });
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content-fields/index.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content-fields/index.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAUrC,6FAVA,4BAAY,OAUA;AARrB,6CAAwC;AAQjB,0FARd,sBAAS,OAQc;AAPhC,2CAAsC;AAOJ,yFAPzB,oBAAQ,OAOyB;AAN1C,6CAAwC;AAMI,0FANnC,sBAAS,OAMmC;AALrD,gGAAyF;AAKlC,uGAL9C,kDAAsB,OAK8C;AAH7E,6DAAyD;AAAhD,wHAAA,iBAAiB,OAAA;AAC1B,6CAA0C;AAAjC,yGAAA,UAAU,OAAA;AACnB,+CAA4C;AAAnC,2GAAA,WAAW,OAAA;AAEpB,+CAA4C;AAAnC,2GAAA,WAAW,OAAA"}
|
|
@@ -4,5 +4,14 @@ type ConditionalQueueStatusArgs = {
|
|
|
4
4
|
queue_id: string;
|
|
5
5
|
queue_name: string;
|
|
6
6
|
};
|
|
7
|
-
export declare function conditionalQueueStatus({
|
|
7
|
+
export declare function conditionalQueueStatus({ queue_id, }: ConditionalQueueStatusArgs): Promise<string>;
|
|
8
|
+
interface AvailabilityData {
|
|
9
|
+
available: boolean;
|
|
10
|
+
waiting_cases: number;
|
|
11
|
+
availability_threshold_waiting_cases: number;
|
|
12
|
+
open: boolean;
|
|
13
|
+
name: string;
|
|
14
|
+
available_agents: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function getQueueAvailability(queueId: string): Promise<AvailabilityData>;
|
|
8
17
|
export {};
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.conditionalQueueStatus = void 0;
|
|
3
|
+
exports.getQueueAvailability = exports.conditionalQueueStatus = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
|
-
const helpers_1 = require("../helpers");
|
|
7
6
|
const utils_1 = require("../utils");
|
|
8
7
|
const _HUBTYPE_API_URL_ = (0, utils_1.getWebpackEnvVar)(
|
|
9
8
|
// @ts-ignore
|
|
10
9
|
typeof HUBTYPE_API_URL !== 'undefined' && HUBTYPE_API_URL, 'HUBTYPE_API_URL', 'https://api.hubtype.com');
|
|
11
|
-
async function conditionalQueueStatus({
|
|
12
|
-
const
|
|
10
|
+
async function conditionalQueueStatus({ queue_id, }) {
|
|
11
|
+
const data = await getQueueAvailability(queue_id);
|
|
12
|
+
const isAvailable = data.available;
|
|
13
|
+
return isAvailable ? 'open' : 'closed';
|
|
14
|
+
}
|
|
15
|
+
exports.conditionalQueueStatus = conditionalQueueStatus;
|
|
16
|
+
async function getQueueAvailability(queueId) {
|
|
17
|
+
const response = await axios_1.default.get(`${_HUBTYPE_API_URL_}/v1/queues/${queueId}/availability/`,
|
|
13
18
|
// TODO: Make it configurable in the future
|
|
14
19
|
{
|
|
15
20
|
params: {
|
|
@@ -18,17 +23,7 @@ async function conditionalQueueStatus({ request, queue_id, queue_name, }) {
|
|
|
18
23
|
check_available_agents: false,
|
|
19
24
|
},
|
|
20
25
|
});
|
|
21
|
-
|
|
22
|
-
const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
|
|
23
|
-
if (flowBuilderPlugin.trackEvent) {
|
|
24
|
-
const eventName = `QUEUE_${isAvailable ? 'OPEN' : 'CLOSED'}`;
|
|
25
|
-
const args = {
|
|
26
|
-
queue_id,
|
|
27
|
-
queue_name,
|
|
28
|
-
};
|
|
29
|
-
await flowBuilderPlugin.trackEvent(request, eventName, args);
|
|
30
|
-
}
|
|
31
|
-
return isAvailable ? 'open' : 'closed';
|
|
26
|
+
return response.data;
|
|
32
27
|
}
|
|
33
|
-
exports.
|
|
28
|
+
exports.getQueueAvailability = getQueueAvailability;
|
|
34
29
|
//# sourceMappingURL=conditional-queue-status.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional-queue-status.js","sourceRoot":"","sources":["../../../src/functions/conditional-queue-status.ts"],"names":[],"mappings":";;;;AACA,0DAAyB;
|
|
1
|
+
{"version":3,"file":"conditional-queue-status.js","sourceRoot":"","sources":["../../../src/functions/conditional-queue-status.ts"],"names":[],"mappings":";;;;AACA,0DAAyB;AAGzB,oCAA2C;AAE3C,MAAM,iBAAiB,GAAG,IAAA,wBAAgB;AACxC,aAAa;AACb,OAAO,eAAe,KAAK,WAAW,IAAI,eAAe,EACzD,iBAAiB,EACjB,yBAAyB,CAC1B,CAAA;AAQM,KAAK,UAAU,sBAAsB,CAAC,EAC3C,QAAQ,GACmB;IAC3B,MAAM,IAAI,GAAG,MAAM,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IACjD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAA;IAClC,OAAO,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;AACxC,CAAC;AAND,wDAMC;AAWM,KAAK,UAAU,oBAAoB,CACxC,OAAe;IAEf,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,GAAG,iBAAiB,cAAc,OAAO,gBAAgB;IACzD,2CAA2C;IAC3C;QACE,MAAM,EAAE;YACN,oBAAoB,EAAE,IAAI;YAC1B,mBAAmB,EAAE,KAAK;YAC1B,sBAAsB,EAAE,KAAK;SAC9B;KACF,CACF,CAAA;IACD,OAAO,QAAQ,CAAC,IAAI,CAAA;AACtB,CAAC;AAfD,oDAeC"}
|
package/lib/cjs/helpers.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Plugin } from '@botonic/core';
|
|
2
|
-
import { HtHandoffNode, HtNodeWithContent } from './content-fields/hubtype-fields';
|
|
3
2
|
import BotonicPluginFlowBuilder from './index';
|
|
4
3
|
export declare function getFlowBuilderPlugin(plugins: {
|
|
5
4
|
[id: string]: Plugin;
|
|
6
5
|
}): BotonicPluginFlowBuilder;
|
|
7
|
-
export declare function isHandoffNode(node: HtNodeWithContent): node is HtHandoffNode;
|
package/lib/cjs/helpers.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const hubtype_fields_1 = require("./content-fields/hubtype-fields");
|
|
3
|
+
exports.getFlowBuilderPlugin = void 0;
|
|
5
4
|
const FLOW_BUILDER_PLUGIN_NAME = 'BotonicPluginFlowBuilder';
|
|
6
5
|
function getFlowBuilderPlugin(plugins) {
|
|
7
6
|
const flowBuilderPlugin = Object.values(plugins).find(
|
|
@@ -12,8 +11,4 @@ function getFlowBuilderPlugin(plugins) {
|
|
|
12
11
|
return flowBuilderPlugin;
|
|
13
12
|
}
|
|
14
13
|
exports.getFlowBuilderPlugin = getFlowBuilderPlugin;
|
|
15
|
-
function isHandoffNode(node) {
|
|
16
|
-
return node.type === hubtype_fields_1.HtNodeWithContentType.HANDOFF;
|
|
17
|
-
}
|
|
18
|
-
exports.isHandoffNode = isHandoffNode;
|
|
19
14
|
//# sourceMappingURL=helpers.js.map
|
package/lib/cjs/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;;AAIA,MAAM,wBAAwB,GAAG,0BAA0B,CAAA;AAE3D,SAAgB,oBAAoB,CAAC,OAEpC;IACC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI;IACnD,aAAa;IACb,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAC7B,CAAA;IAC7B,IAAI,CAAC,iBAAiB;QACpB,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAA;IACH,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAZD,oDAYC"}
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Plugin,
|
|
1
|
+
import { Plugin, PluginPreRequest, Session } from '@botonic/core';
|
|
2
2
|
import { ActionRequest } from '@botonic/react';
|
|
3
3
|
import { FlowBuilderApi } from './api';
|
|
4
4
|
import { FlowContent } from './content-fields';
|
|
5
|
-
import { HtFunctionNode,
|
|
5
|
+
import { HtFunctionNode, HtNodeWithContent } from './content-fields/hubtype-fields';
|
|
6
6
|
import { BotonicPluginFlowBuilderOptions } from './types';
|
|
7
7
|
export default class BotonicPluginFlowBuilder implements Plugin {
|
|
8
8
|
readonly options: BotonicPluginFlowBuilderOptions;
|
|
@@ -16,11 +16,9 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
16
16
|
trackEvent?: (request: ActionRequest, eventName: string, args?: Record<string, any>) => Promise<void>;
|
|
17
17
|
constructor(options: BotonicPluginFlowBuilderOptions);
|
|
18
18
|
pre(request: PluginPreRequest): Promise<void>;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
handoffNode?: HtHandoffNode;
|
|
23
|
-
}>;
|
|
19
|
+
getContentsByCode(code: string, locale: string, prevContents?: FlowContent[]): Promise<FlowContent[]>;
|
|
20
|
+
getContentsById(id: string, locale: string, prevContents?: FlowContent[]): Promise<FlowContent[]>;
|
|
21
|
+
getContentsByNode(node: HtNodeWithContent, locale: string, prevContents?: FlowContent[]): Promise<FlowContent[]>;
|
|
24
22
|
private getFlowContent;
|
|
25
23
|
callFunction(functionNode: HtFunctionNode, locale: string): Promise<string>;
|
|
26
24
|
}
|