@botonic/plugin-flow-builder 0.27.8-alpha.2 → 0.28.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/README.md +96 -0
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/action/knowledge-bases.js +4 -3
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/content-fields/flow-handoff.d.ts +1 -0
- package/lib/cjs/content-fields/flow-handoff.js +5 -0
- package/lib/cjs/content-fields/flow-handoff.js.map +1 -1
- package/lib/cjs/content-fields/flow-knowledge-base.d.ts +2 -0
- package/lib/cjs/content-fields/flow-knowledge-base.js +3 -1
- package/lib/cjs/content-fields/flow-knowledge-base.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/knowledge-base.d.ts +1 -0
- package/lib/cjs/index.d.ts +4 -1
- package/lib/cjs/index.js +10 -5
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/user-input/smart-intent.d.ts +1 -0
- package/lib/cjs/user-input/smart-intent.js +6 -1
- package/lib/cjs/user-input/smart-intent.js.map +1 -1
- package/lib/cjs/webview/contents-context.d.ts +2 -2
- package/lib/cjs/webview/contents-context.js +3 -27
- package/lib/cjs/webview/contents-context.js.map +1 -1
- package/lib/cjs/webview/index.d.ts +1 -1
- package/lib/cjs/webview/index.js +2 -2
- package/lib/cjs/webview/index.js.map +1 -1
- package/lib/cjs/webview/types.d.ts +4 -3
- package/lib/cjs/webview/use-webview-contents.d.ts +2 -2
- package/lib/cjs/webview/use-webview-contents.js.map +1 -1
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/action/knowledge-bases.js +4 -3
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/content-fields/flow-handoff.d.ts +1 -0
- package/lib/esm/content-fields/flow-handoff.js +7 -2
- package/lib/esm/content-fields/flow-handoff.js.map +1 -1
- package/lib/esm/content-fields/flow-knowledge-base.d.ts +2 -0
- package/lib/esm/content-fields/flow-knowledge-base.js +3 -1
- package/lib/esm/content-fields/flow-knowledge-base.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/knowledge-base.d.ts +1 -0
- package/lib/esm/index.d.ts +4 -1
- package/lib/esm/index.js +10 -5
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/user-input/smart-intent.d.ts +1 -0
- package/lib/esm/user-input/smart-intent.js +6 -1
- package/lib/esm/user-input/smart-intent.js.map +1 -1
- package/lib/esm/webview/contents-context.d.ts +2 -2
- package/lib/esm/webview/contents-context.js +1 -25
- package/lib/esm/webview/contents-context.js.map +1 -1
- package/lib/esm/webview/index.d.ts +1 -1
- package/lib/esm/webview/index.js +1 -1
- package/lib/esm/webview/index.js.map +1 -1
- package/lib/esm/webview/types.d.ts +4 -3
- package/lib/esm/webview/use-webview-contents.d.ts +2 -2
- package/lib/esm/webview/use-webview-contents.js.map +1 -1
- package/package.json +3 -3
- package/src/action/index.tsx +0 -1
- package/src/action/knowledge-bases.ts +5 -4
- package/src/content-fields/flow-handoff.tsx +20 -1
- package/src/content-fields/flow-knowledge-base.tsx +14 -3
- package/src/content-fields/hubtype-fields/knowledge-base.ts +1 -0
- package/src/index.ts +16 -6
- package/src/user-input/smart-intent.ts +6 -1
- package/src/webview/contents-context.ts +2 -26
- package/src/webview/index.ts +1 -1
- package/src/webview/types.ts +5 -3
- package/src/webview/use-webview-contents.ts +4 -3
|
@@ -5,17 +5,19 @@ export class FlowKnowledgeBase extends ContentFieldsBase {
|
|
|
5
5
|
constructor() {
|
|
6
6
|
super(...arguments);
|
|
7
7
|
this.code = '';
|
|
8
|
+
this.feedbackEnabled = false;
|
|
8
9
|
this.sources = [];
|
|
9
10
|
this.text = '';
|
|
10
11
|
}
|
|
11
12
|
static fromHubtypeCMS(component) {
|
|
12
13
|
const newKnowledgeBase = new FlowKnowledgeBase(component.id);
|
|
13
14
|
newKnowledgeBase.code = component.code;
|
|
15
|
+
newKnowledgeBase.feedbackEnabled = component.content.feedback_enabled;
|
|
14
16
|
newKnowledgeBase.sources = component.content.sources;
|
|
15
17
|
return newKnowledgeBase;
|
|
16
18
|
}
|
|
17
19
|
toBotonic(id) {
|
|
18
|
-
return _jsx(Text, { children: this.text }, id);
|
|
20
|
+
return (_jsx(Text, Object.assign({ feedbackEnabled: this.feedbackEnabled, inferenceId: this.inferenceId }, { children: this.text }), id));
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
//# sourceMappingURL=flow-knowledge-base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-knowledge-base.js","sourceRoot":"","sources":["../../../src/content-fields/flow-knowledge-base.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAGrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAGzD,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IAAxD;;QACS,SAAI,
|
|
1
|
+
{"version":3,"file":"flow-knowledge-base.js","sourceRoot":"","sources":["../../../src/content-fields/flow-knowledge-base.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAGrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAGzD,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IAAxD;;QACS,SAAI,GAAW,EAAE,CAAA;QACjB,oBAAe,GAAY,KAAK,CAAA;QAChC,YAAO,GAAa,EAAE,CAAA;QACtB,SAAI,GAAW,EAAE,CAAA;IAuB1B,CAAC;IApBC,MAAM,CAAC,cAAc,CAAC,SAA8B;QAClD,MAAM,gBAAgB,GAAG,IAAI,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC5D,gBAAgB,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;QACtC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAA;QACrE,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAA;QAEpD,OAAO,gBAAgB,CAAA;IACzB,CAAC;IAED,SAAS,CAAC,EAAU;QAClB,OAAO,CACL,KAAC,IAAI,kBAEH,eAAe,EAAE,IAAI,CAAC,eAAe,EACrC,WAAW,EAAE,IAAI,CAAC,WAAW,gBAE5B,IAAI,CAAC,IAAI,KAJL,EAAE,CAKF,CACR,CAAA;IACH,CAAC;CACF"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Plugin, PluginPreRequest, Session } from '@botonic/core';
|
|
|
2
2
|
import { FlowBuilderApi } from './api';
|
|
3
3
|
import { FlowContent } from './content-fields';
|
|
4
4
|
import { HtNodeWithContent } from './content-fields/hubtype-fields';
|
|
5
|
-
import { BotonicPluginFlowBuilderOptions, KnowledgeBaseFunction, PayloadParamsBase, TrackEventFunction } from './types';
|
|
5
|
+
import { BotonicPluginFlowBuilderOptions, FlowBuilderJSONVersion, KnowledgeBaseFunction, PayloadParamsBase, TrackEventFunction } from './types';
|
|
6
6
|
import { SmartIntentsInferenceConfig } from './user-input/smart-intent';
|
|
7
7
|
export default class BotonicPluginFlowBuilder implements Plugin {
|
|
8
8
|
readonly options: BotonicPluginFlowBuilderOptions;
|
|
@@ -16,7 +16,10 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
16
16
|
trackEvent?: TrackEventFunction;
|
|
17
17
|
getKnowledgeBaseResponse?: KnowledgeBaseFunction;
|
|
18
18
|
smartIntentsConfig: SmartIntentsInferenceConfig;
|
|
19
|
+
jsonVersion: FlowBuilderJSONVersion;
|
|
20
|
+
apiUrl: string;
|
|
19
21
|
constructor(options: BotonicPluginFlowBuilderOptions);
|
|
22
|
+
resolveFlowUrl(request: PluginPreRequest): string;
|
|
20
23
|
pre(request: PluginPreRequest): Promise<void>;
|
|
21
24
|
private updateRequestBeforeRoutes;
|
|
22
25
|
private removeSourceSufix;
|
package/lib/esm/index.js
CHANGED
|
@@ -11,23 +11,28 @@ import { inputHasTextData, resolveGetAccessToken } from './utils';
|
|
|
11
11
|
export default class BotonicPluginFlowBuilder {
|
|
12
12
|
constructor(options) {
|
|
13
13
|
this.options = options;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.flowUrl = `${apiUrl}/flow/${jsonVersion}`;
|
|
14
|
+
this.apiUrl = options.apiUrl || FLOW_BUILDER_API_URL_PROD;
|
|
15
|
+
this.jsonVersion = options.jsonVersion || FlowBuilderJSONVersion.LATEST;
|
|
17
16
|
this.flow = options.flow;
|
|
18
17
|
this.getLocale = options.getLocale;
|
|
19
18
|
this.getAccessToken = resolveGetAccessToken(options);
|
|
20
19
|
this.trackEvent = options.trackEvent;
|
|
21
20
|
this.getKnowledgeBaseResponse = options.getKnowledgeBaseResponse;
|
|
22
|
-
this.smartIntentsConfig = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.smartIntentsConfig), { useLatest: jsonVersion === FlowBuilderJSONVersion.LATEST });
|
|
21
|
+
this.smartIntentsConfig = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.smartIntentsConfig), { useLatest: this.jsonVersion === FlowBuilderJSONVersion.LATEST });
|
|
23
22
|
const customFunctions = options.customFunctions || {};
|
|
24
23
|
this.functions = Object.assign(Object.assign({}, DEFAULT_FUNCTIONS), customFunctions);
|
|
25
24
|
}
|
|
25
|
+
resolveFlowUrl(request) {
|
|
26
|
+
if (request.session.is_test_integration) {
|
|
27
|
+
return `${this.apiUrl}/flow/${FlowBuilderJSONVersion.DRAFT}`;
|
|
28
|
+
}
|
|
29
|
+
return `${this.apiUrl}/flow/${this.jsonVersion}`;
|
|
30
|
+
}
|
|
26
31
|
pre(request) {
|
|
27
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
33
|
this.currentRequest = request;
|
|
29
34
|
this.cmsApi = yield FlowBuilderApi.create({
|
|
30
|
-
url: this.
|
|
35
|
+
url: this.resolveFlowUrl(request),
|
|
31
36
|
flow: this.flow,
|
|
32
37
|
accessToken: this.getAccessToken(request.session),
|
|
33
38
|
request: this.currentRequest,
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAA;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,SAAS,EACT,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,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,EAEL,sBAAsB,GAIvB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACjE,MAAM,CAAC,OAAO,OAAO,wBAAwB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAA;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,SAAS,EACT,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,YAAY,EAEZ,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACT,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM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AAG,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,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AACvD,cAAc,kBAAkB,CAAA;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAEL,sBAAsB,GAEvB,MAAM,SAAS,CAAA;AAChB,cAAc,WAAW,CAAA"}
|
|
@@ -17,5 +17,6 @@ export declare class SmartIntentsApi {
|
|
|
17
17
|
smartIntentsConfig: SmartIntentsInferenceConfig;
|
|
18
18
|
constructor(cmsApi: FlowBuilderApi, currentRequest: ActionRequest, smartIntentsConfig: SmartIntentsInferenceConfig);
|
|
19
19
|
getNodeByInput(): Promise<HtSmartIntentNode | undefined>;
|
|
20
|
+
private resolveUseLatest;
|
|
20
21
|
private getInference;
|
|
21
22
|
}
|
|
@@ -18,7 +18,7 @@ export class SmartIntentsApi {
|
|
|
18
18
|
bot_id: this.currentRequest.session.bot.id,
|
|
19
19
|
text: this.currentRequest.input.data,
|
|
20
20
|
num_smart_intents_to_use: this.smartIntentsConfig.numSmartIntentsToUse,
|
|
21
|
-
use_latest: this.
|
|
21
|
+
use_latest: this.resolveUseLatest(),
|
|
22
22
|
};
|
|
23
23
|
try {
|
|
24
24
|
const response = yield this.getInference(params);
|
|
@@ -39,6 +39,11 @@ export class SmartIntentsApi {
|
|
|
39
39
|
return undefined;
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
+
resolveUseLatest() {
|
|
43
|
+
if (this.currentRequest.session.is_test_integration)
|
|
44
|
+
return false;
|
|
45
|
+
return this.smartIntentsConfig.useLatest;
|
|
46
|
+
}
|
|
42
47
|
getInference(inferenceParams) {
|
|
43
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
49
|
return yield axios({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-intent.js","sourceRoot":"","sources":["../../../src/user-input/smart-intent.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAerD,MAAM,OAAO,eAAe;IAC1B,YACS,MAAsB,EACtB,cAA6B,EAC7B,kBAA+C;QAF/C,WAAM,GAAN,MAAM,CAAgB;QACtB,mBAAc,GAAd,cAAc,CAAe;QAC7B,uBAAkB,GAAlB,kBAAkB,CAA6B;IACrD,CAAC;IAEE,cAAc;;YAClB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI;gBAAE,OAAO,SAAS,CAAA;YACrD,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAA;YAC1D,IAAI,CAAC,gBAAgB,CAAC,MAAM;gBAAE,OAAO,SAAS,CAAA;YAE9C,MAAM,MAAM,GAAG;gBACb,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBAC1C,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI;gBACpC,wBAAwB,EAAE,IAAI,CAAC,kBAAkB,CAAC,oBAAoB;gBACtE,UAAU,EAAE,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"smart-intent.js","sourceRoot":"","sources":["../../../src/user-input/smart-intent.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,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;wBAC9D,uBAAuB,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU;wBAC7D,SAAS,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI;qBAC1C,CAAC,CAAA;oBACF,OAAO,eAAe,CAAA;iBACvB;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;aACjB;YACD,OAAO,SAAS,CAAA;QAClB,CAAC;KAAA;IAEO,gBAAgB;QACtB,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,mBAAmB;YAAE,OAAO,KAAK,CAAA;QACjE,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAA;IAC1C,CAAC;IAEa,YAAY,CACxB,eAA4C;;YAE5C,OAAO,MAAM,KAAK,CAAC;gBACjB,MAAM,EAAE,MAAM;gBACd,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,0CAA0C;gBAC7E,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,aAAa,EAAE;oBACpE,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,KAAK;aACf,CAAC,CAAA;QACJ,CAAC;KAAA;CACF"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { WebviewContentsContextType } from './types';
|
|
3
|
-
export declare const
|
|
2
|
+
import { MapContentsType, WebviewContentsContextType } from './types';
|
|
3
|
+
export declare const createWebviewContentsContext: <T extends MapContentsType>() => import("react").Context<WebviewContentsContextType<T>>;
|
|
@@ -1,29 +1,5 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
|
-
|
|
3
|
-
Define a generic type parameter for your context
|
|
4
|
-
WebviewContentsContext is a function that returns a context object with the type parameter T
|
|
5
|
-
It is necessary to create the context outside the component
|
|
6
|
-
e.g.
|
|
7
|
-
|
|
8
|
-
interface WebviewContents {
|
|
9
|
-
textIntro: string
|
|
10
|
-
image2: string
|
|
11
|
-
headerWebview: string
|
|
12
|
-
image: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const MyWebviewContentsContext = WebviewContentsContext<WebviewContents>()
|
|
16
|
-
|
|
17
|
-
Then you can use it in your component like this:
|
|
18
|
-
<MyWebviewContentsContext.Provider value={webviewContentsContext}>
|
|
19
|
-
...// your components
|
|
20
|
-
</MyWebviewContentsContext.Provider>
|
|
21
|
-
|
|
22
|
-
In your components you can use the context to read contents like this:
|
|
23
|
-
|
|
24
|
-
const { contents } = useContext(MyWebviewContentsContext)
|
|
25
|
-
*/
|
|
26
|
-
export const WebviewContentsContext = () => createContext({
|
|
2
|
+
export const createWebviewContentsContext = () => createContext({
|
|
27
3
|
getTextContent: () => '',
|
|
28
4
|
getImageSrc: () => '',
|
|
29
5
|
setCurrentLocale: () => undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAIrC
|
|
1
|
+
{"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAIrC,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAA8B,EAAE,CAC1E,aAAa,CAAgC;IAC3C,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE;IACrB,gBAAgB,EAAE,GAAG,EAAE,CAAC,SAAS;IACjC,QAAQ,EAAE,EAA6B;CACxC,CAAC,CAAA"}
|
package/lib/esm/webview/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AACjE,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -26,7 +26,8 @@ export interface WebviewImageContent {
|
|
|
26
26
|
}[];
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
export
|
|
29
|
+
export type MapContentsType = Record<string, string>;
|
|
30
|
+
export interface UseWebviewContentsProps<T extends MapContentsType> {
|
|
30
31
|
apiUrl?: string;
|
|
31
32
|
version?: FlowBuilderJSONVersion;
|
|
32
33
|
orgId: string;
|
|
@@ -35,12 +36,12 @@ export interface UseWebviewContentsProps<T> {
|
|
|
35
36
|
locale: string;
|
|
36
37
|
mapContents: Record<keyof T, string>;
|
|
37
38
|
}
|
|
38
|
-
export interface UseWebviewContents<T> {
|
|
39
|
+
export interface UseWebviewContents<T extends MapContentsType> {
|
|
39
40
|
isLoading: boolean;
|
|
40
41
|
error: boolean;
|
|
41
42
|
webviewContentsContext: WebviewContentsContextType<T>;
|
|
42
43
|
}
|
|
43
|
-
export interface WebviewContentsContextType<T> {
|
|
44
|
+
export interface WebviewContentsContextType<T extends MapContentsType> {
|
|
44
45
|
getTextContent: (code: string) => string;
|
|
45
46
|
getImageSrc: (code: string) => string;
|
|
46
47
|
setCurrentLocale: (locale: string) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UseWebviewContents, UseWebviewContentsProps } from './types';
|
|
2
|
-
export declare function useWebviewContents<T>({ apiUrl, version, orgId, botId, webviewId, locale, mapContents, }: UseWebviewContentsProps<T>): UseWebviewContents<T>;
|
|
1
|
+
import { MapContentsType, UseWebviewContents, UseWebviewContentsProps } from './types';
|
|
2
|
+
export declare function useWebviewContents<T extends MapContentsType>({ apiUrl, version, orgId, botId, webviewId, locale, mapContents, }: UseWebviewContentsProps<T>): UseWebviewContents<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-webview-contents.js","sourceRoot":"","sources":["../../../src/webview/use-webview-contents.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"use-webview-contents.js","sourceRoot":"","sources":["../../../src/webview/use-webview-contents.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,EAKL,kBAAkB,GAGnB,MAAM,SAAS,CAAA;AAEhB,MAAM,UAAU,kBAAkB,CAA4B,EAC5D,MAAM,GAAG,yBAAyB,EAClC,OAAO,GAAG,sBAAsB,CAAC,MAAM,EACvC,KAAK,EACL,KAAK,EACL,SAAS,EACT,MAAM,EACN,WAAW,GACgB;IAC3B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,EAAwB,CAAA;IACxE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,EAAyB,CAAA;IAC3E,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CACtC,EAA6B,CAC9B,CAAA;IACD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC1D,MAAM,CAAC,SAAS,EA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plugin-flow-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
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,8 +14,8 @@
|
|
|
14
14
|
"lint_core": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.ts*'"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@botonic/react": "^0.
|
|
18
|
-
"axios": "^1.
|
|
17
|
+
"@botonic/react": "^0.28.0",
|
|
18
|
+
"axios": "^1.7.2",
|
|
19
19
|
"uuid": "^9.0.1"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
package/src/action/index.tsx
CHANGED
|
@@ -71,16 +71,17 @@ async function getContentsWithKnowledgeResponse(
|
|
|
71
71
|
return undefined
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
return
|
|
74
|
+
return updateContentsWithResponse(contents, knowledgeBaseResponse)
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
function
|
|
77
|
+
function updateContentsWithResponse(
|
|
78
78
|
contents: FlowContent[],
|
|
79
|
-
|
|
79
|
+
response: KnowledgeBaseResponse
|
|
80
80
|
): FlowContent[] {
|
|
81
81
|
return contents.map(content => {
|
|
82
82
|
if (content instanceof FlowKnowledgeBase) {
|
|
83
|
-
content.text = answer
|
|
83
|
+
content.text = response.answer
|
|
84
|
+
content.inferenceId = response.inferenceId
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
return content
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { HandOffBuilder, isDev, isWebchat } from '@botonic/core'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ActionRequest,
|
|
4
|
+
Multichannel,
|
|
5
|
+
Text,
|
|
6
|
+
WebchatSettings,
|
|
7
|
+
} from '@botonic/react'
|
|
3
8
|
import React from 'react'
|
|
4
9
|
|
|
5
10
|
import { FlowBuilderApi } from '../api'
|
|
@@ -11,6 +16,7 @@ export class FlowHandoff extends ContentFieldsBase {
|
|
|
11
16
|
public queue?: HtQueueLocale
|
|
12
17
|
public onFinishPayload?: string
|
|
13
18
|
public handoffAutoAssign: boolean
|
|
19
|
+
public isTestIntegration: boolean
|
|
14
20
|
|
|
15
21
|
static fromHubtypeCMS(
|
|
16
22
|
cmsHandoff: HtHandoffNode,
|
|
@@ -51,11 +57,24 @@ export class FlowHandoff extends ContentFieldsBase {
|
|
|
51
57
|
language: request.session.user.extra_data.language,
|
|
52
58
|
country: request.session.user.extra_data.country,
|
|
53
59
|
})
|
|
60
|
+
this.isTestIntegration = request.session.is_test_integration
|
|
54
61
|
await handOffBuilder.handOff()
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
toBotonic(id: string, request: ActionRequest): JSX.Element {
|
|
66
|
+
if (this.isTestIntegration) {
|
|
67
|
+
return (
|
|
68
|
+
<Multichannel key={this.id}>
|
|
69
|
+
<Text>
|
|
70
|
+
_**HANDOFF IN PREVIEW**_ {'\n'}ℹ️ _At this point, a new case would
|
|
71
|
+
be created in {this.queue?.name} queue. To continue with the
|
|
72
|
+
preview, a case resolved scenario will be simulated._
|
|
73
|
+
</Text>
|
|
74
|
+
</Multichannel>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
59
78
|
return isDev(request.session) || isWebchat(request.session) ? (
|
|
60
79
|
<WebchatSettings key={id} enableUserInput={true} />
|
|
61
80
|
) : (
|
|
@@ -5,19 +5,30 @@ import { ContentFieldsBase } from './content-fields-base'
|
|
|
5
5
|
import { HtKnowledgeBaseNode } from './hubtype-fields'
|
|
6
6
|
|
|
7
7
|
export class FlowKnowledgeBase extends ContentFieldsBase {
|
|
8
|
-
public code = ''
|
|
8
|
+
public code: string = ''
|
|
9
|
+
public feedbackEnabled: boolean = false
|
|
9
10
|
public sources: string[] = []
|
|
10
|
-
public text = ''
|
|
11
|
+
public text: string = ''
|
|
12
|
+
public inferenceId?: string
|
|
11
13
|
|
|
12
14
|
static fromHubtypeCMS(component: HtKnowledgeBaseNode): FlowKnowledgeBase {
|
|
13
15
|
const newKnowledgeBase = new FlowKnowledgeBase(component.id)
|
|
14
16
|
newKnowledgeBase.code = component.code
|
|
17
|
+
newKnowledgeBase.feedbackEnabled = component.content.feedback_enabled
|
|
15
18
|
newKnowledgeBase.sources = component.content.sources
|
|
16
19
|
|
|
17
20
|
return newKnowledgeBase
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
toBotonic(id: string): JSX.Element {
|
|
21
|
-
return
|
|
24
|
+
return (
|
|
25
|
+
<Text
|
|
26
|
+
key={id}
|
|
27
|
+
feedbackEnabled={this.feedbackEnabled}
|
|
28
|
+
inferenceId={this.inferenceId}
|
|
29
|
+
>
|
|
30
|
+
{this.text}
|
|
31
|
+
</Text>
|
|
32
|
+
)
|
|
22
33
|
}
|
|
23
34
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Plugin, PluginPreRequest, Session } from '@botonic/core'
|
|
2
2
|
import { ActionRequest } from '@botonic/react'
|
|
3
3
|
import { v4 as uuid } from 'uuid'
|
|
4
4
|
|
|
@@ -53,10 +53,13 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
53
53
|
public getKnowledgeBaseResponse?: KnowledgeBaseFunction
|
|
54
54
|
public smartIntentsConfig: SmartIntentsInferenceConfig
|
|
55
55
|
|
|
56
|
+
// TODO: Rethink how we construct FlowBuilderApi to be simpler
|
|
57
|
+
public jsonVersion: FlowBuilderJSONVersion
|
|
58
|
+
public apiUrl: string
|
|
59
|
+
|
|
56
60
|
constructor(readonly options: BotonicPluginFlowBuilderOptions) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
this.flowUrl = `${apiUrl}/flow/${jsonVersion}`
|
|
61
|
+
this.apiUrl = options.apiUrl || FLOW_BUILDER_API_URL_PROD
|
|
62
|
+
this.jsonVersion = options.jsonVersion || FlowBuilderJSONVersion.LATEST
|
|
60
63
|
this.flow = options.flow
|
|
61
64
|
this.getLocale = options.getLocale
|
|
62
65
|
this.getAccessToken = resolveGetAccessToken(options)
|
|
@@ -64,16 +67,23 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
64
67
|
this.getKnowledgeBaseResponse = options.getKnowledgeBaseResponse
|
|
65
68
|
this.smartIntentsConfig = {
|
|
66
69
|
...options?.smartIntentsConfig,
|
|
67
|
-
useLatest: jsonVersion === FlowBuilderJSONVersion.LATEST,
|
|
70
|
+
useLatest: this.jsonVersion === FlowBuilderJSONVersion.LATEST,
|
|
68
71
|
}
|
|
69
72
|
const customFunctions = options.customFunctions || {}
|
|
70
73
|
this.functions = { ...DEFAULT_FUNCTIONS, ...customFunctions }
|
|
71
74
|
}
|
|
72
75
|
|
|
76
|
+
resolveFlowUrl(request: PluginPreRequest): string {
|
|
77
|
+
if (request.session.is_test_integration) {
|
|
78
|
+
return `${this.apiUrl}/flow/${FlowBuilderJSONVersion.DRAFT}`
|
|
79
|
+
}
|
|
80
|
+
return `${this.apiUrl}/flow/${this.jsonVersion}`
|
|
81
|
+
}
|
|
82
|
+
|
|
73
83
|
async pre(request: PluginPreRequest): Promise<void> {
|
|
74
84
|
this.currentRequest = request
|
|
75
85
|
this.cmsApi = await FlowBuilderApi.create({
|
|
76
|
-
url: this.
|
|
86
|
+
url: this.resolveFlowUrl(request),
|
|
77
87
|
flow: this.flow,
|
|
78
88
|
accessToken: this.getAccessToken(request.session),
|
|
79
89
|
request: this.currentRequest,
|
|
@@ -34,7 +34,7 @@ export class SmartIntentsApi {
|
|
|
34
34
|
bot_id: this.currentRequest.session.bot.id,
|
|
35
35
|
text: this.currentRequest.input.data,
|
|
36
36
|
num_smart_intents_to_use: this.smartIntentsConfig.numSmartIntentsToUse,
|
|
37
|
-
use_latest: this.
|
|
37
|
+
use_latest: this.resolveUseLatest(),
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
try {
|
|
@@ -58,6 +58,11 @@ export class SmartIntentsApi {
|
|
|
58
58
|
return undefined
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
private resolveUseLatest(): boolean {
|
|
62
|
+
if (this.currentRequest.session.is_test_integration) return false
|
|
63
|
+
return this.smartIntentsConfig.useLatest
|
|
64
|
+
}
|
|
65
|
+
|
|
61
66
|
private async getInference(
|
|
62
67
|
inferenceParams: SmartIntentsInferenceParams
|
|
63
68
|
): Promise<SmartIntentResponse> {
|
|
@@ -1,32 +1,8 @@
|
|
|
1
1
|
import { createContext } from 'react'
|
|
2
2
|
|
|
3
|
-
import { WebviewContentsContextType } from './types'
|
|
3
|
+
import { MapContentsType, WebviewContentsContextType } from './types'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
Define a generic type parameter for your context
|
|
7
|
-
WebviewContentsContext is a function that returns a context object with the type parameter T
|
|
8
|
-
It is necessary to create the context outside the component
|
|
9
|
-
e.g.
|
|
10
|
-
|
|
11
|
-
interface WebviewContents {
|
|
12
|
-
textIntro: string
|
|
13
|
-
image2: string
|
|
14
|
-
headerWebview: string
|
|
15
|
-
image: string
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const MyWebviewContentsContext = WebviewContentsContext<WebviewContents>()
|
|
19
|
-
|
|
20
|
-
Then you can use it in your component like this:
|
|
21
|
-
<MyWebviewContentsContext.Provider value={webviewContentsContext}>
|
|
22
|
-
...// your components
|
|
23
|
-
</MyWebviewContentsContext.Provider>
|
|
24
|
-
|
|
25
|
-
In your components you can use the context to read contents like this:
|
|
26
|
-
|
|
27
|
-
const { contents } = useContext(MyWebviewContentsContext)
|
|
28
|
-
*/
|
|
29
|
-
export const WebviewContentsContext = <T>() =>
|
|
5
|
+
export const createWebviewContentsContext = <T extends MapContentsType>() =>
|
|
30
6
|
createContext<WebviewContentsContextType<T>>({
|
|
31
7
|
getTextContent: () => '',
|
|
32
8
|
getImageSrc: () => '',
|
package/src/webview/index.ts
CHANGED
package/src/webview/types.ts
CHANGED
|
@@ -25,7 +25,9 @@ export interface WebviewImageContent {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export
|
|
28
|
+
export type MapContentsType = Record<string, string>
|
|
29
|
+
|
|
30
|
+
export interface UseWebviewContentsProps<T extends MapContentsType> {
|
|
29
31
|
apiUrl?: string
|
|
30
32
|
version?: FlowBuilderJSONVersion
|
|
31
33
|
orgId: string
|
|
@@ -35,13 +37,13 @@ export interface UseWebviewContentsProps<T> {
|
|
|
35
37
|
mapContents: Record<keyof T, string>
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
export interface UseWebviewContents<T> {
|
|
40
|
+
export interface UseWebviewContents<T extends MapContentsType> {
|
|
39
41
|
isLoading: boolean
|
|
40
42
|
error: boolean
|
|
41
43
|
webviewContentsContext: WebviewContentsContextType<T>
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
export interface WebviewContentsContextType<T> {
|
|
46
|
+
export interface WebviewContentsContextType<T extends MapContentsType> {
|
|
45
47
|
getTextContent: (code: string) => string
|
|
46
48
|
getImageSrc: (code: string) => string
|
|
47
49
|
setCurrentLocale: (locale: string) => void
|
|
@@ -4,6 +4,7 @@ import { useEffect, useState } from 'react'
|
|
|
4
4
|
import { FLOW_BUILDER_API_URL_PROD } from '../constants'
|
|
5
5
|
import { FlowBuilderJSONVersion } from '../types'
|
|
6
6
|
import {
|
|
7
|
+
MapContentsType,
|
|
7
8
|
UseWebviewContents,
|
|
8
9
|
UseWebviewContentsProps,
|
|
9
10
|
WebviewContentsResponse,
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
WebviewTextContent,
|
|
13
14
|
} from './types'
|
|
14
15
|
|
|
15
|
-
export function useWebviewContents<T>({
|
|
16
|
+
export function useWebviewContents<T extends MapContentsType>({
|
|
16
17
|
apiUrl = FLOW_BUILDER_API_URL_PROD,
|
|
17
18
|
version = FlowBuilderJSONVersion.LATEST,
|
|
18
19
|
orgId,
|
|
@@ -50,11 +51,11 @@ export function useWebviewContents<T>({
|
|
|
50
51
|
|
|
51
52
|
useEffect(() => {
|
|
52
53
|
if (textContents || imageContents) {
|
|
53
|
-
const contentsObject = {}
|
|
54
|
+
const contentsObject = {}
|
|
54
55
|
for (const [key, value] of Object.entries<string>(mapContents)) {
|
|
55
56
|
contentsObject[key] = getTextContent(value) || getImageSrc(value)
|
|
56
57
|
}
|
|
57
|
-
setContents(contentsObject)
|
|
58
|
+
setContents(contentsObject as Record<keyof T, string>)
|
|
58
59
|
}
|
|
59
60
|
}, [textContents, imageContents, currentLocale])
|
|
60
61
|
|