@botonic/plugin-flow-builder 0.35.1 → 0.36.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/lib/cjs/action/ai-agent.d.ts +3 -0
  2. package/lib/cjs/action/ai-agent.js +37 -0
  3. package/lib/cjs/action/ai-agent.js.map +1 -0
  4. package/lib/cjs/action/index.js +5 -0
  5. package/lib/cjs/action/index.js.map +1 -1
  6. package/lib/cjs/api.d.ts +1 -0
  7. package/lib/cjs/api.js +7 -0
  8. package/lib/cjs/api.js.map +1 -1
  9. package/lib/cjs/constants.d.ts +1 -0
  10. package/lib/cjs/constants.js +2 -1
  11. package/lib/cjs/constants.js.map +1 -1
  12. package/lib/cjs/content-fields/flow-ai-agent.d.ts +11 -0
  13. package/lib/cjs/content-fields/flow-ai-agent.js +26 -0
  14. package/lib/cjs/content-fields/flow-ai-agent.js.map +1 -0
  15. package/lib/cjs/content-fields/hubtype-fields/ai-agent.d.ts +9 -0
  16. package/lib/cjs/content-fields/hubtype-fields/ai-agent.js +3 -0
  17. package/lib/cjs/content-fields/hubtype-fields/ai-agent.js.map +1 -0
  18. package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +2 -1
  19. package/lib/cjs/content-fields/hubtype-fields/node-types.js +1 -0
  20. package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -1
  21. package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +2 -1
  22. package/lib/cjs/content-fields/index.d.ts +3 -4
  23. package/lib/cjs/content-fields/index.js +7 -5
  24. package/lib/cjs/content-fields/index.js.map +1 -1
  25. package/lib/cjs/index.d.ts +2 -1
  26. package/lib/cjs/index.js +3 -0
  27. package/lib/cjs/index.js.map +1 -1
  28. package/lib/cjs/types.d.ts +12 -0
  29. package/lib/cjs/types.js.map +1 -1
  30. package/lib/esm/action/ai-agent.d.ts +3 -0
  31. package/lib/esm/action/ai-agent.js +33 -0
  32. package/lib/esm/action/ai-agent.js.map +1 -0
  33. package/lib/esm/action/index.js +5 -0
  34. package/lib/esm/action/index.js.map +1 -1
  35. package/lib/esm/api.d.ts +1 -0
  36. package/lib/esm/api.js +8 -1
  37. package/lib/esm/api.js.map +1 -1
  38. package/lib/esm/constants.d.ts +1 -0
  39. package/lib/esm/constants.js +1 -0
  40. package/lib/esm/constants.js.map +1 -1
  41. package/lib/esm/content-fields/flow-ai-agent.d.ts +11 -0
  42. package/lib/esm/content-fields/flow-ai-agent.js +22 -0
  43. package/lib/esm/content-fields/flow-ai-agent.js.map +1 -0
  44. package/lib/esm/content-fields/hubtype-fields/ai-agent.d.ts +9 -0
  45. package/lib/esm/content-fields/hubtype-fields/ai-agent.js +2 -0
  46. package/lib/esm/content-fields/hubtype-fields/ai-agent.js.map +1 -0
  47. package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +2 -1
  48. package/lib/esm/content-fields/hubtype-fields/node-types.js +1 -0
  49. package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -1
  50. package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +2 -1
  51. package/lib/esm/content-fields/index.d.ts +3 -4
  52. package/lib/esm/content-fields/index.js +4 -3
  53. package/lib/esm/content-fields/index.js.map +1 -1
  54. package/lib/esm/index.d.ts +2 -1
  55. package/lib/esm/index.js +4 -1
  56. package/lib/esm/index.js.map +1 -1
  57. package/lib/esm/types.d.ts +12 -0
  58. package/lib/esm/types.js.map +1 -1
  59. package/package.json +1 -1
  60. package/src/action/ai-agent.ts +52 -0
  61. package/src/action/index.tsx +5 -0
  62. package/src/api.ts +18 -1
  63. package/src/constants.ts +1 -0
  64. package/src/content-fields/flow-ai-agent.tsx +23 -0
  65. package/src/content-fields/hubtype-fields/ai-agent.ts +10 -0
  66. package/src/content-fields/hubtype-fields/node-types.ts +1 -0
  67. package/src/content-fields/hubtype-fields/nodes.ts +2 -0
  68. package/src/content-fields/index.ts +5 -3
  69. package/src/index.ts +7 -0
  70. package/src/types.ts +18 -0
@@ -7,5 +7,6 @@ export const REG_EXP_PATTERN = /^\/(.*)\/([gimyus]*)$/;
7
7
  export const UUID_REGEXP = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
