@botonic/plugin-flow-builder 0.21.0-alpha.9 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/action.js +21 -32
- package/lib/cjs/action.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 +6 -1
- package/lib/cjs/content-fields/content-fields-base.js.map +1 -1
- package/lib/cjs/content-fields/flow-button.js +4 -2
- package/lib/cjs/content-fields/flow-button.js.map +1 -1
- package/lib/cjs/content-fields/flow-video.d.ts +8 -0
- package/lib/cjs/content-fields/flow-video.js +26 -0
- package/lib/cjs/content-fields/flow-video.js.map +1 -0
- package/lib/cjs/content-fields/index.d.ts +1 -0
- package/lib/cjs/content-fields/index.js +3 -1
- package/lib/cjs/content-fields/index.js.map +1 -1
- package/lib/cjs/content-fields/types.d.ts +2 -1
- package/lib/cjs/flow-builder-models.d.ts +26 -4
- package/lib/cjs/flow-builder-models.js +2 -0
- package/lib/cjs/flow-builder-models.js.map +1 -1
- package/lib/cjs/handoff.d.ts +2 -1
- package/lib/cjs/handoff.js +21 -14
- package/lib/cjs/handoff.js.map +1 -1
- package/lib/cjs/helpers.d.ts +5 -0
- package/lib/cjs/helpers.js +14 -0
- package/lib/cjs/helpers.js.map +1 -0
- package/lib/cjs/index.d.ts +8 -3
- package/lib/cjs/index.js +35 -17
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/action.js +22 -33
- package/lib/esm/action.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 +6 -1
- package/lib/esm/content-fields/content-fields-base.js.map +1 -1
- package/lib/esm/content-fields/flow-button.js +4 -2
- package/lib/esm/content-fields/flow-button.js.map +1 -1
- package/lib/esm/content-fields/flow-video.d.ts +8 -0
- package/lib/esm/content-fields/flow-video.js +21 -0
- package/lib/esm/content-fields/flow-video.js.map +1 -0
- package/lib/esm/content-fields/index.d.ts +1 -0
- package/lib/esm/content-fields/index.js +1 -0
- package/lib/esm/content-fields/index.js.map +1 -1
- package/lib/esm/content-fields/types.d.ts +2 -1
- package/lib/esm/flow-builder-models.d.ts +26 -4
- package/lib/esm/flow-builder-models.js +2 -0
- package/lib/esm/flow-builder-models.js.map +1 -1
- package/lib/esm/handoff.d.ts +2 -1
- package/lib/esm/handoff.js +21 -14
- package/lib/esm/handoff.js.map +1 -1
- package/lib/esm/helpers.d.ts +5 -0
- package/lib/esm/helpers.js +10 -0
- package/lib/esm/helpers.js.map +1 -0
- package/lib/esm/index.d.ts +8 -3
- package/lib/esm/index.js +36 -18
- package/lib/esm/index.js.map +1 -1
- package/package.json +3 -4
- package/src/action.tsx +25 -35
- package/src/content-fields/content-fields-base.ts +11 -2
- package/src/content-fields/flow-button.tsx +3 -1
- package/src/content-fields/flow-video.tsx +22 -0
- package/src/content-fields/index.ts +1 -0
- package/src/content-fields/types.ts +2 -1
- package/src/flow-builder-models.ts +30 -2
- package/src/handoff.ts +25 -16
- package/src/helpers.ts +18 -0
- package/src/index.ts +52 -21
package/lib/cjs/action.js
CHANGED
|
@@ -5,47 +5,36 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = require("@botonic/react");
|
|
6
6
|
const react_2 = tslib_1.__importDefault(require("react"));
|
|
7
7
|
const handoff_1 = require("./handoff");
|
|
8
|
+
const helpers_1 = require("./helpers");
|
|
8
9
|
class FlowBuilderAction extends react_2.default.Component {
|
|
9
10
|
static async botonicInit(request) {
|
|
10
|
-
const flowBuilderPlugin = request.plugins
|
|
11
|
-
.hubtypeFlowBuilder;
|
|
11
|
+
const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
|
|
12
12
|
const locale = flowBuilderPlugin.getLocale(request.session);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
const payload = request.input.payload;
|
|
14
|
+
let targetContentId = payload;
|
|
15
|
+
if (!payload && request.session.is_first_interaction) {
|
|
16
|
+
targetContentId = await flowBuilderPlugin.getStartId();
|
|
17
|
+
}
|
|
18
|
+
if (!payload) {
|
|
19
|
+
const intentPayload = await flowBuilderPlugin.getPayloadByIntent(request.input, locale);
|
|
20
|
+
if (intentPayload)
|
|
21
|
+
targetContentId = intentPayload;
|
|
21
22
|
const keywordPayload = await flowBuilderPlugin.getPayloadByKeyword(request.input, locale);
|
|
22
|
-
if (keywordPayload)
|
|
23
|
-
|
|
24
|
-
}
|
|
23
|
+
if (keywordPayload)
|
|
24
|
+
targetContentId = keywordPayload;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (content.length === 0) {
|
|
29
|
-
const handoffParams = {
|
|
30
|
-
queue: 'Test',
|
|
31
|
-
agentEmail: 'test@gmail.com',
|
|
32
|
-
note: 'This is a note that will be attached to the case as a reminder',
|
|
33
|
-
};
|
|
34
|
-
await (0, handoff_1.doHandoff)(request, handoffParams.queue, handoffParams.note);
|
|
35
|
-
const isHandoff = true;
|
|
36
|
-
return { isHandoff };
|
|
26
|
+
if (!targetContentId) {
|
|
27
|
+
targetContentId = await flowBuilderPlugin.getFallbackId();
|
|
37
28
|
}
|
|
38
|
-
|
|
29
|
+
const { contents, handoffNode } = await flowBuilderPlugin.getContents(targetContentId, locale);
|
|
30
|
+
if (handoffNode)
|
|
31
|
+
await (0, handoff_1.doHandoff)(request, locale, handoffNode);
|
|
32
|
+
return { contents, handoffNode };
|
|
39
33
|
}
|
|
40
34
|
render() {
|
|
41
35
|
// @ts-ignore
|
|
42
|
-
const {
|
|
43
|
-
|
|
44
|
-
return react_2.default.createElement(react_1.Text, null, "You are being transferred to an agent!");
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
return contents.map((content, index) => content.toBotonic(index));
|
|
48
|
-
}
|
|
36
|
+
const { contents, handoffNode } = this.props;
|
|
37
|
+
return contents.map((content, index) => content.toBotonic(index));
|
|
49
38
|
}
|
|
50
39
|
}
|
|
51
40
|
exports.FlowBuilderAction = FlowBuilderAction;
|
package/lib/cjs/action.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/action.tsx"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/action.tsx"],"names":[],"mappings":";;;;AAAA,0CAA8D;AAC9D,0DAAyB;AAGzB,uCAAqC;AACrC,uCAAgD;AAOhD,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;QAC3D,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAA;QACrC,IAAI,eAAe,GAAuB,OAAO,CAAA;QACjD,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,oBAAoB,EAAE;YACpD,eAAe,GAAG,MAAM,iBAAiB,CAAC,UAAU,EAAE,CAAA;SACvD;QACD,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,kBAAkB,CAC9D,OAAO,CAAC,KAAK,EACb,MAAM,CACP,CAAA;YACD,IAAI,aAAa;gBAAE,eAAe,GAAG,aAAa,CAAA;YAClD,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC,mBAAmB,CAChE,OAAO,CAAC,KAAK,EACb,MAAM,CACP,CAAA;YACD,IAAI,cAAc;gBAAE,eAAe,GAAG,cAAc,CAAA;SACrD;QACD,IAAI,CAAC,eAAe,EAAE;YACpB,eAAe,GAAG,MAAM,iBAAiB,CAAC,aAAa,EAAE,CAAA;SAC1D;QAED,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,iBAAiB,CAAC,WAAW,CACnE,eAAe,EACf,MAAM,CACP,CAAA;QAED,IAAI,WAAW;YAAE,MAAM,IAAA,mBAAS,EAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;QAE9D,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;IAClC,CAAC;IAED,MAAM;QACJ,aAAa;QACb,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAC5C,OAAO,QAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;IACpE,CAAC;;AAzCH,8CA0CC;AAzCQ,6BAAW,GAAG,sBAAc,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { MediaFileLocale, TextLocale } from '../flow-builder-models';
|
|
1
|
+
import { MediaFileLocale, TextLocale, VideoLocale } from '../flow-builder-models';
|
|
2
2
|
export declare abstract class ContentFieldsBase {
|
|
3
3
|
private readonly id;
|
|
4
4
|
constructor(id: string);
|
|
5
5
|
static getTextByLocale(locale: string, text: TextLocale[]): string;
|
|
6
6
|
static getImageByLocale(locale: string, image: MediaFileLocale[]): string;
|
|
7
|
+
static getVideoByLocale(locale: string, video: VideoLocale[]): string;
|
|
7
8
|
}
|
|
@@ -12,9 +12,14 @@ class ContentFieldsBase {
|
|
|
12
12
|
}
|
|
13
13
|
static getImageByLocale(locale, image) {
|
|
14
14
|
var _a;
|
|
15
|
-
const result = image.find(
|
|
15
|
+
const result = image.find(i => i.locale === locale);
|
|
16
16
|
return (_a = result === null || result === void 0 ? void 0 : result.file) !== null && _a !== void 0 ? _a : '';
|
|
17
17
|
}
|
|
18
|
+
static getVideoByLocale(locale, video) {
|
|
19
|
+
var _a;
|
|
20
|
+
const result = video.find(v => v.locale === locale);
|
|
21
|
+
return (_a = result === null || result === void 0 ? void 0 : result.url) !== null && _a !== void 0 ? _a : '';
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
exports.ContentFieldsBase = ContentFieldsBase;
|
|
20
25
|
//# 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":";;;AAMA,MAAsB,iBAAiB;IACrC,YAA6B,EAAU;QAAV,OAAE,GAAF,EAAE,CAAQ;IAAG,CAAC;IAE3C,MAAM,CAAC,eAAe,CAAC,MAAc,EAAE,IAAkB;;QACvD,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,KAAwB;;QAC9D,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,KAAoB;;QAC1D,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;CACF;AAjBD,8CAiBC"}
|
|
@@ -12,10 +12,12 @@ class FlowButton extends content_fields_base_1.ContentFieldsBase {
|
|
|
12
12
|
this.text = '';
|
|
13
13
|
}
|
|
14
14
|
static fromHubtypeCMS(component, locale) {
|
|
15
|
-
var _a;
|
|
15
|
+
var _a, _b;
|
|
16
16
|
const newButton = new FlowButton(component.id);
|
|
17
17
|
newButton.text = FlowButton.getTextByLocale(locale, component.text);
|
|
18
|
-
newButton.payload =
|
|
18
|
+
newButton.payload = component.target
|
|
19
|
+
? component.target.id
|
|
20
|
+
: (_b = (_a = component.payload) === null || _a === void 0 ? void 0 : _a.find(payload => payload.locale === locale)) === null || _b === void 0 ? void 0 : _b.id;
|
|
19
21
|
if (component.url) {
|
|
20
22
|
const urlButton = component.url.find(url => url.locale === locale);
|
|
21
23
|
if (urlButton)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-button.js","sourceRoot":"","sources":["../../../src/content-fields/flow-button.tsx"],"names":[],"mappings":";;;;AAAA,0CAA8C;AAC9C,0DAAyB;AAEzB,gEAAwE;AACxE,+DAAyD;AAEzD,MAAa,UAAW,SAAQ,uCAAiB;IAAjD;;QACS,SAAI,GAAG,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"flow-button.js","sourceRoot":"","sources":["../../../src/content-fields/flow-button.tsx"],"names":[],"mappings":";;;;AAAA,0CAA8C;AAC9C,0DAAyB;AAEzB,gEAAwE;AACxE,+DAAyD;AAEzD,MAAa,UAAW,SAAQ,uCAAiB;IAAjD;;QACS,SAAI,GAAG,EAAE,CAAA;IAoClB,CAAC;IAhCC,MAAM,CAAC,cAAc,CAAC,SAAmB,EAAE,MAAc;;QACvD,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC9C,SAAS,CAAC,IAAI,GAAG,UAAU,CAAC,eAA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
+
export declare class FlowVideo extends ContentFieldsBase {
|
|
4
|
+
src: string;
|
|
5
|
+
code: string;
|
|
6
|
+
static fromHubtypeCMS(component: VideoNode, locale: string): FlowVideo;
|
|
7
|
+
toBotonic(index: number): JSX.Element;
|
|
8
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowVideo = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = require("@botonic/react");
|
|
6
|
+
const react_2 = tslib_1.__importDefault(require("react"));
|
|
7
|
+
const content_fields_base_1 = require("./content-fields-base");
|
|
8
|
+
class FlowVideo extends content_fields_base_1.ContentFieldsBase {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.src = '';
|
|
12
|
+
this.code = '';
|
|
13
|
+
}
|
|
14
|
+
static fromHubtypeCMS(component, locale) {
|
|
15
|
+
const newVideo = new FlowVideo(component.id);
|
|
16
|
+
newVideo.code = component.code;
|
|
17
|
+
newVideo.src = this.getVideoByLocale(locale, component.content.video);
|
|
18
|
+
return newVideo;
|
|
19
|
+
}
|
|
20
|
+
toBotonic(index) {
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
return react_2.default.createElement(react_1.Video, { key: index, src: this.src });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.FlowVideo = FlowVideo;
|
|
26
|
+
//# sourceMappingURL=flow-video.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-video.js","sourceRoot":"","sources":["../../../src/content-fields/flow-video.tsx"],"names":[],"mappings":";;;;AAAA,0CAAsC;AACtC,0DAAyB;AAGzB,+DAAyD;AAEzD,MAAa,SAAU,SAAQ,uCAAiB;IAAhD;;QACS,QAAG,GAAG,EAAE,CAAA;QACR,SAAI,GAAG,EAAE,CAAA;IAalB,CAAC;IAXC,MAAM,CAAC,cAAc,CAAC,SAAoB,EAAE,MAAc;QACxD,MAAM,QAAQ,GAAG,IAAI,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC5C,QAAQ,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;QAC9B,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACrE,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,SAAS,CAAC,KAAa;QACrB,aAAa;QACb,OAAO,8BAAC,aAAK,IAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,GAAI,CAAA;IAC7C,CAAC;CACF;AAfD,8BAeC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowText = exports.FlowImage = exports.FlowElement = exports.FlowCarousel = exports.FlowButton = exports.ContentFieldsBase = void 0;
|
|
3
|
+
exports.FlowVideo = exports.FlowText = exports.FlowImage = exports.FlowElement = exports.FlowCarousel = exports.FlowButton = exports.ContentFieldsBase = void 0;
|
|
4
4
|
var content_fields_base_1 = require("./content-fields-base");
|
|
5
5
|
Object.defineProperty(exports, "ContentFieldsBase", { enumerable: true, get: function () { return content_fields_base_1.ContentFieldsBase; } });
|
|
6
6
|
var flow_button_1 = require("./flow-button");
|
|
@@ -13,4 +13,6 @@ var flow_image_1 = require("./flow-image");
|
|
|
13
13
|
Object.defineProperty(exports, "FlowImage", { enumerable: true, get: function () { return flow_image_1.FlowImage; } });
|
|
14
14
|
var flow_text_1 = require("./flow-text");
|
|
15
15
|
Object.defineProperty(exports, "FlowText", { enumerable: true, get: function () { return flow_text_1.FlowText; } });
|
|
16
|
+
var flow_video_1 = require("./flow-video");
|
|
17
|
+
Object.defineProperty(exports, "FlowVideo", { enumerable: true, get: function () { return flow_video_1.FlowVideo; } });
|
|
16
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content-fields/index.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;AAAhD,wHAAA,iBAAiB,OAAA;AAC1B,6CAA0C;AAAjC,yGAAA,UAAU,OAAA;AACnB,iDAA8C;AAArC,6GAAA,YAAY,OAAA;AACrB,+CAA4C;AAAnC,2GAAA,WAAW,OAAA;AACpB,2CAAwC;AAA/B,uGAAA,SAAS,OAAA;AAClB,yCAAsC;AAA7B,qGAAA,QAAQ,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content-fields/index.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;AAAhD,wHAAA,iBAAiB,OAAA;AAC1B,6CAA0C;AAAjC,yGAAA,UAAU,OAAA;AACnB,iDAA8C;AAArC,6GAAA,YAAY,OAAA;AACrB,+CAA4C;AAAnC,2GAAA,WAAW,OAAA;AACpB,2CAAwC;AAA/B,uGAAA,SAAS,OAAA;AAClB,yCAAsC;AAA7B,qGAAA,QAAQ,OAAA;AACjB,2CAAwC;AAA/B,uGAAA,SAAS,OAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FlowCarousel } from './flow-carousel';
|
|
2
2
|
import { FlowImage } from './flow-image';
|
|
3
3
|
import { FlowText } from './flow-text';
|
|
4
|
-
|
|
4
|
+
import { FlowVideo } from './flow-video';
|
|
5
|
+
export type FlowContent = FlowText | FlowImage | FlowCarousel | FlowVideo;
|
|
@@ -16,7 +16,9 @@ export declare enum NodeType {
|
|
|
16
16
|
START_UP = "start-up",
|
|
17
17
|
URL = "url",
|
|
18
18
|
PAYLOAD = "payload",
|
|
19
|
-
FUNCTION = "function"
|
|
19
|
+
FUNCTION = "function",
|
|
20
|
+
FALLBACK = "fallback",
|
|
21
|
+
VIDEO = "video"
|
|
20
22
|
}
|
|
21
23
|
export interface BaseNode {
|
|
22
24
|
id: string;
|
|
@@ -57,8 +59,8 @@ export interface Button {
|
|
|
57
59
|
text: TextLocale[];
|
|
58
60
|
target?: NodeLink;
|
|
59
61
|
hidden: string;
|
|
60
|
-
url?: UrlLocale;
|
|
61
|
-
payload?: PayloadLocale;
|
|
62
|
+
url?: UrlLocale[];
|
|
63
|
+
payload?: PayloadLocale[];
|
|
62
64
|
}
|
|
63
65
|
export interface TextNodeContent {
|
|
64
66
|
text: TextLocale[];
|
|
@@ -171,4 +173,24 @@ export interface FunctionNode extends Node {
|
|
|
171
173
|
type: NodeType.FUNCTION;
|
|
172
174
|
content: FunctionNodeContent;
|
|
173
175
|
}
|
|
174
|
-
export
|
|
176
|
+
export interface FallbackNodeContent {
|
|
177
|
+
first_message: NodeLink;
|
|
178
|
+
second_message: NodeLink;
|
|
179
|
+
}
|
|
180
|
+
export interface FallbackNode extends Node {
|
|
181
|
+
type: NodeType.FALLBACK;
|
|
182
|
+
content: FallbackNodeContent;
|
|
183
|
+
}
|
|
184
|
+
export interface VideoLocale {
|
|
185
|
+
url: string;
|
|
186
|
+
is_embedded?: boolean;
|
|
187
|
+
locale: string;
|
|
188
|
+
}
|
|
189
|
+
export interface VideoNodeContent {
|
|
190
|
+
video: VideoLocale[];
|
|
191
|
+
}
|
|
192
|
+
export interface VideoNode extends Node {
|
|
193
|
+
type: NodeType.VIDEO;
|
|
194
|
+
content: VideoNodeContent;
|
|
195
|
+
}
|
|
196
|
+
export type NodeComponent = TextNode | ImageNode | CarouselNode | HandoffNode | KeywordNode | IntentNode | UrlNode | StartNode | PayloadNode | FunctionNode | FallbackNode | VideoNode;
|
|
@@ -13,6 +13,8 @@ var NodeType;
|
|
|
13
13
|
NodeType["URL"] = "url";
|
|
14
14
|
NodeType["PAYLOAD"] = "payload";
|
|
15
15
|
NodeType["FUNCTION"] = "function";
|
|
16
|
+
NodeType["FALLBACK"] = "fallback";
|
|
17
|
+
NodeType["VIDEO"] = "video";
|
|
16
18
|
})(NodeType = exports.NodeType || (exports.NodeType = {}));
|
|
17
19
|
var ButtonStyle;
|
|
18
20
|
(function (ButtonStyle) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-builder-models.js","sourceRoot":"","sources":["../../src/flow-builder-models.ts"],"names":[],"mappings":";;;AASA,IAAY,
|
|
1
|
+
{"version":3,"file":"flow-builder-models.js","sourceRoot":"","sources":["../../src/flow-builder-models.ts"],"names":[],"mappings":";;;AASA,IAAY,QAaX;AAbD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,2BAAe,CAAA;IACf,iCAAqB,CAAA;IACrB,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;IACnB,6BAAiB,CAAA;IACjB,iCAAqB,CAAA;IACrB,uBAAW,CAAA;IACX,+BAAmB,CAAA;IACnB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,2BAAe,CAAA;AACjB,CAAC,EAbW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAanB;AA6BD,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,0CAA2B,CAAA;AAC7B,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB"}
|
package/lib/cjs/handoff.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { ActionRequest } from '@botonic/react';
|
|
2
|
-
|
|
2
|
+
import { HandoffNode } from './flow-builder-models';
|
|
3
|
+
export declare function doHandoff(request: ActionRequest, locale: string, handoffNode: HandoffNode): Promise<void>;
|
package/lib/cjs/handoff.js
CHANGED
|
@@ -2,22 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.doHandoff = void 0;
|
|
4
4
|
const core_1 = require("@botonic/core");
|
|
5
|
-
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
async function doHandoff(request, locale, handoffNode) {
|
|
6
7
|
var _a;
|
|
8
|
+
const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
|
|
9
|
+
const handoffTargetNode = await flowBuilderPlugin.getHandoffContent((_a = handoffNode.target) === null || _a === void 0 ? void 0 : _a.id);
|
|
7
10
|
// @ts-ignore
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
|
|
11
|
+
const handOffBuilder = new core_1.HandOffBuilder(request.session); // handOffBuilder.withQueue(handoffNode.content.queue)
|
|
12
|
+
const handoffQueues = handoffNode.content.queue;
|
|
13
|
+
const queueFound = handoffQueues.find(q => q.locale === locale);
|
|
14
|
+
if (queueFound)
|
|
15
|
+
handOffBuilder.withQueue(queueFound.id);
|
|
16
|
+
// TODO: Retrieve params from FlowBuilder
|
|
17
|
+
// const handoffParams = {
|
|
18
|
+
// agentEmail: 'test@gmail.com',
|
|
19
|
+
// note: 'This is a note that will be attached to the case as a reminder',
|
|
20
|
+
// }
|
|
21
|
+
// if (handoffParams.note) {
|
|
22
|
+
// handOffBuilder.withNote(handoffParams.note)
|
|
23
|
+
// }
|
|
24
|
+
// if (handoffParams.agentEmail) {
|
|
25
|
+
// handOffBuilder.withAgentEmail(handoffParams.agentEmail)
|
|
26
|
+
// }
|
|
27
|
+
handOffBuilder.withOnFinishPayload(handoffTargetNode.id);
|
|
21
28
|
await handOffBuilder.handOff();
|
|
22
29
|
}
|
|
23
30
|
exports.doHandoff = doHandoff;
|
package/lib/cjs/handoff.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/handoff.ts"],"names":[],"mappings":";;;AAAA,wCAA8C;
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/handoff.ts"],"names":[],"mappings":";;;AAAA,wCAA8C;AAI9C,uCAAgD;AAEzC,KAAK,UAAU,SAAS,CAC7B,OAAsB,EACtB,MAAc,EACd,WAAwB;;IAExB,MAAM,iBAAiB,GAAG,IAAA,8BAAoB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,MAAM,iBAAiB,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CACjE,MAAA,WAAW,CAAC,MAAM,0CAAE,EAAE,CACvB,CAAA;IACD,aAAa;IACb,MAAM,cAAc,GAAG,IAAI,qBAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA,CAAC,sDAAsD;IACjH,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAA;IAC/C,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAA;IAC/D,IAAI,UAAU;QAAE,cAAc,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IACvD,yCAAyC;IACzC,0BAA0B;IAC1B,kCAAkC;IAClC,4EAA4E;IAC5E,IAAI;IAEJ,4BAA4B;IAC5B,gDAAgD;IAChD,IAAI;IAEJ,kCAAkC;IAClC,4DAA4D;IAC5D,IAAI;IAEJ,cAAc,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;IACxD,MAAM,cAAc,CAAC,OAAO,EAAE,CAAA;AAChC,CAAC;AA9BD,8BA8BC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFlowBuilderPlugin = void 0;
|
|
4
|
+
const FLOW_BUILDER_PLUGIN_NAME = 'BotonicPluginFlowBuilder';
|
|
5
|
+
function getFlowBuilderPlugin(plugins) {
|
|
6
|
+
const flowBuilderPlugin = Object.values(plugins).find(
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
plugin => plugin.name === FLOW_BUILDER_PLUGIN_NAME);
|
|
9
|
+
if (!flowBuilderPlugin)
|
|
10
|
+
throw new Error(`You must include '@botonic/plugin-flow-builder' in your plugins file.`);
|
|
11
|
+
return flowBuilderPlugin;
|
|
12
|
+
}
|
|
13
|
+
exports.getFlowBuilderPlugin = getFlowBuilderPlugin;
|
|
14
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;;AAGA,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,KAAK,wBAAwB,CACvB,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
|
@@ -21,12 +21,17 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
21
21
|
pre(request: PluginPreRequest): Promise<void>;
|
|
22
22
|
post(_request: PluginPostRequest): Promise<void>;
|
|
23
23
|
getContent(id: string): Promise<NodeComponent>;
|
|
24
|
-
getHandoffContent(): Promise<HandoffNode>;
|
|
24
|
+
getHandoffContent(handoffTargetId: string | undefined): Promise<HandoffNode>;
|
|
25
25
|
getFlowContent(hubtypeContent: NodeComponent, locale: string): FlowContent | undefined;
|
|
26
26
|
getStartId(): Promise<string>;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
getFallbackId(): Promise<string>;
|
|
28
|
+
getContents(id: string, locale: string, prevContents?: FlowContent[]): Promise<{
|
|
29
|
+
contents: FlowContent[];
|
|
30
|
+
handoffNode: HandoffNode;
|
|
31
|
+
}>;
|
|
32
|
+
getPayloadByIntent(input: Input, locale: string): Promise<string | undefined>;
|
|
29
33
|
hasIntent(node: IntentNode, intent: string, locale: string): boolean;
|
|
34
|
+
hasMetConfidenceThreshold(node: IntentNode, predictedConfidence: number): boolean;
|
|
30
35
|
getPayloadByKeyword(input: Input, locale: string): Promise<string | undefined>;
|
|
31
36
|
matchKeywords(node: KeywordNode, input: string, locale: string): boolean;
|
|
32
37
|
containsAnyKeywords(input: string, keywords: string[]): boolean;
|
package/lib/cjs/index.js
CHANGED
|
@@ -17,10 +17,10 @@ class BotonicPluginFlowBuilder {
|
|
|
17
17
|
this.functions = Object.assign(Object.assign({}, functions_1.DEFAULT_FUNCTIONS), customFunctions);
|
|
18
18
|
}
|
|
19
19
|
async readFlowContent() {
|
|
20
|
-
const
|
|
20
|
+
const { data } = await axios_1.default.get(this.flowUrl, {
|
|
21
21
|
headers: { Authorization: `Bearer ${this.getAccessToken()}` },
|
|
22
22
|
});
|
|
23
|
-
return
|
|
23
|
+
return data;
|
|
24
24
|
}
|
|
25
25
|
async pre(request) {
|
|
26
26
|
this.currentRequest = request;
|
|
@@ -34,9 +34,9 @@ class BotonicPluginFlowBuilder {
|
|
|
34
34
|
throw Error(`Node with id: '${id}' not found`);
|
|
35
35
|
return content;
|
|
36
36
|
}
|
|
37
|
-
async getHandoffContent() {
|
|
37
|
+
async getHandoffContent(handoffTargetId) {
|
|
38
38
|
const flow = await this.flow;
|
|
39
|
-
const content = flow.nodes.find(node => node.
|
|
39
|
+
const content = flow.nodes.find(node => node.id === handoffTargetId);
|
|
40
40
|
if (!content)
|
|
41
41
|
throw Error(`Handoff node not found`);
|
|
42
42
|
return content;
|
|
@@ -49,6 +49,8 @@ class BotonicPluginFlowBuilder {
|
|
|
49
49
|
return content_fields_1.FlowImage.fromHubtypeCMS(hubtypeContent, locale);
|
|
50
50
|
case flow_builder_models_1.NodeType.CAROUSEL:
|
|
51
51
|
return content_fields_1.FlowCarousel.fromHubtypeCMS(hubtypeContent, locale);
|
|
52
|
+
case flow_builder_models_1.NodeType.VIDEO:
|
|
53
|
+
return content_fields_1.FlowVideo.fromHubtypeCMS(hubtypeContent, locale);
|
|
52
54
|
default:
|
|
53
55
|
return undefined;
|
|
54
56
|
}
|
|
@@ -56,14 +58,26 @@ class BotonicPluginFlowBuilder {
|
|
|
56
58
|
async getStartId() {
|
|
57
59
|
const flow = await this.flow;
|
|
58
60
|
const startNode = flow.nodes.find(node => node.type === flow_builder_models_1.NodeType.START_UP);
|
|
59
|
-
if (!startNode)
|
|
61
|
+
if (!startNode)
|
|
60
62
|
throw new Error('start-up id must be defined');
|
|
61
|
-
}
|
|
62
63
|
return startNode.target.id;
|
|
63
64
|
}
|
|
65
|
+
async getFallbackId() {
|
|
66
|
+
const flow = await this.flow;
|
|
67
|
+
const fallbackNode = flow.nodes.find(node => node.type === flow_builder_models_1.NodeType.FALLBACK);
|
|
68
|
+
if (!fallbackNode)
|
|
69
|
+
throw new Error('fallback node must be defined');
|
|
70
|
+
const fallbackFirstMessage = fallbackNode.content.first_message;
|
|
71
|
+
const fallbackSecondMessage = fallbackNode.content.second_message;
|
|
72
|
+
if (!fallbackSecondMessage)
|
|
73
|
+
return fallbackFirstMessage.id;
|
|
74
|
+
const fallbackIds = [fallbackFirstMessage.id, fallbackSecondMessage.id];
|
|
75
|
+
return fallbackIds[Math.floor(Math.random() * fallbackIds.length)];
|
|
76
|
+
}
|
|
64
77
|
async getContents(id, locale, prevContents) {
|
|
65
78
|
const contents = prevContents || [];
|
|
66
79
|
const hubtypeContent = await this.getContent(id);
|
|
80
|
+
const isHandoff = hubtypeContent.type === flow_builder_models_1.NodeType.HANDOFF;
|
|
67
81
|
if (hubtypeContent.content.elements) {
|
|
68
82
|
for (const i in hubtypeContent.content.elements) {
|
|
69
83
|
const button = hubtypeContent.content.elements[i].button;
|
|
@@ -98,20 +112,21 @@ class BotonicPluginFlowBuilder {
|
|
|
98
112
|
}
|
|
99
113
|
// execute function
|
|
100
114
|
// return this.getContents(function result_mapping target, locale, contents)
|
|
101
|
-
return contents;
|
|
115
|
+
return { contents, handoffNode: isHandoff && hubtypeContent };
|
|
102
116
|
}
|
|
103
|
-
async
|
|
117
|
+
async getPayloadByIntent(input, locale) {
|
|
104
118
|
var _a;
|
|
105
119
|
try {
|
|
106
120
|
const flow = await this.flow;
|
|
107
121
|
const intents = flow.nodes.filter(node => node.type === flow_builder_models_1.NodeType.INTENT);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
122
|
+
const inputIntent = input.intent;
|
|
123
|
+
const inputConfidence = input.confidence;
|
|
124
|
+
if (inputIntent) {
|
|
125
|
+
const matchedIntentNode = intents.find(node => inputIntent &&
|
|
126
|
+
this.hasIntent(node, inputIntent, locale) &&
|
|
127
|
+
inputConfidence &&
|
|
128
|
+
this.hasMetConfidenceThreshold(node, inputConfidence));
|
|
129
|
+
return (_a = matchedIntentNode === null || matchedIntentNode === void 0 ? void 0 : matchedIntentNode.target) === null || _a === void 0 ? void 0 : _a.id;
|
|
115
130
|
}
|
|
116
131
|
}
|
|
117
132
|
catch (error) {
|
|
@@ -120,8 +135,11 @@ class BotonicPluginFlowBuilder {
|
|
|
120
135
|
return undefined;
|
|
121
136
|
}
|
|
122
137
|
hasIntent(node, intent, locale) {
|
|
123
|
-
|
|
124
|
-
|
|
138
|
+
return node.content.intents.some(i => i.locale === locale && i.values.includes(intent));
|
|
139
|
+
}
|
|
140
|
+
hasMetConfidenceThreshold(node, predictedConfidence) {
|
|
141
|
+
const nodeConfidence = node.content.confidence / 100;
|
|
142
|
+
return predictedConfidence >= nodeConfidence;
|
|
125
143
|
}
|
|
126
144
|
async getPayloadByKeyword(input, locale) {
|
|
127
145
|
var _a;
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;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AM,CAAC,CACtE,IAAI,CACL,CAAA;QACD,0CAA0C;QAC1C,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CACrD,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,cAAc,CACjC,CAAA;QACD,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CACb,wDAAwD,cAAc,EAAE,CACzE,CAAA;SACF;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAA;IACzB,CAAC;CACF;AA5PD,2CA4PC;AAED,mCAA4C;AAAnC,2GAAA,iBAAiB,OAAA"}
|
package/lib/esm/action.js
CHANGED
|
@@ -1,47 +1,36 @@
|
|
|
1
|
-
import { RequestContext
|
|
1
|
+
import { RequestContext } from '@botonic/react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { doHandoff } from './handoff';
|
|
4
|
+
import { getFlowBuilderPlugin } from './helpers';
|
|
4
5
|
export class FlowBuilderAction extends React.Component {
|
|
5
6
|
static async botonicInit(request) {
|
|
6
|
-
const flowBuilderPlugin = request.plugins
|
|
7
|
-
.hubtypeFlowBuilder;
|
|
7
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
|
|
8
8
|
const locale = flowBuilderPlugin.getLocale(request.session);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
const payload = request.input.payload;
|
|
10
|
+
let targetContentId = payload;
|
|
11
|
+
if (!payload && request.session.is_first_interaction) {
|
|
12
|
+
targetContentId = await flowBuilderPlugin.getStartId();
|
|
13
|
+
}
|
|
14
|
+
if (!payload) {
|
|
15
|
+
const intentPayload = await flowBuilderPlugin.getPayloadByIntent(request.input, locale);
|
|
16
|
+
if (intentPayload)
|
|
17
|
+
targetContentId = intentPayload;
|
|
17
18
|
const keywordPayload = await flowBuilderPlugin.getPayloadByKeyword(request.input, locale);
|
|
18
|
-
if (keywordPayload)
|
|
19
|
-
|
|
20
|
-
}
|
|
19
|
+
if (keywordPayload)
|
|
20
|
+
targetContentId = keywordPayload;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (content.length === 0) {
|
|
25
|
-
const handoffParams = {
|
|
26
|
-
queue: 'Test',
|
|
27
|
-
agentEmail: 'test@gmail.com',
|
|
28
|
-
note: 'This is a note that will be attached to the case as a reminder',
|
|
29
|
-
};
|
|
30
|
-
await doHandoff(request, handoffParams.queue, handoffParams.note);
|
|
31
|
-
const isHandoff = true;
|
|
32
|
-
return { isHandoff };
|
|
22
|
+
if (!targetContentId) {
|
|
23
|
+
targetContentId = await flowBuilderPlugin.getFallbackId();
|
|
33
24
|
}
|
|
34
|
-
|
|
25
|
+
const { contents, handoffNode } = await flowBuilderPlugin.getContents(targetContentId, locale);
|
|
26
|
+
if (handoffNode)
|
|
27
|
+
await doHandoff(request, locale, handoffNode);
|
|
28
|
+
return { contents, handoffNode };
|
|
35
29
|
}
|
|
36
30
|
render() {
|
|
37
31
|
// @ts-ignore
|
|
38
|
-
const {
|
|
39
|
-
|
|
40
|
-
return React.createElement(Text, null, "You are being transferred to an agent!");
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return contents.map((content, index) => content.toBotonic(index));
|
|
44
|
-
}
|
|
32
|
+
const { contents, handoffNode } = this.props;
|
|
33
|
+
return contents.map((content, index) => content.toBotonic(index));
|
|
45
34
|
}
|
|
46
35
|
}
|
|
47
36
|
FlowBuilderAction.contextType = RequestContext;
|