@botonic/plugin-flow-builder 0.36.0-alpha.0 → 0.36.0-alpha.3
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/ai-agent.js +2 -2
- package/lib/cjs/action/ai-agent.js.map +1 -1
- package/lib/cjs/action/index.d.ts +3 -2
- package/lib/cjs/action/index.js +28 -11
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +1 -1
- package/lib/cjs/content-fields/flow-button.d.ts +3 -0
- package/lib/cjs/content-fields/flow-button.js +1 -1
- package/lib/cjs/content-fields/flow-button.js.map +1 -1
- package/lib/cjs/filters/index.d.ts +12 -0
- package/lib/cjs/filters/index.js +20 -0
- package/lib/cjs/filters/index.js.map +1 -0
- package/lib/cjs/index.d.ts +3 -2
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types.d.ts +6 -5
- package/lib/cjs/types.js.map +1 -1
- package/lib/esm/action/ai-agent.js +2 -2
- package/lib/esm/action/ai-agent.js.map +1 -1
- package/lib/esm/action/index.d.ts +3 -2
- package/lib/esm/action/index.js +31 -14
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/content-fields/flow-button.d.ts +3 -0
- package/lib/esm/content-fields/flow-button.js +2 -2
- package/lib/esm/content-fields/flow-button.js.map +1 -1
- package/lib/esm/filters/index.d.ts +12 -0
- package/lib/esm/filters/index.js +16 -0
- package/lib/esm/filters/index.js.map +1 -0
- package/lib/esm/index.d.ts +3 -2
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types.d.ts +6 -5
- package/lib/esm/types.js.map +1 -1
- package/package.json +2 -2
- package/src/action/ai-agent.ts +2 -2
- package/src/action/index.tsx +50 -14
- package/src/constants.ts +1 -1
- package/src/content-fields/flow-button.tsx +6 -7
- package/src/filters/index.ts +27 -0
- package/src/index.ts +4 -0
- package/src/types.ts +13 -8
|
@@ -19,7 +19,7 @@ function getContentsByAiAgent({ cmsApi, flowBuilderPlugin, request, }) {
|
|
|
19
19
|
name: aiAgentContent.name,
|
|
20
20
|
instructions: aiAgentContent.instructions,
|
|
21
21
|
}));
|
|
22
|
-
if (!aiAgentResponse) {
|
|
22
|
+
if (!aiAgentResponse || aiAgentResponse.role === 'exit') {
|
|
23
23
|
return [];
|
|
24
24
|
}
|
|
25
25
|
return updateContentsWithAiAgentResponse(contents, aiAgentResponse);
|
|
@@ -29,7 +29,7 @@ exports.getContentsByAiAgent = getContentsByAiAgent;
|
|
|
29
29
|
function updateContentsWithAiAgentResponse(contents, aiAgentResponse) {
|
|
30
30
|
return contents.map(content => {
|
|
31
31
|
if (content instanceof flow_ai_agent_1.FlowAiAgent) {
|
|
32
|
-
content.text = aiAgentResponse.
|
|
32
|
+
content.text = aiAgentResponse.content;
|
|
33
33
|
}
|
|
34
34
|
return content;
|
|
35
35
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-agent.js","sourceRoot":"","sources":["../../../src/action/ai-agent.ts"],"names":[],"mappings":";;;;AACA,mEAA6D;AAI7D,SAAsB,oBAAoB,CAAC,EACzC,MAAM,EACN,iBAAiB,EACjB,OAAO,GACY;;;QACnB,MAAM,oBAAoB,GAAG,MAAM,CAAC,uBAAuB,EAAE,CAAA;QAC7D,IAAI,CAAC,oBAAoB,EAAE;YACzB,OAAO,EAAE,CAAA;SACV;QAED,MAAM,QAAQ,GACZ,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAA;QACjE,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAClC,OAAO,CAAC,EAAE,CAAC,OAAO,YAAY,2BAAW,CAC3B,CAAA;QAEhB,IAAI,CAAC,cAAc,EAAE;YACnB,OAAO,EAAE,CAAA;SACV;QAED,MAAM,eAAe,G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CAAC,IAAI,GAAG,eAAe,CAAC,OAAO,CAAA;SACvC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { ActionRequest, RequestContext } from '@botonic/react';
|
|
1
|
+
import { ActionRequest, RequestContext, WebchatSettingsProps } from '@botonic/react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { FlowBuilderApi } from '../api';
|
|
4
4
|
import { FlowContent } from '../content-fields';
|
|
5
5
|
import BotonicPluginFlowBuilder from '../index';
|
|
6
6
|
export type FlowBuilderActionProps = {
|
|
7
7
|
contents: FlowContent[];
|
|
8
|
+
webchatSettingsParams?: WebchatSettingsProps;
|
|
8
9
|
};
|
|
9
10
|
export declare class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
|
|
10
11
|
static contextType: React.Context<ActionRequest>;
|
|
11
12
|
context: React.ContextType<typeof RequestContext>;
|
|
12
13
|
static executeConversationStart(request: ActionRequest): Promise<FlowBuilderActionProps>;
|
|
13
14
|
static botonicInit(request: ActionRequest, contentID?: string): Promise<FlowBuilderActionProps>;
|
|
14
|
-
|
|
15
|
+
static doHandoffAndBotActions(request: ActionRequest, contents: FlowContent[]): Promise<void>;
|
|
15
16
|
render(): JSX.Element | JSX.Element[];
|
|
16
17
|
}
|
|
17
18
|
export declare class FlowBuilderMultichannelAction extends FlowBuilderAction {
|
package/lib/cjs/action/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const react_1 = require("@botonic/react");
|
|
|
8
8
|
const react_2 = tslib_1.__importDefault(require("react"));
|
|
9
9
|
const content_fields_1 = require("../content-fields");
|
|
10
10
|
const flow_bot_action_1 = require("../content-fields/flow-bot-action");
|
|
11
|
+
const filters_1 = require("../filters");
|
|
11
12
|
const helpers_1 = require("../helpers");
|
|
12
13
|
const tracking_1 = require("../tracking");
|
|
13
14
|
const utils_1 = require("../utils");
|
|
@@ -21,17 +22,19 @@ class FlowBuilderAction extends react_2.default.Component {
|
|
|
21
22
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
23
|
const context = getContext(request);
|
|
23
24
|
const contents = yield (0, first_interaction_1.getContentsByFirstInteraction)(context);
|
|
24
|
-
yield (
|
|
25
|
-
yield
|
|
26
|
-
|
|
25
|
+
const filteredContents = yield filterContents(request, contents);
|
|
26
|
+
yield (0, tracking_1.trackFlowContent)(request, filteredContents);
|
|
27
|
+
yield FlowBuilderAction.doHandoffAndBotActions(request, filteredContents);
|
|
28
|
+
return { contents: filteredContents };
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
static botonicInit(request, contentID) {
|
|
30
32
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
33
|
const contents = yield getContents(request, contentID);
|
|
32
|
-
yield (
|
|
33
|
-
yield
|
|
34
|
-
|
|
34
|
+
const filteredContents = yield filterContents(request, contents);
|
|
35
|
+
yield (0, tracking_1.trackFlowContent)(request, filteredContents);
|
|
36
|
+
yield FlowBuilderAction.doHandoffAndBotActions(request, filteredContents);
|
|
37
|
+
return { contents: filteredContents };
|
|
35
38
|
});
|
|
36
39
|
}
|
|
37
40
|
static doHandoffAndBotActions(request, contents) {
|
|
@@ -47,18 +50,17 @@ class FlowBuilderAction extends react_2.default.Component {
|
|
|
47
50
|
});
|
|
48
51
|
}
|
|
49
52
|
render() {
|
|
50
|
-
const { contents } = this.props;
|
|
53
|
+
const { contents, webchatSettingsParams } = this.props;
|
|
51
54
|
const request = this.context;
|
|
52
|
-
return
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [((0, core_1.isWebchat)(request.session) || (0, core_1.isDev)(request.session)) &&
|
|
56
|
+
!!webchatSettingsParams && ((0, jsx_runtime_1.jsx)(react_1.WebchatSettings, Object.assign({}, webchatSettingsParams))), contents.map(content => content.toBotonic(content.id, request))] }));
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
59
|
exports.FlowBuilderAction = FlowBuilderAction;
|
|
56
60
|
FlowBuilderAction.contextType = react_1.RequestContext;
|
|
57
61
|
class FlowBuilderMultichannelAction extends FlowBuilderAction {
|
|
58
62
|
render() {
|
|
59
|
-
|
|
60
|
-
const request = this.context;
|
|
61
|
-
return ((0, jsx_runtime_1.jsx)(react_1.Multichannel, Object.assign({ text: { buttonsAsText: false } }, { children: contents.map(content => content.toBotonic(content.id, request)) })));
|
|
63
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Multichannel, Object.assign({ text: { buttonsAsText: false } }, { children: (0, jsx_runtime_1.jsx)(FlowBuilderAction, Object.assign({}, this.props)) })));
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
exports.FlowBuilderMultichannelAction = FlowBuilderMultichannelAction;
|
|
@@ -92,6 +94,21 @@ function getContents(request, contentID) {
|
|
|
92
94
|
return yield (0, fallback_1.getContentsByFallback)(context);
|
|
93
95
|
});
|
|
94
96
|
}
|
|
97
|
+
function filterContents(request, contents) {
|
|
98
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
|
|
100
|
+
const contentFilters = flowBuilderPlugin.contentFilters;
|
|
101
|
+
const contentFilterExecutor = new filters_1.ContentFilterExecutor({
|
|
102
|
+
filters: contentFilters,
|
|
103
|
+
});
|
|
104
|
+
const filteredContents = [];
|
|
105
|
+
for (const content of contents) {
|
|
106
|
+
const filteredContent = yield contentFilterExecutor.filter(request, content);
|
|
107
|
+
filteredContents.push(filteredContent);
|
|
108
|
+
}
|
|
109
|
+
return filteredContents;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
95
112
|
function getContext(request, contentID) {
|
|
96
113
|
const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
|
|
97
114
|
const cmsApi = flowBuilderPlugin.cmsApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/action/index.tsx"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/action/index.tsx"],"names":[],"mappings":";;;;;AAAA,wCAAmE;AACnE,0CAMuB;AACvB,0DAAyB;AAGzB,sDAA4D;AAC5D,uEAAiE;AACjE,wCAAkD;AAClD,wCAAiD;AAEjD,0CAA8C;AAC9C,oCAA2C;AAC3C,yCAAiD;AACjD,yCAAkD;AAClD,2DAAmE;AACnE,uDAA8D;AAC9D,uCAAgD;AAOhD,MAAa,iBAAkB,SAAQ,eAAK,CAAC,SAAiC;IAI5E,MAAM,CAAO,wBAAwB,CACnC,OAAsB;;YAEtB,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;YACnC,MAAM,QAAQ,GAAG,MAAM,IAAA,iDAA6B,EAAC,OAAO,CAAC,CAAA;YAC7D,MAAM,gBAAgB,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;YAChE,MAAM,IAAA,2BAAgB,EAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;YACjD,MAAM,iBAAiB,CAAC,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;YAEzE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAA;QACvC,CAAC;KAAA;IAED,MAAM,CAAO,WAAW,CACtB,OAAsB,EACtB,SAAkB;;YAElB,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;YACtD,MAAM,gBAAgB,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;YAChE,MAAM,IAAA,2BAAgB,EAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;YACjD,MAAM,iBAAiB,CAAC,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;YAEzE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAA;QACvC,C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BAAiB,CAAC,cAAc,CAAA;QACvD,MAAM,qBAAqB,GAAG,IAAI,+BAAqB,CAAC;YACtD,OAAO,EAAE,cAAc;SACxB,CAAC,CAAA;QAEF,MAAM,gBAAgB,GAAkB,EAAE,CAAA;QAC1C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC9B,MAAM,eAAe,GAAG,MAAM,qBAAqB,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAC5E,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;SACvC;QAED,OAAO,gBAAgB,CAAA;IACzB,CAAC;CAAA;AAUD,SAAS,UAAU,CACjB,OAAsB,EACtB,SAAkB;IAElB,MAAM,iBAAiB,GAAG,IAAA,8BAAoB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAA;IACvC,MAAM,cAAc,GAAG,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAA;IACnE,OAAO;QACL,MAAM;QACN,iBAAiB;QACjB,OAAO;QACP,cAAc;QACd,SAAS;KACV,CAAA;AACH,CAAC"}
|
package/lib/cjs/constants.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export declare const REG_EXP_PATTERN: RegExp;
|
|
|
7
7
|
export declare const UUID_REGEXP: RegExp;
|
|
8
8
|
export declare const MAIN_FLOW_NAME = "Main";
|
|
9
9
|
export declare const KNOWLEDGE_BASE_FLOW_NAME = "Knowledge base";
|
|
10
|
-
export declare const AI_AGENTS_FLOW_NAME = "AI
|
|
10
|
+
export declare const AI_AGENTS_FLOW_NAME = "AI Agents";
|
|
11
11
|
export declare const FALLBACK_FLOW_NAME = "Fallback";
|
package/lib/cjs/constants.js
CHANGED
|
@@ -10,6 +10,6 @@ exports.REG_EXP_PATTERN = /^\/(.*)\/([gimyus]*)$/;
|
|
|
10
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;
|
|
11
11
|
exports.MAIN_FLOW_NAME = 'Main';
|
|
12
12
|
exports.KNOWLEDGE_BASE_FLOW_NAME = 'Knowledge base';
|
|
13
|
-
exports.AI_AGENTS_FLOW_NAME = 'AI
|
|
13
|
+
exports.AI_AGENTS_FLOW_NAME = 'AI Agents';
|
|
14
14
|
exports.FALLBACK_FLOW_NAME = 'Fallback';
|
|
15
15
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { Webview } from '@botonic/react';
|
|
2
3
|
import { FlowBuilderApi } from '../api';
|
|
3
4
|
import { ContentFieldsBase } from './content-fields-base';
|
|
4
5
|
import { HtButton, HtButtonStyle } from './hubtype-fields';
|
|
@@ -6,6 +7,8 @@ export declare class FlowButton extends ContentFieldsBase {
|
|
|
6
7
|
text: string;
|
|
7
8
|
url?: string;
|
|
8
9
|
payload?: string;
|
|
10
|
+
target?: string;
|
|
11
|
+
webview?: Webview;
|
|
9
12
|
static fromHubtypeCMS(cmsButton: HtButton, locale: string, cmsApi: FlowBuilderApi): FlowButton;
|
|
10
13
|
static getUrlId(cmsButton: HtButton, locale: string): string | undefined;
|
|
11
14
|
renderButton(buttonIndex: number, buttonStyle?: HtButtonStyle): JSX.Element;
|
|
@@ -32,7 +32,7 @@ class FlowButton extends content_fields_base_1.ContentFieldsBase {
|
|
|
32
32
|
if (buttonStyle === hubtype_fields_1.HtButtonStyle.QUICK_REPLY) {
|
|
33
33
|
return ((0, jsx_runtime_1.jsx)(react_1.Reply, Object.assign({ payload: this.getButtonPayload(buttonIndex) }, { children: this.text }), this.id));
|
|
34
34
|
}
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)(react_1.Button, Object.assign({ url: this.url, payload: this.getButtonPayload(buttonIndex) }, { children: this.text }), this.id));
|
|
35
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Button, Object.assign({ url: this.url, payload: this.getButtonPayload(buttonIndex), target: this.target, webview: this.webview }, { children: this.text }), this.id));
|
|
36
36
|
}
|
|
37
37
|
getButtonPayload(buttonIndex) {
|
|
38
38
|
return this.payload
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-button.js","sourceRoot":"","sources":["../../../src/content-fields/flow-button.tsx"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"flow-button.js","sourceRoot":"","sources":["../../../src/content-fields/flow-button.tsx"],"names":[],"mappings":";;;;AAAA,0CAAuD;AAIvD,4CAAoD;AACpD,+DAAyD;AACzD,qDAAqE;AAErE,MAAa,UAAW,SAAQ,uCAAiB;IAAjD;;QACS,SAAI,GAAG,EAAE,CAAA;IAyDlB,CAAC;IAnDC,MAAM,CAAC,cAAc,CACnB,SAAmB,EACnB,MAAc,EACd,MAAsB;QAEtB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QAE9C,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC9C,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;QAC7D,IAAI,SAAS,CAAC,MAAM,EAAE;YACpB,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;SACxD;QAED,IAAI,SAAS,CAAC,GAAG,IAAI,KAAK,EAAE;YAC1B,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAY,KAAK,CAAC,CAAA;YACpD,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAA;SACpC;QAED,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,SAAmB,EAAE,MAAc;;QACjD,OAAO,MAAA,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,0CAAE,EAAE,CAAA;IAC7D,CAAC;IAED,YAAY,CAAC,WAAmB,EAAE,WAA2B;QAC3D,IAAI,WAAW,KAAK,8BAAa,CAAC,WAAW,EAAE;YAC7C,OAAO,CACL,uBAAC,aAAK,kBAAe,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,gBAC7D,IAAI,CAAC,IAAI,KADA,IAAI,CAAC,EAAE,CAEX,CACT,CAAA;SACF;QACD,OAAO,CACL,uBAAC,cAAM,kBAEL,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAC3C,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,OAAO,EAAE,IAAI,CAAC,OAAO,gBAEpB,IAAI,CAAC,IAAI,KANL,IAAI,CAAC,EAAE,CAOL,CACV,CAAA;IACH,CAAC;IAEO,gBAAgB,CAAC,WAAmB;QAC1C,OAAO,IAAI,CAAC,OAAO;YACjB,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,GAAG,iCAAqB,GAAG,WAAW,EAAE;YACzD,CAAC,CAAC,SAAS,CAAA;IACf,CAAC;CACF;AA1DD,gCA0DC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BotContext } from '@botonic/core';
|
|
2
|
+
import { FlowContent } from '../content-fields';
|
|
3
|
+
import { ContentFilter } from '../types';
|
|
4
|
+
interface ContentFilterExecutorOptions {
|
|
5
|
+
filters: ContentFilter[];
|
|
6
|
+
}
|
|
7
|
+
export declare class ContentFilterExecutor {
|
|
8
|
+
private filters;
|
|
9
|
+
constructor(options: ContentFilterExecutorOptions);
|
|
10
|
+
filter(request: BotContext, content: FlowContent): Promise<FlowContent>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContentFilterExecutor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
class ContentFilterExecutor {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.filters = [];
|
|
8
|
+
this.filters = options.filters;
|
|
9
|
+
}
|
|
10
|
+
filter(request, content) {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
for (const filter of this.filters) {
|
|
13
|
+
content = yield filter(request, content);
|
|
14
|
+
}
|
|
15
|
+
return content;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.ContentFilterExecutor = ContentFilterExecutor;
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/filters/index.ts"],"names":[],"mappings":";;;;AASA,MAAa,qBAAqB;IAGhC,YAAY,OAAqC;QAFzC,YAAO,GAAoB,EAAE,CAAA;QAGnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;IAChC,CAAC;IAEK,MAAM,CACV,OAAmB,EACnB,OAAoB;;YAEpB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;gBACjC,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;aACzC;YAED,OAAO,OAAO,CAAA;QAChB,CAAC;KAAA;CACF;AAjBD,sDAiBC"}
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Plugin, PluginPreRequest, ResolvedPlugins, Session } from '@botonic/cor
|
|
|
2
2
|
import { FlowBuilderApi } from './api';
|
|
3
3
|
import { FlowContent } from './content-fields';
|
|
4
4
|
import { HtNodeWithContent } from './content-fields/hubtype-fields';
|
|
5
|
-
import { AiAgentFunction, BotonicPluginFlowBuilderOptions, FlowBuilderJSONVersion, InShadowingConfig, KnowledgeBaseFunction, PayloadParamsBase, TrackEventFunction } from './types';
|
|
5
|
+
import { AiAgentFunction, BotonicPluginFlowBuilderOptions, ContentFilter, FlowBuilderJSONVersion, InShadowingConfig, KnowledgeBaseFunction, PayloadParamsBase, TrackEventFunction } from './types';
|
|
6
6
|
import { SmartIntentsInferenceConfig } from './user-input/smart-intent';
|
|
7
7
|
export default class BotonicPluginFlowBuilder implements Plugin {
|
|
8
8
|
cmsApi: FlowBuilderApi;
|
|
@@ -15,6 +15,7 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
15
15
|
getAiAgentResponse?: AiAgentFunction;
|
|
16
16
|
smartIntentsConfig: SmartIntentsInferenceConfig;
|
|
17
17
|
inShadowing: InShadowingConfig;
|
|
18
|
+
contentFilters: ContentFilter[];
|
|
18
19
|
jsonVersion: FlowBuilderJSONVersion;
|
|
19
20
|
apiUrl: string;
|
|
20
21
|
constructor(options: BotonicPluginFlowBuilderOptions<ResolvedPlugins, any>);
|
|
@@ -38,5 +39,5 @@ export * from './action';
|
|
|
38
39
|
export * from './content-fields';
|
|
39
40
|
export { HtBotActionNode } from './content-fields/hubtype-fields';
|
|
40
41
|
export { trackFlowContent } from './tracking';
|
|
41
|
-
export { BotonicPluginFlowBuilderOptions, FlowBuilderJSONVersion, PayloadParamsBase, } from './types';
|
|
42
|
+
export { BotonicPluginFlowBuilderOptions, ContentFilter, FlowBuilderJSONVersion, PayloadParamsBase, } from './types';
|
|
42
43
|
export * from './webview';
|
package/lib/cjs/index.js
CHANGED
|
@@ -30,6 +30,7 @@ class BotonicPluginFlowBuilder {
|
|
|
30
30
|
allowSmartIntents: ((_b = options.inShadowing) === null || _b === void 0 ? void 0 : _b.allowSmartIntents) || false,
|
|
31
31
|
allowKnowledgeBases: ((_c = options.inShadowing) === null || _c === void 0 ? void 0 : _c.allowKnowledgeBases) || false,
|
|
32
32
|
};
|
|
33
|
+
this.contentFilters = options.contentFilters || [];
|
|
33
34
|
}
|
|
34
35
|
resolveFlowUrl(request) {
|
|
35
36
|
if (request.session.is_test_integration) {
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAOA,+BAAmC;AAEnC,+BAAsC;AACtC,2CAIoB;AACpB,qDAYyB;AACzB,oEASwC;AACxC,2CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAOA,+BAAmC;AAEnC,+BAAsC;AACtC,2CAIoB;AACpB,qDAYyB;AACzB,oEASwC;AACxC,2CAA+C;AAC/C,mCASgB;AAChB,6CAAiD;AAEjD,mCAAiE;AAEjE,2EAA2E;AAE3E,MAAqB,wBAAwB;IAiB3C,YAAY,OAA8D;;QACxE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,qCAAyB,CAAA;QACzD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,8BAAsB,CAAC,MAAM,CAAA;QACvE,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACxB,IAAI,CAAC,cAAc,GAAG,IAAA,6BAAqB,EAAC,OAAO,CAAC,cAAc,CAAC,CAAA;QACnE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;QACpC,IAAI,CAAC,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAA;QAChE,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,kBAAkB,mCAClB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,kBAAkB,KAC9B,SAAS,EAAE,IAAI,CAAC,WAAW,KAAK,8BAAsB,CAAC,MAAM,GAC9D,CAAA;QACD,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,EAAE,CAAA;QACrD,IAAI,CAAC,SA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,CAAE,MAAM,CAAA,EAAE;gBACnB,MAAM,IAAI,KAAK,CACb,wDAAwD,cAAc,EAAE,CACzE,CAAA;aACF;YACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAA;QACzB,CAAC;KAAA;IAEO,oBAAoB,CAC1B,IAA2B,EAC3B,MAAc;QAEd,IAAI,eAAe,GAAyB,EAAE,CAAA;QAC9C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,IAAI,QAAQ,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE;gBAC5C,eAAe,GAAG,CAAC,GAAG,eAAe,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;aACtD;YACD,IAAI,MAAM,IAAI,GAAG,EAAE;gBACjB,eAAe,GAAG,CAAC,GAAG,eAAe,EAAE,GAAG,CAAC,CAAA;aAC5C;SACF;QAED,OAAO,eAAe,CAAA;IACxB,CAAC;IAED,gBAAgB,CAA8B,OAAe;QAC3D,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,qBAAS,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAA;QACrE,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,WAAW,CAAC,MAAc;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;CACF;AA9PD,2CA8PC;AAED,mDAAwB;AACxB,2DAAgC;AAEhC,uCAA6C;AAApC,4GAAA,gBAAgB,OAAA;AACzB,iCAKgB;AAFd,+GAAA,sBAAsB,OAAA;AAGxB,oDAAyB"}
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BotContext, PluginPreRequest, ResolvedPlugins } from '@botonic/core';
|
|
2
|
+
import { FlowContent } from './content-fields';
|
|
2
3
|
import { HtFlowBuilderData } from './content-fields/hubtype-fields';
|
|
3
4
|
export interface InShadowingConfig {
|
|
4
5
|
allowKeywords: boolean;
|
|
@@ -18,14 +19,16 @@ export interface BotonicPluginFlowBuilderOptions<TPlugins extends ResolvedPlugin
|
|
|
18
19
|
numSmartIntentsToUse: number;
|
|
19
20
|
};
|
|
20
21
|
inShadowing?: Partial<InShadowingConfig>;
|
|
22
|
+
contentFilters?: ContentFilter<TPlugins, TExtraData>[];
|
|
21
23
|
}
|
|
22
24
|
export type TrackEventFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, eventAction: string, args?: Record<string, any>) => Promise<void>;
|
|
23
25
|
export type KnowledgeBaseFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, sources: string[], instructions: string, messageId: string, memoryLength: number) => Promise<KnowledgeBaseResponse>;
|
|
24
|
-
export type AiAgentFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, aiAgentArgs: AiAgentArgs) => Promise<AiAgentResponse>;
|
|
26
|
+
export type AiAgentFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, aiAgentArgs: AiAgentArgs) => Promise<AiAgentResponse | undefined>;
|
|
25
27
|
export interface AiAgentArgs {
|
|
26
28
|
name: string;
|
|
27
29
|
instructions: string;
|
|
28
30
|
}
|
|
31
|
+
export type ContentFilter<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, content: FlowContent) => Promise<FlowContent> | FlowContent;
|
|
29
32
|
export interface FlowBuilderApiOptions {
|
|
30
33
|
url: string;
|
|
31
34
|
flowUrl: string;
|
|
@@ -49,10 +52,8 @@ export interface KnowledgeBaseResponse {
|
|
|
49
52
|
answer: string;
|
|
50
53
|
}
|
|
51
54
|
export interface AiAgentResponse {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
content: string;
|
|
55
|
-
};
|
|
55
|
+
role: string;
|
|
56
|
+
content: string;
|
|
56
57
|
}
|
|
57
58
|
export interface SmartIntentResponse {
|
|
58
59
|
data: {
|
package/lib/cjs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AA4EA,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;AAC7B,CAAC,EAHW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAG7B;AAED,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;AACnB,CAAC,EAHW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAGjC"}
|
|
@@ -16,7 +16,7 @@ export function getContentsByAiAgent({ cmsApi, flowBuilderPlugin, request, }) {
|
|
|
16
16
|
name: aiAgentContent.name,
|
|
17
17
|
instructions: aiAgentContent.instructions,
|
|
18
18
|
}));
|
|
19
|
-
if (!aiAgentResponse) {
|
|
19
|
+
if (!aiAgentResponse || aiAgentResponse.role === 'exit') {
|
|
20
20
|
return [];
|
|
21
21
|
}
|
|
22
22
|
return updateContentsWithAiAgentResponse(contents, aiAgentResponse);
|
|
@@ -25,7 +25,7 @@ export function getContentsByAiAgent({ cmsApi, flowBuilderPlugin, request, }) {
|
|
|
25
25
|
function updateContentsWithAiAgentResponse(contents, aiAgentResponse) {
|
|
26
26
|
return contents.map(content => {
|
|
27
27
|
if (content instanceof FlowAiAgent) {
|
|
28
|
-
content.text = aiAgentResponse.
|
|
28
|
+
content.text = aiAgentResponse.content;
|
|
29
29
|
}
|
|
30
30
|
return content;
|
|
31
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-agent.js","sourceRoot":"","sources":["../../../src/action/ai-agent.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAI7D,MAAM,UAAgB,oBAAoB,CAAC,EACzC,MAAM,EACN,iBAAiB,EACjB,OAAO,GACY;;;QACnB,MAAM,oBAAoB,GAAG,MAAM,CAAC,uBAAuB,EAAE,CAAA;QAC7D,IAAI,CAAC,oBAAoB,EAAE;YACzB,OAAO,EAAE,CAAA;SACV;QAED,MAAM,QAAQ,GACZ,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAA;QACjE,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAClC,OAAO,CAAC,EAAE,CAAC,OAAO,YAAY,WAAW,CAC3B,CAAA;QAEhB,IAAI,CAAC,cAAc,EAAE;YACnB,OAAO,EAAE,CAAA;SACV;QAED,MAAM,eAAe,GAAG,MAAM,CAAA,MAAA,iBAAiB,CAAC,kBAAkB,kEAChE,OAAO,EACP;YACE,IAAI,EAAE,cAAc,CAAC,IAAI;YACzB,YAAY,EAAE,cAAc,CAAC,YAAY;SAC1C,CACF,CAAA,CAAA;QAED,IAAI,CAAC,eAAe,EAAE;
|
|
1
|
+
{"version":3,"file":"ai-agent.js","sourceRoot":"","sources":["../../../src/action/ai-agent.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAI7D,MAAM,UAAgB,oBAAoB,CAAC,EACzC,MAAM,EACN,iBAAiB,EACjB,OAAO,GACY;;;QACnB,MAAM,oBAAoB,GAAG,MAAM,CAAC,uBAAuB,EAAE,CAAA;QAC7D,IAAI,CAAC,oBAAoB,EAAE;YACzB,OAAO,EAAE,CAAA;SACV;QAED,MAAM,QAAQ,GACZ,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAA;QACjE,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAClC,OAAO,CAAC,EAAE,CAAC,OAAO,YAAY,WAAW,CAC3B,CAAA;QAEhB,IAAI,CAAC,cAAc,EAAE;YACnB,OAAO,EAAE,CAAA;SACV;QAED,MAAM,eAAe,GAAG,MAAM,CAAA,MAAA,iBAAiB,CAAC,kBAAkB,kEAChE,OAAO,EACP;YACE,IAAI,EAAE,cAAc,CAAC,IAAI;YACzB,YAAY,EAAE,cAAc,CAAC,YAAY;SAC1C,CACF,CAAA,CAAA;QAED,IAAI,CAAC,eAAe,IAAI,eAAe,CAAC,IAAI,KAAK,MAAM,EAAE;YACvD,OAAO,EAAE,CAAA;SACV;QAED,OAAO,iCAAiC,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAA;;CACpE;AAED,SAAS,iCAAiC,CACxC,QAAuB,EACvB,eAAgC;IAEhC,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QAC5B,IAAI,OAAO,YAAY,WAAW,EAAE;YAClC,OAAO,CAAC,IAAI,GAAG,eAAe,CAAC,OAAO,CAAA;SACvC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { ActionRequest, RequestContext } from '@botonic/react';
|
|
1
|
+
import { ActionRequest, RequestContext, WebchatSettingsProps } from '@botonic/react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { FlowBuilderApi } from '../api';
|
|
4
4
|
import { FlowContent } from '../content-fields';
|
|
5
5
|
import BotonicPluginFlowBuilder from '../index';
|
|
6
6
|
export type FlowBuilderActionProps = {
|
|
7
7
|
contents: FlowContent[];
|
|
8
|
+
webchatSettingsParams?: WebchatSettingsProps;
|
|
8
9
|
};
|
|
9
10
|
export declare class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
|
|
10
11
|
static contextType: React.Context<ActionRequest>;
|
|
11
12
|
context: React.ContextType<typeof RequestContext>;
|
|
12
13
|
static executeConversationStart(request: ActionRequest): Promise<FlowBuilderActionProps>;
|
|
13
14
|
static botonicInit(request: ActionRequest, contentID?: string): Promise<FlowBuilderActionProps>;
|
|
14
|
-
|
|
15
|
+
static doHandoffAndBotActions(request: ActionRequest, contents: FlowContent[]): Promise<void>;
|
|
15
16
|
render(): JSX.Element | JSX.Element[];
|
|
16
17
|
}
|
|
17
18
|
export declare class FlowBuilderMultichannelAction extends FlowBuilderAction {
|
package/lib/esm/action/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { INPUT } from '@botonic/core';
|
|
4
|
-
import { Multichannel, RequestContext } from '@botonic/react';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { INPUT, isDev, isWebchat } from '@botonic/core';
|
|
4
|
+
import { Multichannel, RequestContext, WebchatSettings, } from '@botonic/react';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { FlowHandoff } from '../content-fields';
|
|
7
7
|
import { FlowBotAction } from '../content-fields/flow-bot-action';
|
|
8
|
+
import { ContentFilterExecutor } from '../filters';
|
|
8
9
|
import { getFlowBuilderPlugin } from '../helpers';
|
|
9
10
|
import { trackFlowContent } from '../tracking';
|
|
10
11
|
import { inputHasTextData } from '../utils';
|
|
@@ -18,17 +19,19 @@ export class FlowBuilderAction extends React.Component {
|
|
|
18
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
20
|
const context = getContext(request);
|
|
20
21
|
const contents = yield getContentsByFirstInteraction(context);
|
|
21
|
-
yield
|
|
22
|
-
yield
|
|
23
|
-
|
|
22
|
+
const filteredContents = yield filterContents(request, contents);
|
|
23
|
+
yield trackFlowContent(request, filteredContents);
|
|
24
|
+
yield FlowBuilderAction.doHandoffAndBotActions(request, filteredContents);
|
|
25
|
+
return { contents: filteredContents };
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
static botonicInit(request, contentID) {
|
|
27
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
30
|
const contents = yield getContents(request, contentID);
|
|
29
|
-
yield
|
|
30
|
-
yield
|
|
31
|
-
|
|
31
|
+
const filteredContents = yield filterContents(request, contents);
|
|
32
|
+
yield trackFlowContent(request, filteredContents);
|
|
33
|
+
yield FlowBuilderAction.doHandoffAndBotActions(request, filteredContents);
|
|
34
|
+
return { contents: filteredContents };
|
|
32
35
|
});
|
|
33
36
|
}
|
|
34
37
|
static doHandoffAndBotActions(request, contents) {
|
|
@@ -44,17 +47,16 @@ export class FlowBuilderAction extends React.Component {
|
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
49
|
render() {
|
|
47
|
-
const { contents } = this.props;
|
|
50
|
+
const { contents, webchatSettingsParams } = this.props;
|
|
48
51
|
const request = this.context;
|
|
49
|
-
return
|
|
52
|
+
return (_jsxs(_Fragment, { children: [(isWebchat(request.session) || isDev(request.session)) &&
|
|
53
|
+
!!webchatSettingsParams && (_jsx(WebchatSettings, Object.assign({}, webchatSettingsParams))), contents.map(content => content.toBotonic(content.id, request))] }));
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
FlowBuilderAction.contextType = RequestContext;
|
|
53
57
|
export class FlowBuilderMultichannelAction extends FlowBuilderAction {
|
|
54
58
|
render() {
|
|
55
|
-
|
|
56
|
-
const request = this.context;
|
|
57
|
-
return (_jsx(Multichannel, Object.assign({ text: { buttonsAsText: false } }, { children: contents.map(content => content.toBotonic(content.id, request)) })));
|
|
59
|
+
return (_jsx(Multichannel, Object.assign({ text: { buttonsAsText: false } }, { children: _jsx(FlowBuilderAction, Object.assign({}, this.props)) })));
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
function getContents(request, contentID) {
|
|
@@ -87,6 +89,21 @@ function getContents(request, contentID) {
|
|
|
87
89
|
return yield getContentsByFallback(context);
|
|
88
90
|
});
|
|
89
91
|
}
|
|
92
|
+
function filterContents(request, contents) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
|
|
95
|
+
const contentFilters = flowBuilderPlugin.contentFilters;
|
|
96
|
+
const contentFilterExecutor = new ContentFilterExecutor({
|
|
97
|
+
filters: contentFilters,
|
|
98
|
+
});
|
|
99
|
+
const filteredContents = [];
|
|
100
|
+
for (const content of contents) {
|
|
101
|
+
const filteredContent = yield contentFilterExecutor.filter(request, content);
|
|
102
|
+
filteredContents.push(filteredContent);
|
|
103
|
+
}
|
|
104
|
+
return filteredContents;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
90
107
|
function getContext(request, contentID) {
|
|
91
108
|
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
|
|
92
109
|
const cmsApi = flowBuilderPlugin.cmsApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/action/index.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/action/index.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAc,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAEL,YAAY,EACZ,cAAc,EACd,eAAe,GAEhB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC3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I,QAAQ,EAAE;YAC9B,MAAM,eAAe,GAAG,MAAM,qBAAqB,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAC5E,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;SACvC;QAED,OAAO,gBAAgB,CAAA;IACzB,CAAC;CAAA;AAUD,SAAS,UAAU,CACjB,OAAsB,EACtB,SAAkB;IAElB,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAA;IACvC,MAAM,cAAc,GAAG,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAA;IACnE,OAAO;QACL,MAAM;QACN,iBAAiB;QACjB,OAAO;QACP,cAAc;QACd,SAAS;KACV,CAAA;AACH,CAAC"}
|
package/lib/esm/constants.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export declare const REG_EXP_PATTERN: RegExp;
|
|
|
7
7
|
export declare const UUID_REGEXP: RegExp;
|
|
8
8
|
export declare const MAIN_FLOW_NAME = "Main";
|
|
9
9
|
export declare const KNOWLEDGE_BASE_FLOW_NAME = "Knowledge base";
|
|
10
|
-
export declare const AI_AGENTS_FLOW_NAME = "AI
|
|
10
|
+
export declare const AI_AGENTS_FLOW_NAME = "AI Agents";
|
|
11
11
|
export declare const FALLBACK_FLOW_NAME = "Fallback";
|
package/lib/esm/constants.js
CHANGED
|
@@ -7,6 +7,6 @@ export const REG_EXP_PATTERN = /^\/(.*)\/([gimyus]*)$/;
|
|
|
7
7
|
export const UUID_REGEXP = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
8
8
|
export const MAIN_FLOW_NAME = 'Main';
|
|
9
9
|
export const KNOWLEDGE_BASE_FLOW_NAME = 'Knowledge base';
|
|
10
|
-
export const AI_AGENTS_FLOW_NAME = 'AI
|
|
10
|
+
export const AI_AGENTS_FLOW_NAME = 'AI Agents';
|
|
11
11
|
export const FALLBACK_FLOW_NAME = 'Fallback';
|
|
12
12
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { Webview } from '@botonic/react';
|
|
2
3
|
import { FlowBuilderApi } from '../api';
|
|
3
4
|
import { ContentFieldsBase } from './content-fields-base';
|
|
4
5
|
import { HtButton, HtButtonStyle } from './hubtype-fields';
|
|
@@ -6,6 +7,8 @@ export declare class FlowButton extends ContentFieldsBase {
|
|
|
6
7
|
text: string;
|
|
7
8
|
url?: string;
|
|
8
9
|
payload?: string;
|
|
10
|
+
target?: string;
|
|
11
|
+
webview?: Webview;
|
|
9
12
|
static fromHubtypeCMS(cmsButton: HtButton, locale: string, cmsApi: FlowBuilderApi): FlowButton;
|
|
10
13
|
static getUrlId(cmsButton: HtButton, locale: string): string | undefined;
|
|
11
14
|
renderButton(buttonIndex: number, buttonStyle?: HtButtonStyle): JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Button, Reply } from '@botonic/react';
|
|
3
3
|
import { SOURCE_INFO_SEPARATOR } from '../constants';
|
|
4
4
|
import { ContentFieldsBase } from './content-fields-base';
|
|
5
|
-
import { HtButtonStyle
|
|
5
|
+
import { HtButtonStyle } from './hubtype-fields';
|
|
6
6
|
export class FlowButton extends ContentFieldsBase {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
@@ -29,7 +29,7 @@ export class FlowButton extends ContentFieldsBase {
|
|
|
29
29
|
if (buttonStyle === HtButtonStyle.QUICK_REPLY) {
|
|
30
30
|
return (_jsx(Reply, Object.assign({ payload: this.getButtonPayload(buttonIndex) }, { children: this.text }), this.id));
|
|
31
31
|
}
|
|
32
|
-
return (_jsx(Button, Object.assign({ url: this.url, payload: this.getButtonPayload(buttonIndex) }, { children: this.text }), this.id));
|
|
32
|
+
return (_jsx(Button, Object.assign({ url: this.url, payload: this.getButtonPayload(buttonIndex), target: this.target, webview: this.webview }, { children: this.text }), this.id));
|
|
33
33
|
}
|
|
34
34
|
getButtonPayload(buttonIndex) {
|
|
35
35
|
return this.payload
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-button.js","sourceRoot":"","sources":["../../../src/content-fields/flow-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"flow-button.js","sourceRoot":"","sources":["../../../src/content-fields/flow-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAW,MAAM,gBAAgB,CAAA;AAIvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAY,aAAa,EAAa,MAAM,kBAAkB,CAAA;AAErE,MAAM,OAAO,UAAW,SAAQ,iBAAiB;IAAjD;;QACS,SAAI,GAAG,EAAE,CAAA;IAyDlB,CAAC;IAnDC,MAAM,CAAC,cAAc,CACnB,SAAmB,EACnB,MAAc,EACd,MAAsB;QAEtB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QAE9C,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC9C,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;QAC7D,IAAI,SAAS,CAAC,MAAM,EAAE;YACpB,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;SACxD;QAED,IAAI,SAAS,CAAC,GAAG,IAAI,KAAK,EAAE;YAC1B,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAY,KAAK,CAAC,CAAA;YACpD,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAA;SACpC;QAED,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,SAAmB,EAAE,MAAc;;QACjD,OAAO,MAAA,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,0CAAE,EAAE,CAAA;IAC7D,CAAC;IAED,YAAY,CAAC,WAAmB,EAAE,WAA2B;QAC3D,IAAI,WAAW,KAAK,aAAa,CAAC,WAAW,EAAE;YAC7C,OAAO,CACL,KAAC,KAAK,kBAAe,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,gBAC7D,IAAI,CAAC,IAAI,KADA,IAAI,CAAC,EAAE,CAEX,CACT,CAAA;SACF;QACD,OAAO,CACL,KAAC,MAAM,kBAEL,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAC3C,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,OAAO,EAAE,IAAI,CAAC,OAAO,gBAEpB,IAAI,CAAC,IAAI,KANL,IAAI,CAAC,EAAE,CAOL,CACV,CAAA;IACH,CAAC;IAEO,gBAAgB,CAAC,WAAmB;QAC1C,OAAO,IAAI,CAAC,OAAO;YACjB,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,GAAG,qBAAqB,GAAG,WAAW,EAAE;YACzD,CAAC,CAAC,SAAS,CAAA;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BotContext } from '@botonic/core';
|
|
2
|
+
import { FlowContent } from '../content-fields';
|
|
3
|
+
import { ContentFilter } from '../types';
|
|
4
|
+
interface ContentFilterExecutorOptions {
|
|
5
|
+
filters: ContentFilter[];
|
|
6
|
+
}
|
|
7
|
+
export declare class ContentFilterExecutor {
|
|
8
|
+
private filters;
|
|
9
|
+
constructor(options: ContentFilterExecutorOptions);
|
|
10
|
+
filter(request: BotContext, content: FlowContent): Promise<FlowContent>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
export class ContentFilterExecutor {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
this.filters = [];
|
|
5
|
+
this.filters = options.filters;
|
|
6
|
+
}
|
|
7
|
+
filter(request, content) {
|
|
8
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
for (const filter of this.filters) {
|
|
10
|
+
content = yield filter(request, content);
|
|
11
|
+
}
|
|
12
|
+
return content;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/filters/index.ts"],"names":[],"mappings":";AASA,MAAM,OAAO,qBAAqB;IAGhC,YAAY,OAAqC;QAFzC,YAAO,GAAoB,EAAE,CAAA;QAGnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;IAChC,CAAC;IAEK,MAAM,CACV,OAAmB,EACnB,OAAoB;;YAEpB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;gBACjC,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;aACzC;YAED,OAAO,OAAO,CAAA;QAChB,CAAC;KAAA;CACF"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Plugin, PluginPreRequest, ResolvedPlugins, Session } from '@botonic/cor
|
|
|
2
2
|
import { FlowBuilderApi } from './api';
|
|
3
3
|
import { FlowContent } from './content-fields';
|
|
4
4
|
import { HtNodeWithContent } from './content-fields/hubtype-fields';
|
|
5
|
-
import { AiAgentFunction, BotonicPluginFlowBuilderOptions, FlowBuilderJSONVersion, InShadowingConfig, KnowledgeBaseFunction, PayloadParamsBase, TrackEventFunction } from './types';
|
|
5
|
+
import { AiAgentFunction, BotonicPluginFlowBuilderOptions, ContentFilter, FlowBuilderJSONVersion, InShadowingConfig, KnowledgeBaseFunction, PayloadParamsBase, TrackEventFunction } from './types';
|
|
6
6
|
import { SmartIntentsInferenceConfig } from './user-input/smart-intent';
|
|
7
7
|
export default class BotonicPluginFlowBuilder implements Plugin {
|
|
8
8
|
cmsApi: FlowBuilderApi;
|
|
@@ -15,6 +15,7 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
15
15
|
getAiAgentResponse?: AiAgentFunction;
|
|
16
16
|
smartIntentsConfig: SmartIntentsInferenceConfig;
|
|
17
17
|
inShadowing: InShadowingConfig;
|
|
18
|
+
contentFilters: ContentFilter[];
|
|
18
19
|
jsonVersion: FlowBuilderJSONVersion;
|
|
19
20
|
apiUrl: string;
|
|
20
21
|
constructor(options: BotonicPluginFlowBuilderOptions<ResolvedPlugins, any>);
|
|
@@ -38,5 +39,5 @@ export * from './action';
|
|
|
38
39
|
export * from './content-fields';
|
|
39
40
|
export { HtBotActionNode } from './content-fields/hubtype-fields';
|
|
40
41
|
export { trackFlowContent } from './tracking';
|
|
41
|
-
export { BotonicPluginFlowBuilderOptions, FlowBuilderJSONVersion, PayloadParamsBase, } from './types';
|
|
42
|
+
export { BotonicPluginFlowBuilderOptions, ContentFilter, FlowBuilderJSONVersion, PayloadParamsBase, } from './types';
|
|
42
43
|
export * from './webview';
|
package/lib/esm/index.js
CHANGED
|
@@ -27,6 +27,7 @@ export default class BotonicPluginFlowBuilder {
|
|
|
27
27
|
allowSmartIntents: ((_b = options.inShadowing) === null || _b === void 0 ? void 0 : _b.allowSmartIntents) || false,
|
|
28
28
|
allowKnowledgeBases: ((_c = options.inShadowing) === null || _c === void 0 ? void 0 : _c.allowKnowledgeBases) || false,
|
|
29
29
|
};
|
|
30
|
+
this.contentFilters = options.contentFilters || [];
|
|
30
31
|
}
|
|
31
32
|
resolveFlowUrl(request) {
|
|
32
33
|
if (request.session.is_test_integration) {
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EACL,yBAAyB,EACzB,SAAS,EACT,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,WAAW,EACX,aAAa,EACb,YAAY,EAEZ,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACT,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAQL,qBAAqB,GACtB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EACL,yBAAyB,EACzB,SAAS,EACT,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,WAAW,EACX,aAAa,EACb,YAAY,EAEZ,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACT,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAQL,qBAAqB,GACtB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAIL,sBAAsB,GAKvB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C,eAAe,GAAG,CAAC,GAAG,eAAe,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;aACtD;YACD,IAAI,MAAM,IAAI,GAAG,EAAE;gBACjB,eAAe,GAAG,CAAC,GAAG,eAAe,EAAE,GAAG,CAAC,CAAA;aAC5C;SACF;QAED,OAAO,eAAe,CAAA;IACxB,CAAC;IAED,gBAAgB,CAA8B,OAAe;QAC3D,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAA;QACrE,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,WAAW,CAAC,MAAc;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;CACF;AAED,cAAc,UAAU,CAAA;AACxB,cAAc,kBAAkB,CAAA;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAGL,sBAAsB,GAEvB,MAAM,SAAS,CAAA;AAChB,cAAc,WAAW,CAAA"}
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BotContext, PluginPreRequest, ResolvedPlugins } from '@botonic/core';
|
|
2
|
+
import { FlowContent } from './content-fields';
|
|
2
3
|
import { HtFlowBuilderData } from './content-fields/hubtype-fields';
|
|
3
4
|
export interface InShadowingConfig {
|
|
4
5
|
allowKeywords: boolean;
|
|
@@ -18,14 +19,16 @@ export interface BotonicPluginFlowBuilderOptions<TPlugins extends ResolvedPlugin
|
|
|
18
19
|
numSmartIntentsToUse: number;
|
|
19
20
|
};
|
|
20
21
|
inShadowing?: Partial<InShadowingConfig>;
|
|
22
|
+
contentFilters?: ContentFilter<TPlugins, TExtraData>[];
|
|
21
23
|
}
|
|
22
24
|
export type TrackEventFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, eventAction: string, args?: Record<string, any>) => Promise<void>;
|
|
23
25
|
export type KnowledgeBaseFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, sources: string[], instructions: string, messageId: string, memoryLength: number) => Promise<KnowledgeBaseResponse>;
|
|
24
|
-
export type AiAgentFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, aiAgentArgs: AiAgentArgs) => Promise<AiAgentResponse>;
|
|
26
|
+
export type AiAgentFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, aiAgentArgs: AiAgentArgs) => Promise<AiAgentResponse | undefined>;
|
|
25
27
|
export interface AiAgentArgs {
|
|
26
28
|
name: string;
|
|
27
29
|
instructions: string;
|
|
28
30
|
}
|
|
31
|
+
export type ContentFilter<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, content: FlowContent) => Promise<FlowContent> | FlowContent;
|
|
29
32
|
export interface FlowBuilderApiOptions {
|
|
30
33
|
url: string;
|
|
31
34
|
flowUrl: string;
|
|
@@ -49,10 +52,8 @@ export interface KnowledgeBaseResponse {
|
|
|
49
52
|
answer: string;
|
|
50
53
|
}
|
|
51
54
|
export interface AiAgentResponse {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
content: string;
|
|
55
|
-
};
|
|
55
|
+
role: string;
|
|
56
|
+
content: string;
|
|
56
57
|
}
|
|
57
58
|
export interface SmartIntentResponse {
|
|
58
59
|
data: {
|
package/lib/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AA4EA,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;AAC7B,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAED,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;AACnB,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/plugin-flow-builder",
|
|
3
|
-
"version": "0.36.0-alpha.
|
|
3
|
+
"version": "0.36.0-alpha.3",
|
|
4
4
|
"main": "./lib/cjs/index.js",
|
|
5
5
|
"module": "./lib/esm/index.js",
|
|
6
6
|
"description": "Use Flow Builder to show your contents",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"lint_core": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.ts*'"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@botonic/react": "^0.
|
|
17
|
+
"@botonic/react": "^0.36.0-alpha.1",
|
|
18
18
|
"axios": "^1.9.0",
|
|
19
19
|
"uuid": "^10.0.0"
|
|
20
20
|
},
|
package/src/action/ai-agent.ts
CHANGED
|
@@ -31,7 +31,7 @@ export async function getContentsByAiAgent({
|
|
|
31
31
|
}
|
|
32
32
|
)
|
|
33
33
|
|
|
34
|
-
if (!aiAgentResponse) {
|
|
34
|
+
if (!aiAgentResponse || aiAgentResponse.role === 'exit') {
|
|
35
35
|
return []
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -44,7 +44,7 @@ function updateContentsWithAiAgentResponse(
|
|
|
44
44
|
): FlowContent[] {
|
|
45
45
|
return contents.map(content => {
|
|
46
46
|
if (content instanceof FlowAiAgent) {
|
|
47
|
-
content.text = aiAgentResponse.
|
|
47
|
+
content.text = aiAgentResponse.content
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
return content
|
package/src/action/index.tsx
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { INPUT } from '@botonic/core'
|
|
2
|
-
import {
|
|
1
|
+
import { BotContext, INPUT, isDev, isWebchat } from '@botonic/core'
|
|
2
|
+
import {
|
|
3
|
+
ActionRequest,
|
|
4
|
+
Multichannel,
|
|
5
|
+
RequestContext,
|
|
6
|
+
WebchatSettings,
|
|
7
|
+
WebchatSettingsProps,
|
|
8
|
+
} from '@botonic/react'
|
|
3
9
|
import React from 'react'
|
|
4
10
|
|
|
5
11
|
import { FlowBuilderApi } from '../api'
|
|
6
12
|
import { FlowContent, FlowHandoff } from '../content-fields'
|
|
7
13
|
import { FlowBotAction } from '../content-fields/flow-bot-action'
|
|
14
|
+
import { ContentFilterExecutor } from '../filters'
|
|
8
15
|
import { getFlowBuilderPlugin } from '../helpers'
|
|
9
16
|
import BotonicPluginFlowBuilder from '../index'
|
|
10
17
|
import { trackFlowContent } from '../tracking'
|
|
@@ -17,6 +24,7 @@ import { getContentsByPayload } from './payload'
|
|
|
17
24
|
|
|
18
25
|
export type FlowBuilderActionProps = {
|
|
19
26
|
contents: FlowContent[]
|
|
27
|
+
webchatSettingsParams?: WebchatSettingsProps
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
export class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
|
|
@@ -28,10 +36,11 @@ export class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
|
|
|
28
36
|
): Promise<FlowBuilderActionProps> {
|
|
29
37
|
const context = getContext(request)
|
|
30
38
|
const contents = await getContentsByFirstInteraction(context)
|
|
31
|
-
await
|
|
32
|
-
await
|
|
39
|
+
const filteredContents = await filterContents(request, contents)
|
|
40
|
+
await trackFlowContent(request, filteredContents)
|
|
41
|
+
await FlowBuilderAction.doHandoffAndBotActions(request, filteredContents)
|
|
33
42
|
|
|
34
|
-
return { contents }
|
|
43
|
+
return { contents: filteredContents }
|
|
35
44
|
}
|
|
36
45
|
|
|
37
46
|
static async botonicInit(
|
|
@@ -39,13 +48,14 @@ export class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
|
|
|
39
48
|
contentID?: string
|
|
40
49
|
): Promise<FlowBuilderActionProps> {
|
|
41
50
|
const contents = await getContents(request, contentID)
|
|
42
|
-
await
|
|
43
|
-
await
|
|
51
|
+
const filteredContents = await filterContents(request, contents)
|
|
52
|
+
await trackFlowContent(request, filteredContents)
|
|
53
|
+
await FlowBuilderAction.doHandoffAndBotActions(request, filteredContents)
|
|
44
54
|
|
|
45
|
-
return { contents }
|
|
55
|
+
return { contents: filteredContents }
|
|
46
56
|
}
|
|
47
57
|
|
|
48
|
-
|
|
58
|
+
static async doHandoffAndBotActions(
|
|
49
59
|
request: ActionRequest,
|
|
50
60
|
contents: FlowContent[]
|
|
51
61
|
) {
|
|
@@ -65,19 +75,26 @@ export class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
|
|
|
65
75
|
}
|
|
66
76
|
|
|
67
77
|
render(): JSX.Element | JSX.Element[] {
|
|
68
|
-
const { contents } = this.props
|
|
78
|
+
const { contents, webchatSettingsParams } = this.props
|
|
69
79
|
const request = this.context as ActionRequest
|
|
70
|
-
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<>
|
|
83
|
+
{(isWebchat(request.session) || isDev(request.session)) &&
|
|
84
|
+
!!webchatSettingsParams && (
|
|
85
|
+
<WebchatSettings {...webchatSettingsParams} />
|
|
86
|
+
)}
|
|
87
|
+
{contents.map(content => content.toBotonic(content.id, request))}
|
|
88
|
+
</>
|
|
89
|
+
)
|
|
71
90
|
}
|
|
72
91
|
}
|
|
73
92
|
|
|
74
93
|
export class FlowBuilderMultichannelAction extends FlowBuilderAction {
|
|
75
94
|
render(): JSX.Element | JSX.Element[] {
|
|
76
|
-
const { contents } = this.props
|
|
77
|
-
const request = this.context as ActionRequest
|
|
78
95
|
return (
|
|
79
96
|
<Multichannel text={{ buttonsAsText: false }}>
|
|
80
|
-
{
|
|
97
|
+
<FlowBuilderAction {...this.props} />
|
|
81
98
|
</Multichannel>
|
|
82
99
|
)
|
|
83
100
|
}
|
|
@@ -120,6 +137,25 @@ async function getContents(
|
|
|
120
137
|
return await getContentsByFallback(context)
|
|
121
138
|
}
|
|
122
139
|
|
|
140
|
+
async function filterContents(
|
|
141
|
+
request: BotContext,
|
|
142
|
+
contents: FlowContent[]
|
|
143
|
+
): Promise<FlowContent[]> {
|
|
144
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
|
|
145
|
+
const contentFilters = flowBuilderPlugin.contentFilters
|
|
146
|
+
const contentFilterExecutor = new ContentFilterExecutor({
|
|
147
|
+
filters: contentFilters,
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
const filteredContents: FlowContent[] = []
|
|
151
|
+
for (const content of contents) {
|
|
152
|
+
const filteredContent = await contentFilterExecutor.filter(request, content)
|
|
153
|
+
filteredContents.push(filteredContent)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return filteredContents
|
|
157
|
+
}
|
|
158
|
+
|
|
123
159
|
export interface FlowBuilderContext {
|
|
124
160
|
cmsApi: FlowBuilderApi
|
|
125
161
|
flowBuilderPlugin: BotonicPluginFlowBuilder
|
package/src/constants.ts
CHANGED
|
@@ -10,5 +10,5 @@ export const UUID_REGEXP =
|
|
|
10
10
|
|
|
11
11
|
export const MAIN_FLOW_NAME = 'Main'
|
|
12
12
|
export const KNOWLEDGE_BASE_FLOW_NAME = 'Knowledge base'
|
|
13
|
-
export const AI_AGENTS_FLOW_NAME = 'AI
|
|
13
|
+
export const AI_AGENTS_FLOW_NAME = 'AI Agents'
|
|
14
14
|
export const FALLBACK_FLOW_NAME = 'Fallback'
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import { Button, Reply } from '@botonic/react'
|
|
1
|
+
import { Button, Reply, Webview } from '@botonic/react'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
4
|
import { FlowBuilderApi } from '../api'
|
|
5
5
|
import { SOURCE_INFO_SEPARATOR } from '../constants'
|
|
6
6
|
import { ContentFieldsBase } from './content-fields-base'
|
|
7
|
-
import {
|
|
8
|
-
HtButton,
|
|
9
|
-
HtButtonStyle,
|
|
10
|
-
HtPayloadNode,
|
|
11
|
-
HtUrlNode,
|
|
12
|
-
} from './hubtype-fields'
|
|
7
|
+
import { HtButton, HtButtonStyle, HtUrlNode } from './hubtype-fields'
|
|
13
8
|
|
|
14
9
|
export class FlowButton extends ContentFieldsBase {
|
|
15
10
|
public text = ''
|
|
16
11
|
public url?: string
|
|
17
12
|
public payload?: string
|
|
13
|
+
public target?: string
|
|
14
|
+
public webview?: Webview
|
|
18
15
|
|
|
19
16
|
static fromHubtypeCMS(
|
|
20
17
|
cmsButton: HtButton,
|
|
@@ -54,6 +51,8 @@ export class FlowButton extends ContentFieldsBase {
|
|
|
54
51
|
key={this.id}
|
|
55
52
|
url={this.url}
|
|
56
53
|
payload={this.getButtonPayload(buttonIndex)}
|
|
54
|
+
target={this.target}
|
|
55
|
+
webview={this.webview}
|
|
57
56
|
>
|
|
58
57
|
{this.text}
|
|
59
58
|
</Button>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BotContext } from '@botonic/core'
|
|
2
|
+
|
|
3
|
+
import { FlowContent } from '../content-fields'
|
|
4
|
+
import { ContentFilter } from '../types'
|
|
5
|
+
|
|
6
|
+
interface ContentFilterExecutorOptions {
|
|
7
|
+
filters: ContentFilter[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class ContentFilterExecutor {
|
|
11
|
+
private filters: ContentFilter[] = []
|
|
12
|
+
|
|
13
|
+
constructor(options: ContentFilterExecutorOptions) {
|
|
14
|
+
this.filters = options.filters
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async filter(
|
|
18
|
+
request: BotContext,
|
|
19
|
+
content: FlowContent
|
|
20
|
+
): Promise<FlowContent> {
|
|
21
|
+
for (const filter of this.filters) {
|
|
22
|
+
content = await filter(request, content)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return content
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -40,6 +40,7 @@ import { DEFAULT_FUNCTIONS } from './functions'
|
|
|
40
40
|
import {
|
|
41
41
|
AiAgentFunction,
|
|
42
42
|
BotonicPluginFlowBuilderOptions,
|
|
43
|
+
ContentFilter,
|
|
43
44
|
FlowBuilderJSONVersion,
|
|
44
45
|
InShadowingConfig,
|
|
45
46
|
KnowledgeBaseFunction,
|
|
@@ -63,6 +64,7 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
63
64
|
public getAiAgentResponse?: AiAgentFunction
|
|
64
65
|
public smartIntentsConfig: SmartIntentsInferenceConfig
|
|
65
66
|
public inShadowing: InShadowingConfig
|
|
67
|
+
public contentFilters: ContentFilter[]
|
|
66
68
|
|
|
67
69
|
// TODO: Rethink how we construct FlowBuilderApi to be simpler
|
|
68
70
|
public jsonVersion: FlowBuilderJSONVersion
|
|
@@ -87,6 +89,7 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
87
89
|
allowSmartIntents: options.inShadowing?.allowSmartIntents || false,
|
|
88
90
|
allowKnowledgeBases: options.inShadowing?.allowKnowledgeBases || false,
|
|
89
91
|
}
|
|
92
|
+
this.contentFilters = options.contentFilters || []
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
resolveFlowUrl(request: PluginPreRequest): string {
|
|
@@ -312,6 +315,7 @@ export { HtBotActionNode } from './content-fields/hubtype-fields'
|
|
|
312
315
|
export { trackFlowContent } from './tracking'
|
|
313
316
|
export {
|
|
314
317
|
BotonicPluginFlowBuilderOptions,
|
|
318
|
+
ContentFilter,
|
|
315
319
|
FlowBuilderJSONVersion,
|
|
316
320
|
PayloadParamsBase,
|
|
317
321
|
} from './types'
|
package/src/types.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BotContext,
|
|
3
|
-
PluginPreRequest,
|
|
4
|
-
ResolvedPlugins,
|
|
5
|
-
Session,
|
|
6
|
-
} from '@botonic/core'
|
|
1
|
+
import { BotContext, PluginPreRequest, ResolvedPlugins } from '@botonic/core'
|
|
7
2
|
|
|
3
|
+
import { FlowContent } from './content-fields'
|
|
8
4
|
import { HtFlowBuilderData } from './content-fields/hubtype-fields'
|
|
9
5
|
|
|
10
6
|
export interface InShadowingConfig {
|
|
@@ -27,6 +23,7 @@ export interface BotonicPluginFlowBuilderOptions<
|
|
|
27
23
|
getAiAgentResponse?: AiAgentFunction<TPlugins, TExtraData>
|
|
28
24
|
smartIntentsConfig?: { numSmartIntentsToUse: number }
|
|
29
25
|
inShadowing?: Partial<InShadowingConfig>
|
|
26
|
+
contentFilters?: ContentFilter<TPlugins, TExtraData>[]
|
|
30
27
|
}
|
|
31
28
|
|
|
32
29
|
export type TrackEventFunction<
|
|
@@ -55,12 +52,19 @@ export type AiAgentFunction<
|
|
|
55
52
|
> = (
|
|
56
53
|
request: BotContext<TPlugins, TExtraData>,
|
|
57
54
|
aiAgentArgs: AiAgentArgs
|
|
58
|
-
) => Promise<AiAgentResponse>
|
|
55
|
+
) => Promise<AiAgentResponse | undefined>
|
|
59
56
|
|
|
60
57
|
export interface AiAgentArgs {
|
|
61
58
|
name: string
|
|
62
59
|
instructions: string
|
|
63
60
|
}
|
|
61
|
+
export type ContentFilter<
|
|
62
|
+
TPlugins extends ResolvedPlugins = ResolvedPlugins,
|
|
63
|
+
TExtraData = any,
|
|
64
|
+
> = (
|
|
65
|
+
request: BotContext<TPlugins, TExtraData>,
|
|
66
|
+
content: FlowContent
|
|
67
|
+
) => Promise<FlowContent> | FlowContent
|
|
64
68
|
|
|
65
69
|
export interface FlowBuilderApiOptions {
|
|
66
70
|
url: string
|
|
@@ -89,7 +93,8 @@ export interface KnowledgeBaseResponse {
|
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
export interface AiAgentResponse {
|
|
92
|
-
|
|
96
|
+
role: string
|
|
97
|
+
content: string
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
export interface SmartIntentResponse {
|