8
8
  export const MAIN_FLOW_NAME = 'Main';
9
9
  export const KNOWLEDGE_BASE_FLOW_NAME = 'Knowledge base';
10
+ export const AI_AGENTS_FLOW_NAME = 'AI agents';
10
11
  export const FALLBACK_FLOW_NAME = 'Fallback';
11
12
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GACpC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;AAC1D,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;AAC5B,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,SAAS,SAAS,CAAA;AAC1D,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAA;AAC5C,MAAM,CAAC,MAAM,yBAAyB,GAAG,eAAe,CAAA;AACxD,MAAM,CAAC,MAAM,eAAe,GAAG,uBAAuB,CAAA;AACtD,MAAM,CAAC,MAAM,WAAW,GACtB,iEAAiE,CAAA;AAEnE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAA;AACpC,MAAM,CAAC,MAAM,wBAAwB,GAAG,gBAAgB,CAAA;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAA"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GACpC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;AAC1D,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;AAC5B,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,SAAS,SAAS,CAAA;AAC1D,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAA;AAC5C,MAAM,CAAC,MAAM,yBAAyB,GAAG,eAAe,CAAA;AACxD,MAAM,CAAC,MAAM,eAAe,GAAG,uBAAuB,CAAA;AACtD,MAAM,CAAC,MAAM,WAAW,GACtB,iEAAiE,CAAA;AAEnE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAA;AACpC,MAAM,CAAC,MAAM,wBAAwB,GAAG,gBAAgB,CAAA;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAA;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAA"}
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { ContentFieldsBase } from './content-fields-base';
3
+ import { HtAiAgentNode } from './hubtype-fields/ai-agent';
4
+ export declare class FlowAiAgent extends ContentFieldsBase {
5
+ code: string;
6
+ name: string;
7
+ instructions: string;
8
+ text: string;
9
+ static fromHubtypeCMS(component: HtAiAgentNode): FlowAiAgent;
10
+ toBotonic(id: string): JSX.Element;
11
+ }
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Text } from '@botonic/react';
3
+ import { ContentFieldsBase } from './content-fields-base';
4
+ export class FlowAiAgent extends ContentFieldsBase {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.code = '';
8
+ this.name = '';
9
+ this.instructions = '';
10
+ this.text = '';
11
+ }
12
+ static fromHubtypeCMS(component) {
13
+ const newAiAgent = new FlowAiAgent(component.id);
14
+ newAiAgent.name = component.content.name;
15
+ newAiAgent.instructions = component.content.instructions;
16
+ return newAiAgent;
17
+ }
18
+ toBotonic(id) {
19
+ return _jsx(Text, { children: this.text }, id);
20
+ }
21
+ }
22
+ //# sourceMappingURL=flow-ai-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-ai-agent.js","sourceRoot":"","sources":["../../../src/content-fields/flow-ai-agent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAGzD,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IAAlD;;QACS,SAAI,GAAW,EAAE,CAAA;QACjB,SAAI,GAAW,EAAE,CAAA;QACjB,iBAAY,GAAW,EAAE,CAAA;QACzB,SAAI,GAAW,EAAE,CAAA;IAa1B,CAAC;IAXC,MAAM,CAAC,cAAc,CAAC,SAAwB;QAC5C,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAChD,UAAU,CAAC,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAA;QACxC,UAAU,CAAC,YAAY,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,CAAA;QAExD,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,SAAS,CAAC,EAAU;QAClB,OAAO,KAAC,IAAI,cAAW,IAAI,CAAC,IAAI,IAAd,EAAE,CAAoB,CAAA;IAC1C,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import { HtBaseNode } from './common';
2
+ import { HtNodeWithContentType } from './node-types';
3
+ export interface HtAiAgentNode extends HtBaseNode {
4
+ type: HtNodeWithContentType.AI_AGENT;
5
+ content: {
6
+ name: string;
7
+ instructions: string;
8
+ };
9
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ai-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-agent.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/ai-agent.ts"],"names":[],"mappings":""}
@@ -11,7 +11,8 @@ export declare enum HtNodeWithContentType {
11
11
  WHATSAPP_BUTTON_LIST = "whatsapp-button-list",
12
12
  WHATSAPP_CTA_URL_BUTTON = "whatsapp-cta-url-button",
13
13
  KNOWLEDGE_BASE = "knowledge-base",
14
- BOT_ACTION = "bot-action"
14
+ BOT_ACTION = "bot-action",
15
+ AI_AGENT = "ai-agent"
15
16
  }
16
17
  export declare enum HtNodeWithoutContentType {
17
18
  URL = "url",
@@ -13,6 +13,7 @@ export var HtNodeWithContentType;
13
13
  HtNodeWithContentType["WHATSAPP_CTA_URL_BUTTON"] = "whatsapp-cta-url-button";
14
14
  HtNodeWithContentType["KNOWLEDGE_BASE"] = "knowledge-base";
15
15
  HtNodeWithContentType["BOT_ACTION"] = "bot-action";
16
+ HtNodeWithContentType["AI_AGENT"] = "ai-agent";
16
17
  })(HtNodeWithContentType || (HtNodeWithContentType = {}));
