@botonic/plugin-flow-builder 0.21.0-alpha.9 → 0.21.2

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.
Files changed (100) hide show
  1. package/lib/cjs/action.js +23 -32
  2. package/lib/cjs/action.js.map +1 -1
  3. package/lib/cjs/content-fields/content-fields-base.d.ts +3 -2
  4. package/lib/cjs/content-fields/content-fields-base.js +6 -1
  5. package/lib/cjs/content-fields/content-fields-base.js.map +1 -1
  6. package/lib/cjs/content-fields/flow-button.d.ts +1 -1
  7. package/lib/cjs/content-fields/flow-button.js +7 -5
  8. package/lib/cjs/content-fields/flow-button.js.map +1 -1
  9. package/lib/cjs/content-fields/flow-carousel.d.ts +1 -1
  10. package/lib/cjs/content-fields/flow-carousel.js +4 -5
  11. package/lib/cjs/content-fields/flow-carousel.js.map +1 -1
  12. package/lib/cjs/content-fields/flow-image.d.ts +1 -1
  13. package/lib/cjs/content-fields/flow-image.js +2 -2
  14. package/lib/cjs/content-fields/flow-image.js.map +1 -1
  15. package/lib/cjs/content-fields/flow-text.d.ts +1 -1
  16. package/lib/cjs/content-fields/flow-text.js +3 -3
  17. package/lib/cjs/content-fields/flow-text.js.map +1 -1
  18. package/lib/cjs/content-fields/flow-video.d.ts +8 -0
  19. package/lib/cjs/content-fields/flow-video.js +26 -0
  20. package/lib/cjs/content-fields/flow-video.js.map +1 -0
  21. package/lib/cjs/content-fields/index.d.ts +1 -0
  22. package/lib/cjs/content-fields/index.js +3 -1
  23. package/lib/cjs/content-fields/index.js.map +1 -1
  24. package/lib/cjs/content-fields/types.d.ts +2 -1
  25. package/lib/cjs/flow-builder-models.d.ts +26 -4
  26. package/lib/cjs/flow-builder-models.js +2 -0
  27. package/lib/cjs/flow-builder-models.js.map +1 -1
  28. package/lib/cjs/handoff.d.ts +2 -1
  29. package/lib/cjs/handoff.js +21 -14
  30. package/lib/cjs/handoff.js.map +1 -1
  31. package/lib/cjs/helpers.d.ts +6 -0
  32. package/lib/cjs/helpers.js +27 -0
  33. package/lib/cjs/helpers.js.map +1 -0
  34. package/lib/cjs/index.d.ts +10 -11
  35. package/lib/cjs/index.js +45 -42
  36. package/lib/cjs/index.js.map +1 -1
  37. package/lib/cjs/types.d.ts +13 -0
  38. package/lib/cjs/types.js +9 -0
  39. package/lib/cjs/types.js.map +1 -0
  40. package/lib/cjs/utils.d.ts +3 -0
  41. package/lib/cjs/utils.js +19 -1
  42. package/lib/cjs/utils.js.map +1 -1
  43. package/lib/esm/action.js +24 -33
  44. package/lib/esm/action.js.map +1 -1
  45. package/lib/esm/content-fields/content-fields-base.d.ts +3 -2
  46. package/lib/esm/content-fields/content-fields-base.js +6 -1
  47. package/lib/esm/content-fields/content-fields-base.js.map +1 -1
  48. package/lib/esm/content-fields/flow-button.d.ts +1 -1
  49. package/lib/esm/content-fields/flow-button.js +7 -5
  50. package/lib/esm/content-fields/flow-button.js.map +1 -1
  51. package/lib/esm/content-fields/flow-carousel.d.ts +1 -1
  52. package/lib/esm/content-fields/flow-carousel.js +4 -5
  53. package/lib/esm/content-fields/flow-carousel.js.map +1 -1
  54. package/lib/esm/content-fields/flow-image.d.ts +1 -1
  55. package/lib/esm/content-fields/flow-image.js +2 -2
  56. package/lib/esm/content-fields/flow-image.js.map +1 -1
  57. package/lib/esm/content-fields/flow-text.d.ts +1 -1
  58. package/lib/esm/content-fields/flow-text.js +3 -3
  59. package/lib/esm/content-fields/flow-text.js.map +1 -1
  60. package/lib/esm/content-fields/flow-video.d.ts +8 -0
  61. package/lib/esm/content-fields/flow-video.js +21 -0
  62. package/lib/esm/content-fields/flow-video.js.map +1 -0
  63. package/lib/esm/content-fields/index.d.ts +1 -0
  64. package/lib/esm/content-fields/index.js +1 -0
  65. package/lib/esm/content-fields/index.js.map +1 -1
  66. package/lib/esm/content-fields/types.d.ts +2 -1
  67. package/lib/esm/flow-builder-models.d.ts +26 -4
  68. package/lib/esm/flow-builder-models.js +2 -0
  69. package/lib/esm/flow-builder-models.js.map +1 -1
  70. package/lib/esm/handoff.d.ts +2 -1
  71. package/lib/esm/handoff.js +21 -14
  72. package/lib/esm/handoff.js.map +1 -1
  73. package/lib/esm/helpers.d.ts +6 -0
  74. package/lib/esm/helpers.js +22 -0
  75. package/lib/esm/helpers.js.map +1 -0
  76. package/lib/esm/index.d.ts +10 -11
  77. package/lib/esm/index.js +46 -43
  78. package/lib/esm/index.js.map +1 -1
  79. package/lib/esm/types.d.ts +13 -0
  80. package/lib/esm/types.js +6 -0
  81. package/lib/esm/types.js.map +1 -0
  82. package/lib/esm/utils.d.ts +3 -0
  83. package/lib/esm/utils.js +17 -0
  84. package/lib/esm/utils.js.map +1 -1
  85. package/package.json +3 -3
  86. package/src/action.tsx +29 -35
  87. package/src/content-fields/content-fields-base.ts +12 -3
  88. package/src/content-fields/flow-button.tsx +6 -4
  89. package/src/content-fields/flow-carousel.tsx +4 -5
  90. package/src/content-fields/flow-image.tsx +2 -2
  91. package/src/content-fields/flow-text.tsx +4 -4
  92. package/src/content-fields/flow-video.tsx +22 -0
  93. package/src/content-fields/index.ts +1 -0
  94. package/src/content-fields/types.ts +2 -1
  95. package/src/flow-builder-models.ts +30 -2
  96. package/src/handoff.ts +25 -16
  97. package/src/helpers.ts +39 -0
  98. package/src/index.ts +61 -61
  99. package/src/types.ts +16 -0
  100. package/src/utils.ts +24 -0
