@botonic/plugin-flow-builder 0.21.0-alpha.8 → 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.d.ts +1 -1
- 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.d.ts +0 -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-carousel.d.ts +0 -1
- package/lib/cjs/content-fields/flow-carousel.js +2 -2
- package/lib/cjs/content-fields/flow-carousel.js.map +1 -1
- package/lib/cjs/content-fields/flow-image.d.ts +0 -1
- package/lib/cjs/content-fields/flow-text.d.ts +0 -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 +27 -5
- package/lib/cjs/flow-builder-models.js +2 -0
- package/lib/cjs/flow-builder-models.js.map +1 -1
- package/lib/cjs/functions/conditional-queue-status.js +1 -1
- package/lib/cjs/functions/conditional-queue-status.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 +9 -4
- package/lib/cjs/index.js +45 -17
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/action.d.ts +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.d.ts +0 -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-carousel.d.ts +0 -1
- package/lib/esm/content-fields/flow-carousel.js +2 -2
- package/lib/esm/content-fields/flow-carousel.js.map +1 -1
- package/lib/esm/content-fields/flow-image.d.ts +0 -1
- package/lib/esm/content-fields/flow-text.d.ts +0 -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 +27 -5
- 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 +9 -4
- package/lib/esm/index.js +46 -18
- package/lib/esm/index.js.map +1 -1
- package/package.json +3 -3
- 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-carousel.tsx +4 -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 +65 -21
package/lib/cjs/action.d.ts
CHANGED
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 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,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;QACnE,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,MAAM;YAClC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;YACrB,CAAC,CAAC,MAAA,MAAA,SAAS,CAAC,OAAO,0CAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,0CAAE,EAAE,CAAA;QACrE,IAAI,SAAS,CAAC,GAAG,EAAE;YACjB,MAAM,SAAS,GAAI,SAAS,CAAC,GAAW,CAAC,IAAI,CAC3C,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,CAC7B,CAAA;YACD,IAAI,SAAS;gBAAE,SAAS,CAAC,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAA;SACrD;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,YAAY,CAAC,KAAa,EAAE,WAAwB;QAClD,IAAI,WAAW,KAAK,iCAAW,CAAC,WAAW,EAAE;YAC3C,OAAO,CACL,8BAAC,aAAK,IAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,IACrC,IAAI,CAAC,IAAI,CACJ,CACT,CAAA;SACF;QACD,IAAI,KAAK,GAAG,EAAE,CAAA;QACd,IAAI,IAAI,CAAC,GAAG;YAAE,KAAK,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAA;QACvC,OAAO;QACL,aAAa;QACb,8BAAC,cAAM,kBAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,IAAM,KAAK,GACjD,IAAI,CAAC,IAAI,CACH,CACV,CAAA;IACH,CAAC;CACF;AArCD,gCAqCC"}
|
|
@@ -20,12 +20,12 @@ class FlowCarousel extends content_fields_base_1.ContentFieldsBase {
|
|
|
20
20
|
}
|
|
21
21
|
toBotonic(index) {
|
|
22
22
|
return (react_2.default.createElement(react_1.Carousel, { key: index }, this.elements.map((element, eIndex) => {
|
|
23
|
-
var _a, _b;
|
|
23
|
+
var _a, _b, _c;
|
|
24
24
|
return (react_2.default.createElement(react_1.Element, { key: eIndex },
|
|
25
25
|
react_2.default.createElement(react_1.Pic, { src: element.image }),
|
|
26
26
|
react_2.default.createElement(react_1.Title, { style: '' }, element.title),
|
|
27
27
|
react_2.default.createElement(react_1.Subtitle, { style: '' }, element.subtitle),
|
|
28
|
-
react_2.default.createElement(react_1.Button, { payload: (_a = element.buttons) === null || _a === void 0 ? void 0 : _a.payload
|
|
28
|
+
react_2.default.createElement(react_1.Button, { payload: (_a = element.buttons) === null || _a === void 0 ? void 0 : _a.payload, url: (_b = element.buttons) === null || _b === void 0 ? void 0 : _b.url }, (_c = element.buttons) === null || _c === void 0 ? void 0 : _c.text),
|
|
29
29
|
","));
|
|
30
30
|
})));
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-carousel.js","sourceRoot":"","sources":["../../../src/content-fields/flow-carousel.tsx"],"names":[],"mappings":";;;;AAAA,0CAAgF;AAChF,0DAAyB;AAGzB,+DAAyD;AACzD,iDAA4C;AAE5C,MAAa,YAAa,SAAQ,uCAAiB;IAAnD;;QACS,SAAI,GAAG,EAAE,CAAA;QACT,aAAQ,GAAkB,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"flow-carousel.js","sourceRoot":"","sources":["../../../src/content-fields/flow-carousel.tsx"],"names":[],"mappings":";;;;AAAA,0CAAgF;AAChF,0DAAyB;AAGzB,+DAAyD;AACzD,iDAA4C;AAE5C,MAAa,YAAa,SAAQ,uCAAiB;IAAnD;;QACS,SAAI,GAAG,EAAE,CAAA;QACT,aAAQ,GAAkB,EAAE,CAAA;IAgCrC,CAAC;IA9BC,MAAM,CAAC,cAAc,CAAC,SAAuB,EAAE,MAAc;QAC3D,MAAM,WAAW,GAAG,IAAI,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAClD,WAAW,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;QACjC,WAAW,CAAC,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAC9D,0BAAW,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAC5C,CAAA;QACD,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,SAAS,CAAC,KAAa;QACrB,OAAO,CACL,8BAAC,gBAAQ,IAAC,GAAG,EAAE,KAAK,IACjB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;;YAAC,OAAA,CACtC,8BAAC,eAAO,IAAC,GAAG,EAAE,MAAM;gBAClB,8BAAC,WAAG,IAAC,GAAG,EAAE,OAAO,CAAC,KAAK,GAAI;gBAC3B,8BAAC,aAAK,IAAC,KAAK,EAAC,EAAE,IAAE,OAAO,CAAC,KAAK,CAAS;gBACvC,8BAAC,gBAAQ,IAAC,KAAK,EAAC,EAAE,IAAE,OAAO,CAAC,QAAQ,CAAY;gBAEhD,8BAAC,cAAM,IACL,OAAO,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAE,OAAO,EACjC,GAAG,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAE,GAAG,IAExB,MAAA,OAAO,CAAC,OAAO,0CAAE,IAAI,CACf;oBAED,CACX,CAAA;SAAA,CAAC,CACO,CACZ,CAAA;IACH,CAAC;CACF;AAlCD,oCAkCC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { VideoNode } from '../flow-builder-models';
|
|
2
|
+
import { ContentFieldsBase } from './content-fields-base';
|
|
3
|
+
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[];
|
|
@@ -148,7 +150,7 @@ export interface PayloadNode extends BaseNode {
|
|
|
148
150
|
type: NodeType.PAYLOAD;
|
|
149
151
|
content: PayloadNodeContent;
|
|
150
152
|
}
|
|
151
|
-
export
|
|
153
|
+
export type ArgumentType = number | string | Record<any, any>;
|
|
152
154
|
export interface FunctionNodeArgument {
|
|
153
155
|
type: ArgumentType;
|
|
154
156
|
name: string;
|
|
@@ -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"}
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
6
6
|
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
|
-
const _HUBTYPE_API_URL_ = utils_1.getWebpackEnvVar(
|
|
8
|
+
const _HUBTYPE_API_URL_ = (0, utils_1.getWebpackEnvVar)(
|
|
9
9
|
// @ts-ignore
|
|
10
10
|
typeof HUBTYPE_API_URL !== 'undefined' && HUBTYPE_API_URL, 'HUBTYPE_API_URL', 'https://api.hubtype.com');
|
|
11
11
|
async function conditionalQueueStatus({ queue_id, }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional-queue-status.js","sourceRoot":"","sources":["../../../src/functions/conditional-queue-status.ts"],"names":[],"mappings":";;;;AAAA,yDAAyD;AACzD,0DAAyB;AAEzB,oCAA2C;AAE3C,MAAM,iBAAiB,GAAG,wBAAgB;AACxC,aAAa;AACb,OAAO,eAAe,KAAK,WAAW,IAAI,eAAe,EACzD,iBAAiB,EACjB,yBAAyB,CAC1B,CAAA;AAEM,KAAK,UAAU,sBAAsB,CAAC,EAC3C,QAAQ,GAGT;IACC,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,GAAG,iBAAiB,cAAc,QAAQ,gBAAgB;IAC1D,2CAA2C;IAC3C;QACE,MAAM,EAAE;YACN,oBAAoB,EAAE,IAAI;YAC1B,mBAAmB,EAAE,KAAK;YAC1B,sBAAsB,EAAE,KAAK;SAC9B;KACF,CACF,CAAA;IACD,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAA;IAC3C,OAAO,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;AACxC,CAAC;AAlBD,wDAkBC"}
|
|
1
|
+
{"version":3,"file":"conditional-queue-status.js","sourceRoot":"","sources":["../../../src/functions/conditional-queue-status.ts"],"names":[],"mappings":";;;;AAAA,yDAAyD;AACzD,0DAAyB;AAEzB,oCAA2C;AAE3C,MAAM,iBAAiB,GAAG,IAAA,wBAAgB;AACxC,aAAa;AACb,OAAO,eAAe,KAAK,WAAW,IAAI,eAAe,EACzD,iBAAiB,EACjB,yBAAyB,CAC1B,CAAA;AAEM,KAAK,UAAU,sBAAsB,CAAC,EAC3C,QAAQ,GAGT;IACC,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,GAAG,iBAAiB,cAAc,QAAQ,gBAAgB;IAC1D,2CAA2C;IAC3C;QACE,MAAM,EAAE;YACN,oBAAoB,EAAE,IAAI;YAC1B,mBAAmB,EAAE,KAAK;YAC1B,sBAAsB,EAAE,KAAK;SAC9B;KACF,CACF,CAAA;IACD,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAA;IAC3C,OAAO,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;AACxC,CAAC;AAlBD,wDAkBC"}
|
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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Input, Plugin, PluginPostRequest, PluginPreRequest, Session } from '@botonic/core';
|
|
2
2
|
import { FlowContent } from './content-fields';
|
|
3
3
|
import { FlowBuilderData, FunctionNode, HandoffNode, IntentNode, KeywordNode, NodeComponent } from './flow-builder-models';
|
|
4
|
-
export
|
|
4
|
+
export type BotonicPluginFlowBuilderOptions = {
|
|
5
5
|
flowUrl: string;
|
|
6
6
|
flow?: FlowBuilderData;
|
|
7
7
|
customFunctions?: Record<any, any>;
|
|
@@ -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,36 @@ 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;
|
|
81
|
+
if (hubtypeContent.content.elements) {
|
|
82
|
+
for (const i in hubtypeContent.content.elements) {
|
|
83
|
+
const button = hubtypeContent.content.elements[i].button;
|
|
84
|
+
if (button.url) {
|
|
85
|
+
for (const j in button.url) {
|
|
86
|
+
button.url[j] = Object.assign(Object.assign({}, button.url[j]), (await this.getContent(button.url[j].id)));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
67
91
|
if (hubtypeContent.content.buttons) {
|
|
68
92
|
for (const i in hubtypeContent.content.buttons) {
|
|
69
93
|
const button = hubtypeContent.content.buttons[i];
|
|
@@ -88,20 +112,21 @@ class BotonicPluginFlowBuilder {
|
|
|
88
112
|
}
|
|
89
113
|
// execute function
|
|
90
114
|
// return this.getContents(function result_mapping target, locale, contents)
|
|
91
|
-
return contents;
|
|
115
|
+
return { contents, handoffNode: isHandoff && hubtypeContent };
|
|
92
116
|
}
|
|
93
|
-
async
|
|
117
|
+
async getPayloadByIntent(input, locale) {
|
|
94
118
|
var _a;
|
|
95
119
|
try {
|
|
96
120
|
const flow = await this.flow;
|
|
97
121
|
const intents = flow.nodes.filter(node => node.type === flow_builder_models_1.NodeType.INTENT);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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;
|
|
105
130
|
}
|
|
106
131
|
}
|
|
107
132
|
catch (error) {
|
|
@@ -110,8 +135,11 @@ class BotonicPluginFlowBuilder {
|
|
|
110
135
|
return undefined;
|
|
111
136
|
}
|
|
112
137
|
hasIntent(node, intent, locale) {
|
|
113
|
-
|
|
114
|
-
|
|
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;
|
|
115
143
|
}
|
|
116
144
|
async getPayloadByKeyword(input, locale) {
|
|
117
145
|
var _a;
|