17
18
  export var HtNodeWithoutContentType;
18
19
  (function (HtNodeWithoutContentType) {
@@ -1 +1 @@
1
- {"version":3,"file":"node-types.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/node-types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,qBAcX;AAdD,WAAY,qBAAqB;IAC/B,8CAAqB,CAAA;IACrB,4CAAmB,CAAA;IACnB,wCAAe,CAAA;IACf,sCAAa,CAAA;IACb,4CAAmB,CAAA;IACnB,sDAA6B,CAAA;IAC7B,8CAAqB,CAAA;IACrB,8CAAqB,CAAA;IACrB,wCAAe,CAAA;IACf,sEAA6C,CAAA;IAC7C,4EAAmD,CAAA;IACnD,0DAAiC,CAAA;IACjC,kDAAyB,CAAA;AAC3B,CAAC,EAdW,qBAAqB,KAArB,qBAAqB,QAchC;AAED,MAAM,CAAN,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,uCAAW,CAAA;IACX,+CAAmB,CAAA;IACnB,qDAAyB,CAAA;AAC3B,CAAC,EAJW,wBAAwB,KAAxB,wBAAwB,QAInC;AAED,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,4CAA2B,CAAA;AAC7B,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB"}
1
+ {"version":3,"file":"node-types.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/node-types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,qBAeX;AAfD,WAAY,qBAAqB;IAC/B,8CAAqB,CAAA;IACrB,4CAAmB,CAAA;IACnB,wCAAe,CAAA;IACf,sCAAa,CAAA;IACb,4CAAmB,CAAA;IACnB,sDAA6B,CAAA;IAC7B,8CAAqB,CAAA;IACrB,8CAAqB,CAAA;IACrB,wCAAe,CAAA;IACf,sEAA6C,CAAA;IAC7C,4EAAmD,CAAA;IACnD,0DAAiC,CAAA;IACjC,kDAAyB,CAAA;IACzB,8CAAqB,CAAA;AACvB,CAAC,EAfW,qBAAqB,KAArB,qBAAqB,QAehC;AAED,MAAM,CAAN,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,uCAAW,CAAA;IACX,+CAAmB,CAAA;IACnB,qDAAyB,CAAA;AAC3B,CAAC,EAJW,wBAAwB,KAAxB,wBAAwB,QAInC;AAED,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,4CAA2B,CAAA;AAC7B,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB"}
@@ -1,3 +1,4 @@
1
+ import { HtAiAgentNode } from './ai-agent';
1
2
  import { HtBotActionNode } from './bot-action';
2
3
  import { HtCarouselNode } from './carousel';
3
4
  import { HtFallbackNode } from './fallback';
@@ -14,6 +15,6 @@ import { HtUrlNode } from './url';
14
15
  import { HtVideoNode } from './video';
15
16
  import { HtWhatsappButtonListNode } from './whatsapp-button-list';
16
17
  import { HtWhatsappCTAUrlButtonNode } from './whatsapp-cta-url-button';
17
- export type HtNodeWithContent = HtTextNode | HtImageNode | HtVideoNode | HtCarouselNode | HtHandoffNode | HtKeywordNode | HtFunctionNode | HtFallbackNode | HtWhatsappButtonListNode | HtWhatsappCTAUrlButtonNode | HtSmartIntentNode | HtKnowledgeBaseNode | HtBotActionNode;
18
+ export type HtNodeWithContent = HtTextNode | HtImageNode | HtVideoNode | HtCarouselNode | HtHandoffNode | HtKeywordNode | HtFunctionNode | HtFallbackNode | HtWhatsappButtonListNode | HtWhatsappCTAUrlButtonNode | HtSmartIntentNode | HtKnowledgeBaseNode | HtBotActionNode | HtAiAgentNode;
18
19
  export type HtNodeWithoutContent = HtUrlNode | HtPayloadNode | HtGoToFlow;
19
20
  export type HtNodeComponent = HtNodeWithContent | HtNodeWithoutContent;
@@ -1,3 +1,4 @@
1
+ import { FlowAiAgent } from './flow-ai-agent';
1
2
  import { FlowBotAction } from './flow-bot-action';
2
3
  import { FlowCarousel } from './flow-carousel';
3
4
  import { FlowHandoff } from './flow-handoff';
@@ -10,8 +11,6 @@ import { FlowWhatsappButtonList } from './whatsapp-button-list/flow-whatsapp-but
10
11
  export { ContentFieldsBase } from './content-fields-base';
11
12
  export { FlowButton } from './flow-button';
12
13
  export { FlowElement } from './flow-element';
13
- export { FlowBotAction, FlowCarousel, FlowImage, FlowKnowledgeBase, FlowText, FlowVideo, FlowWhatsappButtonList, };
14
- export { FlowHandoff } from './flow-handoff';
15
- export { FlowWhatsappCtaUrlButtonNode } from './flow-whatsapp-cta-url-button';
16
- export type FlowContent = FlowCarousel | FlowImage | FlowText | FlowVideo | FlowWhatsappButtonList | FlowWhatsappCtaUrlButtonNode | FlowHandoff | FlowKnowledgeBase | FlowBotAction;
14
+ export { FlowAiAgent, FlowBotAction, FlowCarousel, FlowHandoff, FlowImage, FlowKnowledgeBase, FlowText, FlowVideo, FlowWhatsappButtonList, FlowWhatsappCtaUrlButtonNode, };
15
+ export type FlowContent = FlowCarousel | FlowImage | FlowText | FlowVideo | FlowWhatsappButtonList | FlowWhatsappCtaUrlButtonNode | FlowHandoff | FlowKnowledgeBase | FlowBotAction | FlowAiAgent;
17
16
  export { DISABLED_MEMORY_LENGTH };
@@ -1,15 +1,16 @@
1
+ import { FlowAiAgent } from './flow-ai-agent';
1
2
  import { FlowBotAction } from './flow-bot-action';
2
3
  import { FlowCarousel } from './flow-carousel';
4
+ import { FlowHandoff } from './flow-handoff';
3
5
  import { FlowImage } from './flow-image';
4
6
  import { DISABLED_MEMORY_LENGTH, FlowKnowledgeBase, } from './flow-knowledge-base';
5
7
  import { FlowText } from './flow-text';
6
8
  import { FlowVideo } from './flow-video';
9
+ import { FlowWhatsappCtaUrlButtonNode } from './flow-whatsapp-cta-url-button';
7
10
  import { FlowWhatsappButtonList } from './whatsapp-button-list/flow-whatsapp-button-list';
8
11
  export { ContentFieldsBase } from './content-fields-base';
9
12
  export { FlowButton } from './flow-button';
10
13
  export { FlowElement } from './flow-element';
11
- export { FlowBotAction, FlowCarousel, FlowImage, FlowKnowledgeBase, FlowText, FlowVideo, FlowWhatsappButtonList, };
12
- export { FlowHandoff } from './flow-handoff';
13
- export { FlowWhatsappCtaUrlButtonNode } from './flow-whatsapp-cta-url-button';
14
+ export { FlowAiAgent, FlowBotAction, FlowCarousel, FlowHandoff, FlowImage, FlowKnowledgeBase, FlowText, FlowVideo, FlowWhatsappButtonList, FlowWhatsappCtaUrlButtonNode, };
14
15
  export { DISABLED_MEMORY_LENGTH };
15
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content-fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAA;AAEzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,UAA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D,OAAO,EAAE,sBAAsB,EAAE,CAAA"}
@@ -2,7 +2,7 @@ import { Plugin, PluginPreRequest, ResolvedPlugins, Session } from '@botonic/cor
2
2
  import { FlowBuilderApi } from './api';
3
3
  import { FlowContent } from './content-fields';
4
4
  import { HtNodeWithContent } from './content-fields/hubtype-fields';
5
- import { BotonicPluginFlowBuilderOptions, FlowBuilderJSONVersion, InShadowingConfig, KnowledgeBaseFunction, PayloadParamsBase, TrackEventFunction } from './types';
5
+ import { AiAgentFunction, BotonicPluginFlowBuilderOptions, FlowBuilderJSONVersion, InShadowingConfig, KnowledgeBaseFunction, PayloadParamsBase, TrackEventFunction } from './types';
6
6
  import { SmartIntentsInferenceConfig } from './user-input/smart-intent';
7
7
  export default class BotonicPluginFlowBuilder implements Plugin {
8
8
  cmsApi: FlowBuilderApi;
@@ -12,6 +12,7 @@ export default class BotonicPluginFlowBuilder implements Plugin {
12
12
  getAccessToken: (session: Session) => string;
13
13
  trackEvent?: TrackEventFunction;
14
14
  getKnowledgeBaseResponse?: KnowledgeBaseFunction;
15
+ getAiAgentResponse?: AiAgentFunction;
15
16
  smartIntentsConfig: SmartIntentsInferenceConfig;
16
17
  inShadowing: InShadowingConfig;
17
18
  jsonVersion: FlowBuilderJSONVersion;
package/lib/esm/index.js CHANGED
@@ -2,7 +2,7 @@ import { __awaiter } from "tslib";
2
2
  import { v7 as uuidv7 } from 'uuid';
3
3
  import { FlowBuilderApi } from './api';
4
4
  import { FLOW_BUILDER_API_URL_PROD, SEPARATOR, SOURCE_INFO_SEPARATOR, } from './constants';
5
- import { FlowBotAction, FlowCarousel, FlowHandoff, FlowImage, FlowKnowledgeBase, FlowText, FlowVideo, FlowWhatsappButtonList, FlowWhatsappCtaUrlButtonNode, } from './content-fields';
5
+ import { FlowAiAgent, FlowBotAction, FlowCarousel, FlowHandoff, FlowImage, FlowKnowledgeBase, FlowText, FlowVideo, FlowWhatsappButtonList, FlowWhatsappCtaUrlButtonNode, } from './content-fields';
6
6
  import { HtNodeWithContentType, } from './content-fields/hubtype-fields';
7
7
  import { DEFAULT_FUNCTIONS } from './functions';
8
8
  import { FlowBuilderJSONVersion, } from './types';
@@ -18,6 +18,7 @@ export default class BotonicPluginFlowBuilder {
18
18
  this.getAccessToken = resolveGetAccessToken(options.getAccessToken);
19
19
  this.trackEvent = options.trackEvent;
20
20
  this.getKnowledgeBaseResponse = options.getKnowledgeBaseResponse;
21
+ this.getAiAgentResponse = options.getAiAgentResponse;
21
22
  this.smartIntentsConfig = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.smartIntentsConfig), { useLatest: this.jsonVersion === FlowBuilderJSONVersion.LATEST });
22
23
  const customFunctions = options.customFunctions || {};
23
24
  this.functions = Object.assign(Object.assign({}, DEFAULT_FUNCTIONS), customFunctions);
@@ -132,6 +133,8 @@ export default class BotonicPluginFlowBuilder {
132
133
  return FlowHandoff.fromHubtypeCMS(hubtypeContent, locale, this.cmsApi);
133
134
  case HtNodeWithContentType.KNOWLEDGE_BASE:
134
135
  return FlowKnowledgeBase.fromHubtypeCMS(hubtypeContent);
136
+ case HtNodeWithContentType.AI_AGENT:
137
+ return FlowAiAgent.fromHubtypeCMS(hubtypeContent);
135
138
  case HtNodeWithContentType.BOT_ACTION:
136
139
  return FlowBotAction.fromHubtypeCMS(hubtypeContent, locale, this.cmsApi);
137
140
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EACL,yBAAyB,EACzB,SAAS,EACT,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,aAAa,EACb,YAAY,EAEZ,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACT,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM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BACjB,eAAe,GAAG,CAAC,GAAG,eAAe,EAAE,GAAG,CAAC,CAAA;aAC5C;SACF;QAED,OAAO,eAAe,CAAA;IACxB,CAAC;IAED,gBAAgB,CAA8B,OAAe;QAC3D,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAA;QACrE,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,WAAW,CAAC,MAAc;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;CACF;AAED,cAAc,UAAU,CAAA;AACxB,cAAc,kBAAkB,CAAA;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAEL,sBAAsB,GAEvB,MAAM,SAAS,CAAA;AAChB,cAAc,WAAW,CAAA"}
@@ -13,6 +13,7 @@ export interface BotonicPluginFlowBuilderOptions<TPlugins extends ResolvedPlugin
13
13
  getAccessToken: () => string;
14
14
  trackEvent?: TrackEventFunction<TPlugins, TExtraData>;
15
15
  getKnowledgeBaseResponse?: KnowledgeBaseFunction<TPlugins, TExtraData>;
16
+ getAiAgentResponse?: AiAgentFunction<TPlugins, TExtraData>;
16
17
  smartIntentsConfig?: {
17
18
  numSmartIntentsToUse: number;
18
19
  };
@@ -20,6 +21,11 @@ export interface BotonicPluginFlowBuilderOptions<TPlugins extends ResolvedPlugin
20
21
  }
21
22
  export type TrackEventFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, eventAction: string, args?: Record<string, any>) => Promise<void>;
22
23
  export type KnowledgeBaseFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, sources: string[], instructions: string, messageId: string, memoryLength: number) => Promise<KnowledgeBaseResponse>;
24
+ export type AiAgentFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, aiAgentArgs: AiAgentArgs) => Promise<AiAgentResponse>;
25
+ export interface AiAgentArgs {
26
+ name: string;
27
+ instructions: string;
28
+ }
23
29
  export interface FlowBuilderApiOptions {
24
30
  url: string;
25
31
  flowUrl: string;
@@ -42,6 +48,12 @@ export interface KnowledgeBaseResponse {
42
48
  chunkIds: string[];
43
49
  answer: string;
44
50
  }
51
+ export interface AiAgentResponse {
52
+ message: {
53
+ role: string;
54
+ content: string;
55
+ };
56
+ }
45
57
  export interface SmartIntentResponse {
46
58
  data: {
47
59
  smart_intent_title: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AA0DA,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;AAC7B,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAED,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;AACnB,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAwEA,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;AAC7B,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAED,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;AACnB,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botonic/plugin-flow-builder",
3
- "version": "0.35.1",
3
+ "version": "0.36.0-alpha.0",
4
4
  "main": "./lib/cjs/index.js",
5
5
  "module": "./lib/esm/index.js",
6
6
  "description": "Use Flow Builder to show your contents",
@@ -0,0 +1,52 @@
1
+ import { FlowContent } from '../content-fields'
2
+ import { FlowAiAgent } from '../content-fields/flow-ai-agent'
3
+ import { AiAgentResponse } from '../types'
4
+ import { FlowBuilderContext } from './index'
5
+
6
+ export async function getContentsByAiAgent({
7
+ cmsApi,
8
+ flowBuilderPlugin,
9
+ request,
10
+ }: FlowBuilderContext): Promise<FlowContent[]> {
11
+ const startNodeAiAgentFlow = cmsApi.getStartNodeAiAgentFlow()
12
+ if (!startNodeAiAgentFlow) {
13
+ return []
14
+ }
15
+
16
+ const contents =
17
+ await flowBuilderPlugin.getContentsByNode(startNodeAiAgentFlow)
18
+ const aiAgentContent = contents.find(
19
+ content => content instanceof FlowAiAgent
20
+ ) as FlowAiAgent
21
+
22
+ if (!aiAgentContent) {
23
+ return []
24
+ }
25
+
26
+ const aiAgentResponse = await flowBuilderPlugin.getAiAgentResponse?.(
27
+ request,
28
+ {
29
+ name: aiAgentContent.name,
30
+ instructions: aiAgentContent.instructions,
31
+ }
32
+ )
33
+
34
+ if (!aiAgentResponse) {
35
+ return []
36
+ }
37
+
38
+ return updateContentsWithAiAgentResponse(contents, aiAgentResponse)
39
+ }
40
+
41
+ function updateContentsWithAiAgentResponse(
42
+ contents: FlowContent[],
43
+ aiAgentResponse: AiAgentResponse
44
+ ): FlowContent[] {
45
+ return contents.map(content => {
46
+ if (content instanceof FlowAiAgent) {
47
+ content.text = aiAgentResponse.message.content
48
+ }
49
+
50
+ return content
51
+ })
52
+ }
@@ -9,6 +9,7 @@ import { getFlowBuilderPlugin } from '../helpers'
9
9
  import BotonicPluginFlowBuilder from '../index'
10
10
  import { trackFlowContent } from '../tracking'
11
11
  import { inputHasTextData } from '../utils'
12
+ import { getContentsByAiAgent } from './ai-agent'
12
13
  import { getContentsByFallback } from './fallback'
13
14
  import { getContentsByFirstInteraction } from './first-interaction'
14
15
  import { getContentsByKnowledgeBase } from './knowledge-bases'
@@ -106,6 +107,10 @@ async function getContents(
106
107
  }
107
108
 
108
109
  if (inputHasTextData(request.input)) {
110
+ const aiAgentContents = await getContentsByAiAgent(context)
111
+ if (aiAgentContents.length > 0) {
112
+ return aiAgentContents
113
+ }
109
114
  const knowledgeBaseContents = await getContentsByKnowledgeBase(context)
110
115
  if (knowledgeBaseContents.length > 0) {
111
116
  return knowledgeBaseContents
package/src/api.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  import { Input, PluginPreRequest } from '@botonic/core'
2
2
  import axios from 'axios'
3
3
 
4
- import { KNOWLEDGE_BASE_FLOW_NAME, SEPARATOR, UUID_REGEXP } from './constants'
4
+ import {
5
+ AI_AGENTS_FLOW_NAME,
6
+ KNOWLEDGE_BASE_FLOW_NAME,
7
+ SEPARATOR,
8
+ UUID_REGEXP,
9
+ } from './constants'
5
10
  import {
6
11
  HtBotActionNode,
7
12
  HtFallbackNode,
@@ -202,6 +207,18 @@ export class FlowBuilderApi {
202
207
  return this.getNodeById<HtNodeWithContent>(knowledgeBaseFlow.start_node_id)
203
208
  }
204
209
 
210
+ getStartNodeAiAgentFlow(): HtNodeWithContent | undefined {
211
+ const aiAgentFlow = this.flow.flows.find(
212
+ flow => flow.name === AI_AGENTS_FLOW_NAME
213
+ )
214
+
215
+ if (!aiAgentFlow) {
216
+ return undefined
217
+ }
218
+
219
+ return this.getNodeById<HtNodeWithContent>(aiAgentFlow.start_node_id)
220
+ }
221
+
205
222
  isKnowledgeBaseEnabled(): boolean {
206
223
  return this.flow.is_knowledge_base_active || false
207
224
  }
package/src/constants.ts CHANGED
@@ -10,4 +10,5 @@ export const UUID_REGEXP =
10
10
 
11
11
  export const MAIN_FLOW_NAME = 'Main'
12
12
  export const KNOWLEDGE_BASE_FLOW_NAME = 'Knowledge base'
13
+ export const AI_AGENTS_FLOW_NAME = 'AI agents'
13
14
  export const FALLBACK_FLOW_NAME = 'Fallback'
@@ -0,0 +1,23 @@
1
+ import { Text } from '@botonic/react'
2
+
3
+ import { ContentFieldsBase } from './content-fields-base'
4
+ import { HtAiAgentNode } from './hubtype-fields/ai-agent'
5
+
6
+ export class FlowAiAgent extends ContentFieldsBase {
7
+ public code: string = ''
8
+ public name: string = ''
9
+ public instructions: string = ''
10
+ public text: string = ''
11
+
12
+ static fromHubtypeCMS(component: HtAiAgentNode): FlowAiAgent {
13
+ const newAiAgent = new FlowAiAgent(component.id)
14
+ newAiAgent.name = component.content.name
15
+ newAiAgent.instructions = component.content.instructions
16
+
17
+ return newAiAgent
18
+ }
19
+
20
+ toBotonic(id: string): JSX.Element {
21
+ return <Text key={id}>{this.text}</Text>
22
+ }
23
+ }
@@ -0,0 +1,10 @@
1
+ import { HtBaseNode } from './common'
2
+ import { HtNodeWithContentType } from './node-types'
3
+
4
+ export interface HtAiAgentNode extends HtBaseNode {
5
+ type: HtNodeWithContentType.AI_AGENT
6
+ content: {
7
+ name: string
8
+ instructions: string
9
+ }
10
+ }
@@ -12,6 +12,7 @@ export enum HtNodeWithContentType {
12
12
  WHATSAPP_CTA_URL_BUTTON = 'whatsapp-cta-url-button',
13
13
  KNOWLEDGE_BASE = 'knowledge-base',
14
14
  BOT_ACTION = 'bot-action',
15
+ AI_AGENT = 'ai-agent',
15
16
  }
16
17
 
17
18
  export enum HtNodeWithoutContentType {
@@ -1,3 +1,4 @@
1
+ import { HtAiAgentNode } from './ai-agent'
1
2
  import { HtBotActionNode } from './bot-action'
2
3
  import { HtCarouselNode } from './carousel'
3
4
  import { HtFallbackNode } from './fallback'
@@ -29,6 +30,7 @@ export type HtNodeWithContent =
29
30
  | HtSmartIntentNode
30
31
  | HtKnowledgeBaseNode
31
32
  | HtBotActionNode
33
+ | HtAiAgentNode
32
34
 
33
35
  export type HtNodeWithoutContent = HtUrlNode | HtPayloadNode | HtGoToFlow
34
36
 
@@ -1,3 +1,4 @@
1
+ import { FlowAiAgent } from './flow-ai-agent'
1
2
  import { FlowBotAction } from './flow-bot-action'
2
3
  import { FlowCarousel } from './flow-carousel'
3
4
  import { FlowHandoff } from './flow-handoff'
@@ -10,21 +11,21 @@ import { FlowText } from './flow-text'
10
11
  import { FlowVideo } from './flow-video'
11
12
  import { FlowWhatsappCtaUrlButtonNode } from './flow-whatsapp-cta-url-button'
12
13
  import { FlowWhatsappButtonList } from './whatsapp-button-list/flow-whatsapp-button-list'
13
-
14
14
  export { ContentFieldsBase } from './content-fields-base'
15
15
  export { FlowButton } from './flow-button'
16
16
  export { FlowElement } from './flow-element'
17
17
  export {
18
+ FlowAiAgent,
18
19
  FlowBotAction,
19
20
  FlowCarousel,
21
+ FlowHandoff,
20
22
  FlowImage,
21
23
  FlowKnowledgeBase,
22
24
  FlowText,
23
25
  FlowVideo,
24
26
  FlowWhatsappButtonList,
27
+ FlowWhatsappCtaUrlButtonNode,
25
28
  }
26
- export { FlowHandoff } from './flow-handoff'
27
- export { FlowWhatsappCtaUrlButtonNode } from './flow-whatsapp-cta-url-button'
28
29
 
29
30
  export type FlowContent =
30
31
  | FlowCarousel
@@ -36,5 +37,6 @@ export type FlowContent =
36
37
  | FlowHandoff
37
38
  | FlowKnowledgeBase
38
39
  | FlowBotAction
40
+ | FlowAiAgent
39
41
 
40
42
  export { DISABLED_MEMORY_LENGTH }
package/src/index.ts CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  SOURCE_INFO_SEPARATOR,
15
15
  } from './constants'
16
16
  import {
17
+ FlowAiAgent,
17
18
  FlowBotAction,
18
19
  FlowCarousel,
19
20
  FlowContent,
@@ -37,6 +38,7 @@ import {
37
38
  } from './content-fields/hubtype-fields'
38
39
  import { DEFAULT_FUNCTIONS } from './functions'
39
40
  import {
41
+ AiAgentFunction,
40
42
  BotonicPluginFlowBuilderOptions,
41
43
  FlowBuilderJSONVersion,
42
44
  InShadowingConfig,
@@ -58,6 +60,7 @@ export default class BotonicPluginFlowBuilder implements Plugin {
58
60
  public getAccessToken: (session: Session) => string
59
61
  public trackEvent?: TrackEventFunction
60
62
  public getKnowledgeBaseResponse?: KnowledgeBaseFunction
63
+ public getAiAgentResponse?: AiAgentFunction
61
64
  public smartIntentsConfig: SmartIntentsInferenceConfig
62
65
  public inShadowing: InShadowingConfig
63
66
 
@@ -72,6 +75,7 @@ export default class BotonicPluginFlowBuilder implements Plugin {
72
75
  this.getAccessToken = resolveGetAccessToken(options.getAccessToken)
73
76
  this.trackEvent = options.trackEvent
74
77
  this.getKnowledgeBaseResponse = options.getKnowledgeBaseResponse
78
+ this.getAiAgentResponse = options.getAiAgentResponse
75
79
  this.smartIntentsConfig = {
76
80
  ...options?.smartIntentsConfig,
77
81
  useLatest: this.jsonVersion === FlowBuilderJSONVersion.LATEST,
@@ -230,6 +234,9 @@ export default class BotonicPluginFlowBuilder implements Plugin {
230
234
  case HtNodeWithContentType.KNOWLEDGE_BASE:
231
235
  return FlowKnowledgeBase.fromHubtypeCMS(hubtypeContent)
232
236
 
237
+ case HtNodeWithContentType.AI_AGENT:
238
+ return FlowAiAgent.fromHubtypeCMS(hubtypeContent)
239
+
233
240
  case HtNodeWithContentType.BOT_ACTION:
234
241
  return FlowBotAction.fromHubtypeCMS(hubtypeContent, locale, this.cmsApi)
235
242
 
package/src/types.ts CHANGED
@@ -24,6 +24,7 @@ export interface BotonicPluginFlowBuilderOptions<
24
24
  getAccessToken: () => string
25
25
  trackEvent?: TrackEventFunction<TPlugins, TExtraData>
26
26
  getKnowledgeBaseResponse?: KnowledgeBaseFunction<TPlugins, TExtraData>
27
+ getAiAgentResponse?: AiAgentFunction<TPlugins, TExtraData>
27
28
  smartIntentsConfig?: { numSmartIntentsToUse: number }
28
29
  inShadowing?: Partial<InShadowingConfig>
29
30
  }
@@ -48,6 +49,19 @@ export type KnowledgeBaseFunction<
48
49
  memoryLength: number
49
50
  ) => Promise<KnowledgeBaseResponse>
50
51
 
52
+ export type AiAgentFunction<
53
+ TPlugins extends ResolvedPlugins = ResolvedPlugins,
54
+ TExtraData = any,
55
+ > = (
56
+ request: BotContext<TPlugins, TExtraData>,
57
+ aiAgentArgs: AiAgentArgs
58
+ ) => Promise<AiAgentResponse>
59
+
60
+ export interface AiAgentArgs {
61
+ name: string
62
+ instructions: string
63
+ }
64
+
51
65
  export interface FlowBuilderApiOptions {
52
66
  url: string
53
67
  flowUrl: string
@@ -74,6 +88,10 @@ export interface KnowledgeBaseResponse {
74
88
  answer: string
75
89
  }
76
90
 
91
+ export interface AiAgentResponse {
92
+ message: { role: string; content: string }
93
+ }
94
+
77
95
  export interface SmartIntentResponse {
78
96
  data: {
79
97
  smart_intent_title: string