package/lib/cjs/action.js CHANGED
@@ -5,47 +5,38 @@ 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");
9
+ let alternateFallbackMessage = false;
8
10
  class FlowBuilderAction extends react_2.default.Component {
9
11
  static async botonicInit(request) {
10
- const flowBuilderPlugin = request.plugins
11
- .hubtypeFlowBuilder;
12
+ const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
12
13
  const locale = flowBuilderPlugin.getLocale(request.session);
13
- let payload = request.input.payload
14
- ? request.input.payload
15
- : await flowBuilderPlugin.getStartId();
16
- if (!request.input.payload) {
17
- const intentPayload = await flowBuilderPlugin.getPayloadByInput(request.input, locale);
18
- if (intentPayload) {
19
- payload = intentPayload;
20
- }
14
+ const payload = request.input.payload;
15
+ let targetContentId = payload;
16
+ if (!payload && request.session.is_first_interaction) {
17
+ targetContentId = await flowBuilderPlugin.getStartId();
18
+ }
19
+ if (!payload) {
20
+ const intentPayload = await flowBuilderPlugin.getPayloadByIntent(request.input, locale);
21
+ if (intentPayload)
22
+ targetContentId = intentPayload;
21
23
  const keywordPayload = await flowBuilderPlugin.getPayloadByKeyword(request.input, locale);
22
- if (keywordPayload) {
23
- payload = keywordPayload;
24
- }
24
+ if (keywordPayload)
25
+ targetContentId = keywordPayload;
25
26
  }
26
- // We use only Spanish because they are the backend examples
27
- const content = await flowBuilderPlugin.getContents(payload, locale);
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 };
27
+ if (!targetContentId) {
28
+ targetContentId = await flowBuilderPlugin.getFallbackId(alternateFallbackMessage);
29
+ alternateFallbackMessage = !alternateFallbackMessage;
37
30
  }
38
- return { content };
31
+ const { contents, handoffNode } = await flowBuilderPlugin.getContents(targetContentId, locale);
32
+ if (handoffNode)
33
+ await (0, handoff_1.doHandoff)(request, locale, handoffNode);
34
+ return { contents, handoffNode };
39
35
  }
40
36
  render() {
41
37
  // @ts-ignore
42
- const { content: contents, isHandoff } = this.props;
43
- if (isHandoff) {
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
- }
38
+ const { contents, handoffNode } = this.props;
39
+ return contents.map(content => content.toBotonic(content.id));
49
40
  }
50
41
  }
51
42
  exports.FlowBuilderAction = FlowBuilderAction;
@@ -1 +1 @@
1
- {"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/action.tsx"],"names":[],"mappings":";;;;AAAA,0CAAoE;AACpE,0DAAyB;AAGzB,uCAAqC;AAQrC,MAAa,iBAAkB,SAAQ,eAAK,CAAC,SAAiC;IAG5E,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,OAAsB;QAC7C,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO;aACtC,kBAA8C,CAAA;QACjD,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC3D,IAAI,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO;YACjC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO;YACvB,CAAC,CAAC,MAAM,iBAAiB,CAAC,UAAU,EAAE,CAAA;QAExC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE;YAC1B,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CAC7D,OAAO,CAAC,KAAK,EACb,MAAM,CACP,CAAA;YACD,IAAI,aAAa,EAAE;gBACjB,OAAO,GAAG,aAAa,CAAA;aACxB;YACD,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC,mBAAmB,CAChE,OAAO,CAAC,KAAK,EACb,MAAM,CACP,CAAA;YACD,IAAI,cAAc,EAAE;gBAClB,OAAO,GAAG,cAAc,CAAA;aACzB;SACF;QACD,4DAA4D;QAC5D,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QAEpE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YACxB,MAAM,aAAa,GAAG;gBACpB,KAAK,EAAE,MAAM;gBACb,UAAU,EAAE,gBAAgB;gBAC5B,IAAI,EAAE,gEAAgE;aACvE,CAAA;YACD,MAAM,IAAA,mBAAS,EAA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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,CACrD,wBAAwB,CACzB,CAAA;YACD,wBAAwB,GAAG,CAAC,wBAAwB,CAAA;SACrD;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,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;IAChE,CAAC;;AA5CH,8CA6CC;AA5CQ,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
- private readonly id;
3
+ readonly id: string;
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(t => t.locale === locale);
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":";;;AAEA,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;CACF;AAZD,8CAYC"}
1
+ {"version":3,"file":"content-fields-base.js","sourceRoot":"","sources":["../../../src/content-fields/content-fields-base.ts"],"names":[],"mappings":";;;AAMA,MAAsB,iBAAiB;IACrC,YAA4B,EAAU;QAAV,OAAE,GAAF,EAAE,CAAQ;IAAG,CAAC;IAE1C,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"}
@@ -5,5 +5,5 @@ export declare class FlowButton extends ContentFieldsBase {
5
5
  url?: string;
6
6
  payload?: string;
7
7
  static fromHubtypeCMS(component: FbButton, locale: string): FlowButton;
8
- renderButton(index: number, buttonStyle: ButtonStyle): JSX.Element;
8
+ renderButton(id: string, buttonStyle: ButtonStyle): JSX.Element;
9
9
  }
@@ -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 = (_a = component.target) === null || _a === void 0 ? void 0 : _a.id;
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)
@@ -23,16 +25,16 @@ class FlowButton extends content_fields_base_1.ContentFieldsBase {
23
25
  }
24
26
  return newButton;
25
27
  }
26
- renderButton(index, buttonStyle) {
28
+ renderButton(id, buttonStyle) {
27
29
  if (buttonStyle === flow_builder_models_1.ButtonStyle.QUICK_REPLY) {
28
- return (react_2.default.createElement(react_1.Reply, { payload: this.payload, key: index }, this.text));
30
+ return (react_2.default.createElement(react_1.Reply, { key: id, payload: this.payload }, this.text));
29
31
  }
30
32
  let props = {};
31
33
  if (this.url)
32
34
  props = { url: this.url };
33
35
  return (
34
36
  // @ts-ignore
35
- react_2.default.createElement(react_1.Button, Object.assign({ payload: this.payload, key: index }, props), this.text));
37
+ react_2.default.createElement(react_1.Button, Object.assign({ key: id, payload: this.payload }, props), this.text));
36
38
  }
37
39
  }
38
40
  exports.FlowButton = FlowButton;
@@ -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;IAkClB,CAAC;IA9BC,MAAM,CAAC,cAAc,CAAC,SAAmB,EAAE,MAAc;;QACvD,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,SAAS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IAAM,KAAK,GAC9C,IAAI,CAAC,IAAI,CACH,CACV,CAAA;IACH,CAAC;CACF;AArCD,gCAqCC"}
@@ -5,5 +5,5 @@ export declare class FlowCarousel extends ContentFieldsBase {
5
5
  code: string;
6
6
  elements: FlowElement[];
7
7
  static fromHubtypeCMS(component: CarouselNode, locale: string): FlowCarousel;
8
- toBotonic(index: number): JSX.Element;
8
+ toBotonic(id: string): JSX.Element;
9
9
  }
@@ -18,15 +18,14 @@ class FlowCarousel extends content_fields_base_1.ContentFieldsBase {
18
18
  newCarousel.elements = component.content.elements.map(element => flow_element_1.FlowElement.fromHubtypeCMS(element, locale));
19
19
  return newCarousel;
20
20
  }
21
- toBotonic(index) {
22
- return (react_2.default.createElement(react_1.Carousel, { key: index }, this.elements.map((element, eIndex) => {
21
+ toBotonic(id) {
22
+ return (react_2.default.createElement(react_1.Carousel, { key: id }, this.elements.map(element => {
23
23
  var _a, _b, _c;
24
- return (react_2.default.createElement(react_1.Element, { key: eIndex },
24
+ return (react_2.default.createElement(react_1.Element, { key: `${id}-${element.id}` },
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, url: (_b = element.buttons) === null || _b === void 0 ? void 0 : _b.url }, (_c = element.buttons) === null || _c === void 0 ? void 0 : _c.text),
29
- ","));
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)));
30
29
  })));
31
30
  }
32
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"flow-carousel.js","sourceRoot":"","sources":["../../../src/content-fields/flow-carousel.tsx"],"names":[],"mappings":";;;;AAAA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GAAG,IAExB,MAAA,OAAO,CAAC,OAAO,0CAAE,IAAI,CACf,CACD,CACX,CAAA;SAAA,CAAC,CACO,CACZ,CAAA;IACH,CAAC;CACF;AAjCD,oCAiCC"}
@@ -4,5 +4,5 @@ export declare class FlowImage extends ContentFieldsBase {
4
4
  src: string;
5
5
  code: string;
6
6
  static fromHubtypeCMS(component: ImageNode, locale: string): FlowImage;
7
- toBotonic(index: number): JSX.Element;
7
+ toBotonic(id: string): JSX.Element;
8
8
  }
@@ -17,8 +17,8 @@ class FlowImage extends content_fields_base_1.ContentFieldsBase {
17
17
  newImage.src = this.getImageByLocale(locale, component.content.image);
18
18
  return newImage;
19
19
  }
20
- toBotonic(index) {
21
- return react_2.default.createElement(react_1.Image, { src: this.src, key: index });
20
+ toBotonic(id) {
21
+ return react_2.default.createElement(react_1.Image, { key: id, src: this.src });
22
22
  }
23
23
  }
24
24
  exports.FlowImage = FlowImage;
@@ -1 +1 @@
1
- {"version":3,"file":"flow-image.js","sourceRoot":"","sources":["../../../src/content-fields/flow-image.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;IAYlB,CAAC;IAVC,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,OAAO,8BAAC,aAAK,IAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,GAAI,CAAA;IAC7C,CAAC;CACF;AAdD,8BAcC"}
1
+ {"version":3,"file":"flow-image.js","sourceRoot":"","sources":["../../../src/content-fields/flow-image.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;IAYlB,CAAC;IAVC,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,EAAU;QAClB,OAAO,8BAAC,aAAK,IAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,GAAI,CAAA;IAC1C,CAAC;CACF;AAdD,8BAcC"}
@@ -7,5 +7,5 @@ export declare class FlowText extends ContentFieldsBase {
7
7
  buttons: FlowButton[];
8
8
  buttonStyle: ButtonStyle;
9
9
  static fromHubtypeCMS(component: TextNode, locale: string): FlowText;
10
- toBotonic(index: number): JSX.Element;
10
+ toBotonic(id: string): JSX.Element;
11
11
  }
@@ -23,10 +23,10 @@ class FlowText extends content_fields_base_1.ContentFieldsBase {
23
23
  newText.buttons = component.content.buttons.map(button => flow_button_1.FlowButton.fromHubtypeCMS(button, locale));
24
24
  return newText;
25
25
  }
26
- toBotonic(index) {
27
- return (react_2.default.createElement(react_1.Text, { key: index },
26
+ toBotonic(id) {
27
+ return (react_2.default.createElement(react_1.Text, { key: id },
28
28
  this.text,
29
- this.buttons.map((button, index) => button.renderButton(index, this.buttonStyle))));
29
+ this.buttons.map(button => button.renderButton(button.id, this.buttonStyle))));
30
30
  }
31
31
  }
32
32
  exports.FlowText = FlowText;
@@ -1 +1 @@
1
- {"version":3,"file":"flow-text.js","sourceRoot":"","sources":["../../../src/content-fields/flow-text.tsx"],"names":[],"mappings":";;;;AAAA,0CAAqC;AACrC,0DAAyB;AAEzB,gEAA8D;AAC9D,+DAAyD;AACzD,+CAA0C;AAE1C,MAAa,QAAS,SAAQ,uCAAiB;IAA/C;;QACS,SAAI,GAAG,EAAE,CAAA;QACT,SAAI,GAAG,EAAE,CAAA;QACT,YAAO,GAAiB,EAAE,CAAA;QAC1B,gBAAW,GAAG,iCAAW,CAAC,MAAM,CAAA;IAuBzC,CAAC;IArBC,MAAM,CAAC,cAAc,CAAC,SAAmB,EAAE,MAAc;QACvD,MAAM,OAAO,GAAG,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC1C,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;QAC7B,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,IAAI,iCAAW,CAAC,MAAM,CAAA;QAC3E,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACvE,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CACvD,wBAAU,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAC1C,CAAA;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,SAAS,CAAC,KAAa;QACrB,OAAO,CACL,8BAAC,YAAI,IAAC,GAAG,EAAE,KAAK;YACb,IAAI,CAAC,IAAI;YACT,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MA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EAAE,CACzB,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,CACjD,CACI,CACR,CAAA;IACH,CAAC;CACF;AA3BD,4BA2BC"}
@@ -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(id: string): 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(id) {
21
+ // @ts-ignore
22
+ return react_2.default.createElement(react_1.Video, { key: id, 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,EAAU;QAClB,aAAa;QACb,OAAO,8BAAC,aAAK,IAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,GAAI,CAAA;IAC1C,CAAC;CACF;AAfD,8BAeC"}
@@ -4,4 +4,5 @@ export { FlowCarousel } from './flow-carousel';
4
4
  export { FlowElement } from './flow-element';
5
5
  export { FlowImage } from './flow-image';
6
6
  export { FlowText } from './flow-text';
7
+ export { FlowVideo } from './flow-video';
7
8
  export type { FlowContent } from './types';
@@ -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
- export type FlowContent = FlowText | FlowImage | FlowCarousel;
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 type NodeComponent = TextNode | ImageNode | CarouselNode | HandoffNode | KeywordNode | IntentNode | UrlNode | StartNode | PayloadNode | FunctionNode;
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,QAWX;AAXD,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;AACvB,CAAC,EAXW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAWnB;AA6BD,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,0CAA2B,CAAA;AAC7B,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB"}
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"}
@@ -1,2 +1,3 @@
1
1
  import { ActionRequest } from '@botonic/react';
2
- export declare function doHandoff(request: ActionRequest, queue: string, note?: string, agentEmail?: string): Promise<void>;
2
+ import { HandoffNode } from './flow-builder-models';
3
+ export declare function doHandoff(request: ActionRequest, locale: string, handoffNode: HandoffNode): Promise<void>;
@@ -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
- async function doHandoff(request, queue, note, agentEmail) {
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 flowBuilderPlugin = request.plugins.hubtypeFlowBuilder;
9
- const handoffContent = await flowBuilderPlugin.getHandoffContent();
10
- // @ts-ignore
11
- const handOffBuilder = new core_1.HandOffBuilder(request.session);
12
- handOffBuilder.withQueue(queue);
13
- if (note) {
14
- handOffBuilder.withNote(note);
15
- }
16
- if (agentEmail) {
17
- handOffBuilder.withAgentEmail(agentEmail);
18
- }
19
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20
- handOffBuilder.withOnFinishPayload((_a = handoffContent.target) === null || _a === void 0 ? void 0 : _a.id);
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;
@@ -1 +1 @@
1
- {"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/handoff.ts"],"names":[],"mappings":";;;AAAA,wCAA8C;AAGvC,KAAK,UAAU,SAAS,CAC7B,OAAsB,EACtB,KAAa,EACb,IAAa,EACb,UAAmB;;IAEnB,aAA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AAU;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,6 @@
1
+ import { Plugin } from '@botonic/core';
2
+ import BotonicPluginFlowBuilder from './index';
3
+ export declare function getFlowBuilderPlugin(plugins: {
4
+ [id: string]: Plugin;
5
+ }): BotonicPluginFlowBuilder;
6
+ export declare function updateButtonUrls(hubtypeContent: any, contentKey: string, getContentFn: any): Promise<void>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateButtonUrls = 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
+ async function updateButtonUrls(hubtypeContent, contentKey, getContentFn) {
15
+ if (hubtypeContent.content[contentKey]) {
16
+ for (const i in hubtypeContent.content[contentKey]) {
17
+ const button = hubtypeContent.content[contentKey][i].button;
18
+ if (button.url) {
19
+ for (const j in button.url) {
20
+ button.url[j] = Object.assign(Object.assign({}, button.url[j]), (await getContentFn(button.url[j].id)));
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }
26
+ exports.updateButtonUrls = updateButtonUrls;
27
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;;AAIA,MAAM,wBAAwB,GAAG,0BAA0B,CAAA;AAE3D,SAAgB,oBAAoB,CAAC,OAEpC;IACC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI;IACnD,aAAa;IACb,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,wBAAwB,CACvB,CAAA;IAC7B,IAAI,CAAC,iBAAiB;QACpB,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAA;IACH,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAZD,oDAYC;AAEM,KAAK,UAAU,gBAAgB,CACpC,cAAmB,EACnB,UAAkB,EAClB,YAAiB;IAEjB,IAAI,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QACtC,KAAK,MAAM,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAClD,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;YAC3D,IAAI,MAAM,CAAC,GAAG,EAAE;gBACd,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE;oBAC1B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,mCACR,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GACb,CAAC,MAAM,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAC1C,CAAA;iBACF;aACF;SACF;KACF;AACH,CAAC;AAlBD,4CAkBC"}
@@ -1,13 +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 type BotonicPluginFlowBuilderOptions = {
5
- flowUrl: string;
6
- flow?: FlowBuilderData;
7
- customFunctions?: Record<any, any>;
8
- getLocale: (session: Session) => string;
9
- getAccessToken: () => string;
10
- };
4
+ import { BotonicPluginFlowBuilderOptions } from './types';
11
5
  export default class BotonicPluginFlowBuilder implements Plugin {
12
6
  readonly options: BotonicPluginFlowBuilderOptions;
13
7
  private flowUrl;
@@ -17,16 +11,21 @@ export default class BotonicPluginFlowBuilder implements Plugin {
17
11
  private getAccessToken;
18
12
  getLocale: (session: Session) => string;
19
13
  constructor(options: BotonicPluginFlowBuilderOptions);
20
- readFlowContent(): Promise<FlowBuilderData>;
14
+ readFlowContent(session: Session): Promise<FlowBuilderData>;
21
15
  pre(request: PluginPreRequest): Promise<void>;
22
16
  post(_request: PluginPostRequest): Promise<void>;
23
17
  getContent(id: string): Promise<NodeComponent>;
24
- getHandoffContent(): Promise<HandoffNode>;
18
+ getHandoffContent(handoffTargetId: string | undefined): Promise<HandoffNode>;
25
19
  getFlowContent(hubtypeContent: NodeComponent, locale: string): FlowContent | undefined;
26
20
  getStartId(): Promise<string>;
27
- getContents(id: string, locale: string, prevContents?: FlowContent[]): Promise<FlowContent[]>;
28
- getPayloadByInput(input: Input, locale: string): Promise<string | undefined>;
21
+ getFallbackId(alternate: boolean): Promise<string>;
22
+ getContents(id: string, locale: string, prevContents?: FlowContent[]): Promise<{
23
+ contents: FlowContent[];
24
+ handoffNode: HandoffNode;
25
+ }>;
26
+ getPayloadByIntent(input: Input, locale: string): Promise<string | undefined>;
29
27
  hasIntent(node: IntentNode, intent: string, locale: string): boolean;
28
+ hasMetConfidenceThreshold(node: IntentNode, predictedConfidence: number): boolean;
30
29
  getPayloadByKeyword(input: Input, locale: string): Promise<string | undefined>;
31
30
  matchKeywords(node: KeywordNode, input: string, locale: string): boolean;
32
31
  containsAnyKeywords(input: string, keywords: string[]): boolean;