@botonic/plugin-flow-builder 0.37.1 → 0.38.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.
- package/lib/cjs/action/ai-agent.js +9 -4
- package/lib/cjs/action/ai-agent.js.map +1 -1
- package/lib/cjs/action/fallback.js +6 -2
- package/lib/cjs/action/fallback.js.map +1 -1
- package/lib/cjs/action/first-interaction.js +22 -3
- package/lib/cjs/action/first-interaction.js.map +1 -1
- package/lib/cjs/action/index.js +2 -1
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/action/knowledge-bases.js +31 -29
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/action/payload.js +2 -2
- package/lib/cjs/action/payload.js.map +1 -1
- package/lib/cjs/constants.d.ts +1 -0
- package/lib/cjs/constants.js +2 -1
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/content-fields/flow-ai-agent.d.ts +3 -2
- package/lib/cjs/content-fields/flow-ai-agent.js +4 -2
- package/lib/cjs/content-fields/flow-ai-agent.js.map +1 -1
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.d.ts +2 -2
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js +5 -1
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/ai-agent.d.ts +6 -0
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +2 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +7 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
- package/lib/cjs/tracking.d.ts +1 -12
- package/lib/cjs/tracking.js +15 -31
- package/lib/cjs/tracking.js.map +1 -1
- package/lib/cjs/types.d.ts +8 -44
- package/lib/cjs/types.js.map +1 -1
- package/lib/cjs/user-input/keyword.js +7 -5
- package/lib/cjs/user-input/keyword.js.map +1 -1
- package/lib/cjs/user-input/smart-intent.js +5 -2
- package/lib/cjs/user-input/smart-intent.js.map +1 -1
- package/lib/esm/action/ai-agent.js +9 -4
- package/lib/esm/action/ai-agent.js.map +1 -1
- package/lib/esm/action/fallback.js +8 -4
- package/lib/esm/action/fallback.js.map +1 -1
- package/lib/esm/action/first-interaction.js +22 -3
- package/lib/esm/action/first-interaction.js.map +1 -1
- package/lib/esm/action/index.js +2 -1
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/action/knowledge-bases.js +33 -31
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/action/payload.js +2 -2
- package/lib/esm/action/payload.js.map +1 -1
- package/lib/esm/constants.d.ts +1 -0
- package/lib/esm/constants.js +1 -0
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/content-fields/flow-ai-agent.d.ts +3 -2
- package/lib/esm/content-fields/flow-ai-agent.js +5 -3
- package/lib/esm/content-fields/flow-ai-agent.js.map +1 -1
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.d.ts +2 -2
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js +7 -3
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/ai-agent.d.ts +6 -0
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +2 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +9 -3
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
- package/lib/esm/tracking.d.ts +1 -12
- package/lib/esm/tracking.js +15 -31
- package/lib/esm/tracking.js.map +1 -1
- package/lib/esm/types.d.ts +8 -44
- package/lib/esm/types.js.map +1 -1
- package/lib/esm/user-input/keyword.js +10 -8
- package/lib/esm/user-input/keyword.js.map +1 -1
- package/lib/esm/user-input/smart-intent.js +8 -5
- package/lib/esm/user-input/smart-intent.js.map +1 -1
- package/package.json +2 -2
- package/src/action/ai-agent.ts +12 -2
- package/src/action/fallback.ts +9 -4
- package/src/action/first-interaction.ts +27 -3
- package/src/action/index.tsx +2 -1
- package/src/action/knowledge-bases.ts +47 -43
- package/src/action/payload.ts +3 -3
- package/src/constants.ts +1 -0
- package/src/content-fields/flow-ai-agent.tsx +8 -6
- package/src/content-fields/flow-whatsapp-cta-url-button.tsx +18 -2
- package/src/content-fields/hubtype-fields/ai-agent.ts +7 -0
- package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx +19 -2
- package/src/tracking.ts +14 -35
- package/src/types.ts +19 -52
- package/src/user-input/keyword.ts +11 -9
- package/src/user-input/smart-intent.ts +9 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { AgenticOutputMessage } from '
|
|
2
|
+
import { AgenticOutputMessage } from '@botonic/core';
|
|
3
3
|
import { ContentFieldsBase } from './content-fields-base';
|
|
4
|
-
import { HtAiAgentNode } from './hubtype-fields/ai-agent';
|
|
4
|
+
import { HtAiAgentNode, HtInputGuardrailRule } from './hubtype-fields/ai-agent';
|
|
5
5
|
export declare class FlowAiAgent extends ContentFieldsBase {
|
|
6
6
|
code: string;
|
|
7
7
|
name: string;
|
|
@@ -9,6 +9,7 @@ export declare class FlowAiAgent extends ContentFieldsBase {
|
|
|
9
9
|
activeTools?: {
|
|
10
10
|
name: string;
|
|
11
11
|
}[];
|
|
12
|
+
inputGuardrailRules: HtInputGuardrailRule[];
|
|
12
13
|
responses: AgenticOutputMessage[];
|
|
13
14
|
static fromHubtypeCMS(component: HtAiAgentNode): FlowAiAgent;
|
|
14
15
|
toBotonic(id: string): JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Button, Carousel, Text } from '@botonic/react';
|
|
3
|
-
import { SOURCE_INFO_SEPARATOR } from '../constants';
|
|
3
|
+
import { DO_NOTHING_PAYLOAD, SOURCE_INFO_SEPARATOR } from '../constants';
|
|
4
4
|
import { ContentFieldsBase } from './content-fields-base';
|
|
5
5
|
import { FlowElement } from './flow-element';
|
|
6
6
|
export class FlowAiAgent extends ContentFieldsBase {
|
|
@@ -16,15 +16,17 @@ export class FlowAiAgent extends ContentFieldsBase {
|
|
|
16
16
|
newAiAgent.name = component.content.name;
|
|
17
17
|
newAiAgent.instructions = component.content.instructions;
|
|
18
18
|
newAiAgent.activeTools = component.content.active_tools;
|
|
19
|
+
newAiAgent.inputGuardrailRules =
|
|
20
|
+
component.content.input_guardrail_rules || [];
|
|
19
21
|
return newAiAgent;
|
|
20
22
|
}
|
|
21
23
|
toBotonic(id) {
|
|
22
|
-
return (_jsx(_Fragment, { children: this.responses.map(response => {
|
|
24
|
+
return (_jsx(_Fragment, { children: this.responses.map((response) => {
|
|
23
25
|
if (response.type === 'text') {
|
|
24
26
|
return _jsx(Text, { children: response.content.text }, id);
|
|
25
27
|
}
|
|
26
28
|
if (response.type === 'textWithButtons') {
|
|
27
|
-
return (_jsxs(Text, { children: [response.content.text, response.content.buttons.map((button, buttonIndex) => (_jsx(Button, Object.assign({ payload:
|
|
29
|
+
return (_jsxs(Text, { children: [response.content.text, response.content.buttons.map((button, buttonIndex) => (_jsx(Button, Object.assign({ payload: `${DO_NOTHING_PAYLOAD}${SOURCE_INFO_SEPARATOR}${buttonIndex}` }, { children: button }), buttonIndex)))] }, id));
|
|
28
30
|
}
|
|
29
31
|
if (response.type === 'carousel') {
|
|
30
32
|
return (_jsx(Carousel, { children: response.content.elements.map(element => FlowElement.fromAIAgent(id, element).toBotonic(id)) }, id));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-ai-agent.js","sourceRoot":"","sources":["../../../src/content-fields/flow-ai-agent.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"flow-ai-agent.js","sourceRoot":"","sources":["../../../src/content-fields/flow-ai-agent.tsx"],"names":[],"mappings":";AACA,O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rB,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC,CACrD,KAAC,MAAM,kBAEL,OAAO,EAAE,GAAG,kBAAkB,GAAG,qBAAqB,GAAG,WAAW,EAAE,gBAErE,MAAM,KAHF,WAAW,CAIT,CACV,CAAC,KATO,EAAE,CAUN,CACR,CAAA;iBACF;gBAED,IAAI,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE;oBAChC,OAAO,CACL,KAAC,QAAQ,cACN,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CACvC,WAAW,CAAC,WAAW,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CACnD,IAHY,EAAE,CAIN,CACZ,CAAA;iBACF;gBAED,OAAO,mBAAK,CAAA;YACd,CAAC,CAAC,GACD,CACJ,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { WhatsappCTAUrlHeaderType } from '@botonic/react';
|
|
2
|
+
import { ActionRequest, WhatsappCTAUrlHeaderType } from '@botonic/react';
|
|
3
3
|
import { FlowBuilderApi } from '../api';
|
|
4
4
|
import { ContentFieldsBase } from './content-fields-base';
|
|
5
5
|
import { HtWhatsappCTAUrlButtonNode } from './hubtype-fields';
|
|
@@ -16,5 +16,5 @@ export declare class FlowWhatsappCtaUrlButtonNode extends ContentFieldsBase {
|
|
|
16
16
|
url: string;
|
|
17
17
|
static fromHubtypeCMS(component: HtWhatsappCTAUrlButtonNode, locale: string, cmsApi: FlowBuilderApi): FlowWhatsappCtaUrlButtonNode;
|
|
18
18
|
private static setHeader;
|
|
19
|
-
toBotonic(id: string): JSX.Element;
|
|
19
|
+
toBotonic(id: string, request: ActionRequest): JSX.Element;
|
|
20
20
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isWhatsapp } from '@botonic/core';
|
|
3
|
+
import { Button, Text, WhatsappCTAUrlButton, WhatsappCTAUrlHeaderType, } from '@botonic/react';
|
|
3
4
|
import { ContentFieldsBase } from './content-fields-base';
|
|
4
5
|
import { FlowButton } from './flow-button';
|
|
5
6
|
export class FlowWhatsappCtaUrlButtonNode extends ContentFieldsBase {
|
|
@@ -48,7 +49,10 @@ export class FlowWhatsappCtaUrlButtonNode extends ContentFieldsBase {
|
|
|
48
49
|
whatsappCtaUrlButton.headerDocument = this.getAssetByLocale(locale, component.content.header_document);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
toBotonic(id) {
|
|
52
|
+
toBotonic(id, request) {
|
|
53
|
+
if (!isWhatsapp(request.session)) {
|
|
54
|
+
return (_jsxs(Text, { children: [this.text, _jsx(Button, Object.assign({ url: this.url }, { children: this.displayText }))] }));
|
|
55
|
+
}
|
|
52
56
|
if (this.headerType === WhatsappCTAUrlHeaderType.Image &&
|
|
53
57
|
this.headerImage) {
|
|
54
58
|
return (_jsx(WhatsappCTAUrlButton, { body: this.text, headerType: this.headerType, headerImage: this.headerImage, footer: this.footer, displayText: this.displayText, url: this.url }, id));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-whatsapp-cta-url-button.js","sourceRoot":"","sources":["../../../src/content-fields/flow-whatsapp-cta-url-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"flow-whatsapp-cta-url-button.js","sourceRoot":"","sources":["../../../src/content-fields/flow-whatsapp-cta-url-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAEL,MAAM,EACN,IAAI,EACJ,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,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nB,WAAW,EAAE,IAAI,CAAC,WAAW,EAC7B,GAAG,EAAE,IAAI,CAAC,GAAG,IANR,EAAE,CAOP,CACH,CAAA;SACF;QAED,IAAI,IAAI,CAAC,UAAU,KAAK,wBAAwB,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE;YACpE,OAAO,CACL,KAAC,oBAAoB,IAEnB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,WAAW,EAAE,IAAI,CAAC,WAAW,EAC7B,GAAG,EAAE,IAAI,CAAC,GAAG,IANR,EAAE,CAOP,CACH,CAAA;SACF;QAED,OAAO,CACL,KAAC,oBAAoB,IAEnB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,WAAW,EAAE,IAAI,CAAC,WAAW,EAC7B,GAAG,EAAE,IAAI,CAAC,GAAG,IAJR,EAAE,CAKP,CACH,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { HtBaseNode } from './common';
|
|
2
2
|
import { HtNodeWithContentType } from './node-types';
|
|
3
|
+
export interface HtInputGuardrailRule {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
is_active: boolean;
|
|
7
|
+
}
|
|
3
8
|
export interface HtAiAgentNode extends HtBaseNode {
|
|
4
9
|
type: HtNodeWithContentType.AI_AGENT;
|
|
5
10
|
content: {
|
|
@@ -8,5 +13,6 @@ export interface HtAiAgentNode extends HtBaseNode {
|
|
|
8
13
|
active_tools?: {
|
|
9
14
|
name: string;
|
|
10
15
|
}[];
|
|
16
|
+
input_guardrail_rules?: HtInputGuardrailRule[];
|
|
11
17
|
};
|
|
12
18
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { ActionRequest } from '@botonic/react';
|
|
2
3
|
import { FlowBuilderApi } from '../../api';
|
|
3
4
|
import { ContentFieldsBase } from '../content-fields-base';
|
|
4
5
|
import { HtWhatsappButtonListNode } from '../hubtype-fields';
|
|
@@ -9,5 +10,5 @@ export declare class FlowWhatsappButtonList extends ContentFieldsBase {
|
|
|
9
10
|
listButtonText: string;
|
|
10
11
|
sections: FlowWhatsappButtonListSection[];
|
|
11
12
|
static fromHubtypeCMS(component: HtWhatsappButtonListNode, locale: string, cmsApi: FlowBuilderApi): FlowWhatsappButtonList;
|
|
12
|
-
toBotonic(id: string): JSX.Element;
|
|
13
|
+
toBotonic(id: string, request: ActionRequest): JSX.Element;
|
|
13
14
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isWhatsapp } from '@botonic/core';
|
|
3
|
+
import { Button, Text, WhatsappButtonList } from '@botonic/react';
|
|
3
4
|
import { ContentFieldsBase } from '../content-fields-base';
|
|
4
5
|
import { FlowWhatsappButtonListSection } from './flow-whatsapp-button-list-section';
|
|
5
6
|
export class FlowWhatsappButtonList extends ContentFieldsBase {
|
|
@@ -18,7 +19,12 @@ export class FlowWhatsappButtonList extends ContentFieldsBase {
|
|
|
18
19
|
newWhatsappButtonList.sections = component.content.sections.map(section => FlowWhatsappButtonListSection.fromHubtypeCMS(section, locale, cmsApi));
|
|
19
20
|
return newWhatsappButtonList;
|
|
20
21
|
}
|
|
21
|
-
toBotonic(id) {
|
|
22
|
+
toBotonic(id, request) {
|
|
23
|
+
if (!isWhatsapp(request.session)) {
|
|
24
|
+
const rows = this.sections.flatMap(section => section.rows);
|
|
25
|
+
const buttons = rows.map(row => (_jsx(Button, Object.assign({ payload: row.id }, { children: row.title }), row.id)));
|
|
26
|
+
return (_jsxs(Text, { children: [this.text, buttons] }));
|
|
27
|
+
}
|
|
22
28
|
return (_jsx(WhatsappButtonList, { body: this.text, button: this.listButtonText, sections: this.sections.map((section, sectionIndex) => section.toBotonic(sectionIndex)) }, id));
|
|
23
29
|
}
|
|
24
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-whatsapp-button-list.js","sourceRoot":"","sources":["../../../../src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"flow-whatsapp-button-list.js","sourceRoot":"","sources":["../../../../src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAiB,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAIhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,qCAAqC,CAAA;AAEnF,MAAM,OAAO,sBAAuB,SAAQ,iBAAiB;IAA7D;;QACS,SAAI,GAAG,EAAE,CAAA;QACT,SAAI,GAAG,EAAE,CAAA;QACT,mBAAc,GAAG,EAAE,CAAA;QACnB,aAAQ,GAAoC,EAAE,CAAA;IAmDvD,CAAC;IAjDC,MAAM,CAAC,cAAc,CACnB,SAAmC,EACnC,MAAc,EACd,MAAsB;QAEtB,MAAM,qBAAqB,GAAG,IAAI,sBAAsB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QACtE,qBAAqB,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;QAC3C,qBAAqB,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAC/C,MAAM,EACN,SAAS,CAAC,OAAO,CAAC,IAAI,CACvB,CAAA;QACD,qBAAqB,CAAC,cAAc,GAAG,IAAI,CAAC,eAAe,CACzD,MAAM,EACN,SAAS,CAAC,OAAO,CAAC,WAAW,CAC9B,CAAA;QACD,qBAAqB,CAAC,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CACxE,6BAA6B,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CACtE,CAAA;QACD,OAAO,qBAAqB,CAAA;IAC9B,CAAC;IAED,SAAS,CAAC,EAAU,EAAE,OAAsB;QAC1C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAChC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAC3D,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAC9B,KAAC,MAAM,kBAAc,OAAO,EAAE,GAAG,CAAC,EAAE,gBACjC,GAAG,CAAC,KAAK,KADC,GAAG,CAAC,EAAE,CAEV,CACV,CAAC,CAAA;YAEF,OAAO,CACL,MAAC,IAAI,eACF,IAAI,CAAC,IAAI,EACT,OAAO,IACH,CACR,CAAA;SACF;QAED,OAAO,CACL,KAAC,kBAAkB,IAEjB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,MAAM,EAAE,IAAI,CAAC,cAAc,EAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,CACpD,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAChC,IALI,EAAE,CAMa,CACvB,CAAA;IACH,CAAC;CACF"}
|
package/lib/esm/tracking.d.ts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
+
import { EventAction } from '@botonic/core';
|
|
1
2
|
import { ActionRequest } from '@botonic/react';
|
|
2
3
|
import { FlowContent } from './content-fields';
|
|
3
|
-
export declare enum EventAction {
|
|
4
|
-
FlowNode = "flow_node",
|
|
5
|
-
Keyword = "nlu_keyword",
|
|
6
|
-
IntentSmart = "nlu_intent_smart",
|
|
7
|
-
Knowledgebase = "knowledgebase",
|
|
8
|
-
Fallback = "fallback",
|
|
9
|
-
FeedbackCase = "feedback_case"
|
|
10
|
-
}
|
|
11
|
-
export declare enum KnowledgebaseFailReason {
|
|
12
|
-
NoKnowledge = "no_knowledge",
|
|
13
|
-
Hallucination = "hallucination"
|
|
14
|
-
}
|
|
15
4
|
export declare function trackEvent(request: ActionRequest, eventAction: EventAction, args?: Record<string, any>): Promise<void>;
|
|
16
5
|
export declare function trackFlowContent(request: ActionRequest, contents: FlowContent[]): Promise<void>;
|
package/lib/esm/tracking.js
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
1
|
+
import { __awaiter, __rest } from "tslib";
|
|
2
|
+
import { EventAction } from '@botonic/core';
|
|
2
3
|
import { v7 as uuidv7 } from 'uuid';
|
|
3
4
|
import { HtNodeWithContentType, } from './content-fields/hubtype-fields';
|
|
4
5
|
import { getFlowBuilderPlugin } from './helpers';
|
|
5
|
-
export var EventAction;
|
|
6
|
-
(function (EventAction) {
|
|
7
|
-
EventAction["FlowNode"] = "flow_node";
|
|
8
|
-
EventAction["Keyword"] = "nlu_keyword";
|
|
9
|
-
EventAction["IntentSmart"] = "nlu_intent_smart";
|
|
10
|
-
EventAction["Knowledgebase"] = "knowledgebase";
|
|
11
|
-
EventAction["Fallback"] = "fallback";
|
|
12
|
-
EventAction["FeedbackCase"] = "feedback_case";
|
|
13
|
-
})(EventAction || (EventAction = {}));
|
|
14
|
-
export var KnowledgebaseFailReason;
|
|
15
|
-
(function (KnowledgebaseFailReason) {
|
|
16
|
-
KnowledgebaseFailReason["NoKnowledge"] = "no_knowledge";
|
|
17
|
-
KnowledgebaseFailReason["Hallucination"] = "hallucination";
|
|
18
|
-
})(KnowledgebaseFailReason || (KnowledgebaseFailReason = {}));
|
|
19
6
|
export function trackEvent(request, eventAction, args) {
|
|
20
7
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
8
|
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
|
|
@@ -26,36 +13,33 @@ export function trackEvent(request, eventAction, args) {
|
|
|
26
13
|
});
|
|
27
14
|
}
|
|
28
15
|
export function trackFlowContent(request, contents) {
|
|
29
|
-
var _a;
|
|
30
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
17
|
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
|
|
32
18
|
const cmsApi = flowBuilderPlugin.cmsApi;
|
|
33
19
|
for (const content of contents) {
|
|
34
20
|
const nodeContent = cmsApi.getNodeById(content.id);
|
|
35
21
|
if (nodeContent.type !== HtNodeWithContentType.KNOWLEDGE_BASE) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
flowName: flowBuilderPlugin.getFlowName(nodeContent.flow_id),
|
|
40
|
-
id: nodeContent.id,
|
|
41
|
-
isMeaningful: (_a = nodeContent.is_meaningful) !== null && _a !== void 0 ? _a : false,
|
|
42
|
-
});
|
|
43
|
-
yield trackEvent(request, EventAction.FlowNode, eventArgs);
|
|
22
|
+
const event = getContentEventArgs(request, nodeContent);
|
|
23
|
+
const { action } = event, eventArgs = __rest(event, ["action"]);
|
|
24
|
+
yield trackEvent(request, action, eventArgs);
|
|
44
25
|
}
|
|
45
26
|
}
|
|
46
27
|
});
|
|
47
28
|
}
|
|
48
|
-
function getContentEventArgs(request,
|
|
49
|
-
var _a;
|
|
29
|
+
function getContentEventArgs(request, nodeContent) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
|
|
32
|
+
const flowName = flowBuilderPlugin.getFlowName(nodeContent.flow_id);
|
|
50
33
|
const flowThreadId = (_a = request.session.flow_thread_id) !== null && _a !== void 0 ? _a : uuidv7();
|
|
51
34
|
request.session.flow_thread_id = flowThreadId;
|
|
52
35
|
return {
|
|
36
|
+
action: EventAction.FlowNode,
|
|
53
37
|
flowThreadId,
|
|
54
|
-
flowId:
|
|
55
|
-
flowName:
|
|
56
|
-
flowNodeId:
|
|
57
|
-
flowNodeContentId:
|
|
58
|
-
flowNodeIsMeaningful:
|
|
38
|
+
flowId: nodeContent.flow_id,
|
|
39
|
+
flowName: flowName,
|
|
40
|
+
flowNodeId: nodeContent.id,
|
|
41
|
+
flowNodeContentId: nodeContent.code,
|
|
42
|
+
flowNodeIsMeaningful: (_b = nodeContent.is_meaningful) !== null && _b !== void 0 ? _b : false,
|
|
59
43
|
};
|
|
60
44
|
}
|
|
61
45
|
//# sourceMappingURL=tracking.js.map
|
package/lib/esm/tracking.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../src/tracking.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../src/tracking.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,eAAe,CAAA;AAEtD,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAGnC,OAAO,EAEL,qBAAqB,GACtB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEhD,MAAM,UAAgB,UAAU,CAC9B,OAAsB,EACtB,WAAwB,EACxB,IAA0B;;QAE1B,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC/D,IAAI,iBAAiB,CAAC,UAAU,EAAE;YAChC,MAAM,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAA;SAC/D;QACD,OAAM;IACR,CAAC;CAAA;AAED,MAAM,UAAgB,gBAAgB,CACpC,OAAsB,EACtB,QAAuB;;QAEvB,MAAM,iBAAiB,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
1
|
-
import { BotContext, PluginPreRequest, ResolvedPlugins } from '@botonic/core';
|
|
1
|
+
import { BotContext, InferenceResponse, KnowledgeBasesResponse, PluginPreRequest, ResolvedPlugins } from '@botonic/core';
|
|
2
2
|
import { FlowContent } from './content-fields';
|
|
3
3
|
import { HtFlowBuilderData } from './content-fields/hubtype-fields';
|
|
4
4
|
export interface InShadowingConfig {
|
|
@@ -23,14 +23,19 @@ export interface BotonicPluginFlowBuilderOptions<TPlugins extends ResolvedPlugin
|
|
|
23
23
|
customRatingMessageEnabled?: boolean;
|
|
24
24
|
}
|
|
25
25
|
export type TrackEventFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, eventAction: string, args?: Record<string, any>) => Promise<void>;
|
|
26
|
-
export type KnowledgeBaseFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, sources: string[], instructions: string, messageId: string, memoryLength: number) => Promise<
|
|
27
|
-
export type AiAgentFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, aiAgentArgs: AiAgentArgs) => Promise<
|
|
26
|
+
export type KnowledgeBaseFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, sources: string[], instructions: string, messageId: string, memoryLength: number) => Promise<KnowledgeBasesResponse>;
|
|
27
|
+
export type AiAgentFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, aiAgentArgs: AiAgentArgs) => Promise<InferenceResponse>;
|
|
28
|
+
export interface GuardrailRule {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
}
|
|
28
32
|
export interface AiAgentArgs {
|
|
29
33
|
name: string;
|
|
30
34
|
instructions: string;
|
|
31
35
|
activeTools?: {
|
|
32
36
|
name: string;
|
|
33
37
|
}[];
|
|
38
|
+
inputGuardrailRules?: GuardrailRule[];
|
|
34
39
|
}
|
|
35
40
|
export type ContentFilter<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, content: FlowContent) => Promise<FlowContent> | FlowContent;
|
|
36
41
|
export interface FlowBuilderApiOptions {
|
|
@@ -48,13 +53,6 @@ export declare enum FlowBuilderJSONVersion {
|
|
|
48
53
|
DRAFT = "draft",
|
|
49
54
|
LATEST = "latest"
|
|
50
55
|
}
|
|
51
|
-
export interface KnowledgeBaseResponse {
|
|
52
|
-
inferenceId: string;
|
|
53
|
-
hasKnowledge: boolean;
|
|
54
|
-
isFaithful: boolean;
|
|
55
|
-
chunkIds: string[];
|
|
56
|
-
answer: string;
|
|
57
|
-
}
|
|
58
56
|
export interface SmartIntentResponse {
|
|
59
57
|
data: {
|
|
60
58
|
smart_intent_title: string;
|
|
@@ -68,37 +66,3 @@ export interface SmartIntentResponse {
|
|
|
68
66
|
export interface PayloadParamsBase {
|
|
69
67
|
followUpContentID?: string;
|
|
70
68
|
}
|
|
71
|
-
export interface OutputBaseMessage {
|
|
72
|
-
type: 'text' | 'textWithButtons' | 'carousel' | 'exit';
|
|
73
|
-
}
|
|
74
|
-
export interface TextMessage extends OutputBaseMessage {
|
|
75
|
-
type: 'text';
|
|
76
|
-
content: {
|
|
77
|
-
text: string;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
export interface TextWithButtonsMessage extends OutputBaseMessage {
|
|
81
|
-
type: 'textWithButtons';
|
|
82
|
-
content: {
|
|
83
|
-
text: string;
|
|
84
|
-
buttons: string[];
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
export interface CarouselMessage extends OutputBaseMessage {
|
|
88
|
-
type: 'carousel';
|
|
89
|
-
content: {
|
|
90
|
-
elements: {
|
|
91
|
-
title: string;
|
|
92
|
-
subtitle: string;
|
|
93
|
-
image: string;
|
|
94
|
-
button: {
|
|
95
|
-
text: string;
|
|
96
|
-
url: string;
|
|
97
|
-
};
|
|
98
|
-
}[];
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
export interface ExitMessage extends OutputBaseMessage {
|
|
102
|
-
type: 'exit';
|
|
103
|
-
}
|
|
104
|
-
export type AgenticOutputMessage = TextMessage | TextWithButtonsMessage | CarouselMessage | ExitMessage;
|
package/lib/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AA8FA,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,7 +1,7 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { NluType } from '@botonic/core';
|
|
1
|
+
import { __awaiter, __rest } from "tslib";
|
|
2
|
+
import { EventAction, NluType } from '@botonic/core';
|
|
3
3
|
import { REG_EXP_PATTERN } from '../constants';
|
|
4
|
-
import {
|
|
4
|
+
import { trackEvent } from '../tracking';
|
|
5
5
|
export class KeywordMatcher {
|
|
6
6
|
constructor({ cmsApi, locale, request }) {
|
|
7
7
|
this.cmsApi = cmsApi;
|
|
@@ -63,16 +63,18 @@ export class KeywordMatcher {
|
|
|
63
63
|
}
|
|
64
64
|
trackKeywordEvent() {
|
|
65
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const
|
|
66
|
+
const event = {
|
|
67
|
+
action: EventAction.Keyword,
|
|
68
|
+
flowThreadId: this.request.session.flow_thread_id,
|
|
69
|
+
flowNodeId: this.keywordNodeId,
|
|
70
|
+
flowId: this.flowId,
|
|
67
71
|
nluKeywordName: this.matchedKeyword,
|
|
68
72
|
nluKeywordIsRegex: this.isRegExp,
|
|
69
73
|
nluKeywordMessageId: this.request.input.message_id,
|
|
70
74
|
userInput: this.request.input.data,
|
|
71
|
-
flowThreadId: this.request.session.flow_thread_id,
|
|
72
|
-
flowId: this.flowId,
|
|
73
|
-
flowNodeId: this.keywordNodeId,
|
|
74
75
|
};
|
|
75
|
-
|
|
76
|
+
const { action } = event, eventArgs = __rest(event, ["action"]);
|
|
77
|
+
yield trackEvent(this.request, action, eventArgs);
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyword.js","sourceRoot":"","sources":["../../../src/user-input/keyword.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"keyword.js","sourceRoot":"","sources":["../../../src/user-input/keyword.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAgB,OAAO,EAAE,MAAM,eAAe,CAAA;AAIlE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAK9C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAOxC,MAAM,OAAO,cAAc;IASzB,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAgB;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;IACvB,CAAC;IAEK,cAAc,CAAC,SAAiB;;YACpC,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAA;YAClD,MAAM,WAAW,GAAG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AAuB;gBACxC,MAAM,EAAE,IAAI,CAAC,MAAgB;gBAC7B,cAAc,EAAE,IAAI,CAAC,cAAwB;gBAC7C,iBAAiB,EAAE,IAAI,CAAC,QAAQ;gBAChC,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU;gBAClD,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAc;aAC7C,CAAA;YACD,MAAM,EAAE,MAAM,KAAmB,KAAK,EAAnB,SAAS,UAAK,KAAK,EAAhC,UAAwB,CAAQ,CAAA;YACtC,MAAM,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;QACnD,CAAC;KAAA;CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { NluType } from '@botonic/core';
|
|
1
|
+
import { __awaiter, __rest } from "tslib";
|
|
2
|
+
import { EventAction, NluType } from '@botonic/core';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import { getFlowBuilderPlugin } from '../helpers';
|
|
5
|
-
import {
|
|
5
|
+
import { trackEvent } from '../tracking';
|
|
6
6
|
export class SmartIntentsApi {
|
|
7
7
|
constructor(cmsApi, currentRequest, smartIntentsConfig, flowId) {
|
|
8
8
|
this.cmsApi = cmsApi;
|
|
@@ -33,7 +33,8 @@ export class SmartIntentsApi {
|
|
|
33
33
|
matchedValue: smartIntentNode.content.title,
|
|
34
34
|
payload: targetPayload,
|
|
35
35
|
};
|
|
36
|
-
|
|
36
|
+
const event = {
|
|
37
|
+
action: EventAction.IntentSmart,
|
|
37
38
|
nluIntentSmartTitle: response.data.smart_intent_title,
|
|
38
39
|
nluIntentSmartNumUsed: response.data.smart_intents_used.length,
|
|
39
40
|
nluIntentSmartMessageId: this.currentRequest.input.message_id,
|
|
@@ -41,7 +42,9 @@ export class SmartIntentsApi {
|
|
|
41
42
|
flowThreadId: this.currentRequest.session.flow_thread_id,
|
|
42
43
|
flowId: smartIntentNode.flow_id,
|
|
43
44
|
flowNodeId: smartIntentNode.id,
|
|
44
|
-
}
|
|
45
|
+
};
|
|
46
|
+
const { action } = event, eventArgs = __rest(event, ["action"]);
|
|
47
|
+
yield trackEvent(this.currentRequest, action, eventArgs);
|
|
45
48
|
return smartIntentNode;
|
|
46
49
|
}
|
|
47
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-intent.js","sourceRoot":"","sources":["../../../src/user-input/smart-intent.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"smart-intent.js","sourceRoot":"","sources":["../../../src/user-input/smart-intent.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAoB,OAAO,EAAE,MAAM,eAAe,CAAA;AAEtE,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAexC,MAAM,OAAO,eAAe;IAC1B,YACS,MAAsB,EACtB,cAA6B,EAC7B,kBAA+C,EAC/C,MAAe;QAHf,WAAM,GAAN,MAAM,CAAgB;QACtB,mBAAc,GAAd,cAAc,CAAe;QAC7B,uBAAkB,GAAlB,kBAAkB,CAA6B;QAC/C,WAAM,GAAN,MAAM,CAAS;IACrB,CAAC;IAEE,cAAc;;YAClB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI;gBAAE,OAAO,SAAS,CAAA;YACrD,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAA;YAC1D,IAAI,CAAC,gBAAgB,CAAC,MAAM;gBAAE,OAAO,SAAS,CAAA;YAE9C,MAAM,MAAM,GAAG;gBACb,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,E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B,SAAS,UAAK,KAAK,EAAhC,UAAwB,CAAQ,CAAA;oBAEtC,MAAM,UAAU,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;oBAExD,OAAO,eAAe,CAAA;iBACvB;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;aACjB;YACD,OAAO,SAAS,CAAA;QAClB,CAAC;KAAA;IAEO,gBAAgB;QACtB,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,mBAAmB;YAAE,OAAO,KAAK,CAAA;QACjE,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAA;IAC1C,CAAC;IAEa,YAAY,CACxB,eAA4C;;YAE5C,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YAC3E,MAAM,KAAK,GAAG,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YAE3E,OAAO,MAAM,KAAK,CAAC;gBACjB,MAAM,EAAE,MAAM;gBACd,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,0CAA0C;gBAC7E,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,KAAK,EAAE;oBAChC,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,KAAK;aACf,CAAC,CAAA;QACJ,CAAC;KAAA;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/plugin-flow-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.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",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"lint_core": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.ts*'"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@botonic/react": "
|
|
17
|
+
"@botonic/react": "0.38.0-alpha.0",
|
|
18
18
|
"axios": "^1.10.0",
|
|
19
19
|
"uuid": "^10.0.0"
|
|
20
20
|
},
|
package/src/action/ai-agent.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FlowContent } from '../content-fields'
|
|
2
2
|
import { FlowAiAgent } from '../content-fields/flow-ai-agent'
|
|
3
|
+
import { GuardrailRule } from '../types'
|
|
3
4
|
import { FlowBuilderContext } from './index'
|
|
4
5
|
|
|
5
6
|
export async function getContentsByAiAgent({
|
|
@@ -24,12 +25,21 @@ export async function getContentsByAiAgent({
|
|
|
24
25
|
return []
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
const activeInputGuardrailRules: GuardrailRule[] =
|
|
29
|
+
aiAgentContent.inputGuardrailRules
|
|
30
|
+
?.filter(rule => rule.is_active)
|
|
31
|
+
?.map(rule => ({
|
|
32
|
+
name: rule.name,
|
|
33
|
+
description: rule.description,
|
|
34
|
+
})) || []
|
|
35
|
+
|
|
27
36
|
const aiAgentResponse = await flowBuilderPlugin.getAiAgentResponse?.(
|
|
28
37
|
request,
|
|
29
38
|
{
|
|
30
39
|
name: aiAgentContent.name,
|
|
31
40
|
instructions: aiAgentContent.instructions,
|
|
32
41
|
activeTools: aiAgentContent.activeTools,
|
|
42
|
+
inputGuardrailRules: activeInputGuardrailRules,
|
|
33
43
|
}
|
|
34
44
|
)
|
|
35
45
|
|
|
@@ -37,11 +47,11 @@ export async function getContentsByAiAgent({
|
|
|
37
47
|
return []
|
|
38
48
|
}
|
|
39
49
|
|
|
40
|
-
if (aiAgentResponse.
|
|
50
|
+
if (aiAgentResponse.exit) {
|
|
41
51
|
return []
|
|
42
52
|
}
|
|
43
53
|
|
|
44
|
-
aiAgentContent.responses = aiAgentResponse
|
|
54
|
+
aiAgentContent.responses = aiAgentResponse.messages
|
|
45
55
|
|
|
46
56
|
return contents
|
|
47
57
|
}
|
package/src/action/fallback.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { EventAction, EventFallback } from '@botonic/core'
|
|
1
2
|
import { ActionRequest } from '@botonic/react'
|
|
2
3
|
|
|
3
4
|
import { FlowBuilderApi } from '../api'
|
|
4
5
|
import { FlowContent } from '../content-fields'
|
|
5
|
-
import {
|
|
6
|
+
import { trackEvent } from '../tracking'
|
|
6
7
|
import { FlowBuilderContext } from './index'
|
|
7
8
|
|
|
8
9
|
export async function getContentsByFallback({
|
|
@@ -30,11 +31,15 @@ async function getFallbackNode(cmsApi: FlowBuilderApi, request: ActionRequest) {
|
|
|
30
31
|
const fallbackNode = cmsApi.getFallbackNode(isFirstFallbackOption)
|
|
31
32
|
request.session.user.extra_data.isFirstFallbackOption = !isFirstFallbackOption
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
const event: EventFallback = {
|
|
35
|
+
action: EventAction.Fallback,
|
|
36
|
+
userInput: request.input.data as string,
|
|
35
37
|
fallbackOut: isFirstFallbackOption ? 1 : 2,
|
|
36
38
|
fallbackMessageId: request.input.message_id,
|
|
37
|
-
}
|
|
39
|
+
}
|
|
40
|
+
const { action, ...eventArgs } = event
|
|
41
|
+
|
|
42
|
+
await trackEvent(request, action, eventArgs)
|
|
38
43
|
|
|
39
44
|
return fallbackNode
|
|
40
45
|
}
|
|
@@ -10,11 +10,35 @@ import { getContentsByPayload } from './payload'
|
|
|
10
10
|
export async function getContentsByFirstInteraction(
|
|
11
11
|
context: FlowBuilderContext
|
|
12
12
|
): Promise<FlowContent[]> {
|
|
13
|
-
const { flowBuilderPlugin, request } = context
|
|
13
|
+
const { contentID, flowBuilderPlugin, request } = context
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* If the contentID is provided, the firstInteractionContents are obtained even if they are not used
|
|
17
|
+
* because when obtain this firstInteractionContents is when the session.flow_thread_id is updated.
|
|
18
|
+
* This is needed for example when send a WhatsApp campaign is sent,
|
|
19
|
+
* the bot not receives the message because this message is sent directly by the backend
|
|
20
|
+
* we expect the bot to respond only with the contents of the contentID and not with the firstInteractionContents.
|
|
21
|
+
*/
|
|
14
22
|
const firstInteractionContents = await flowBuilderPlugin.getStartContents()
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
if (contentID) {
|
|
25
|
+
try {
|
|
26
|
+
const contentsByContentID =
|
|
27
|
+
await flowBuilderPlugin.getContentsByContentID(contentID)
|
|
28
|
+
|
|
29
|
+
if (contentsByContentID.length > 0) {
|
|
30
|
+
return contentsByContentID
|
|
31
|
+
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.warn(
|
|
34
|
+
`The contentID ${contentID} is not found. Returning the firstInteractionContents`
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* If the first interaction has a FlowBotAction, it should be the last content
|
|
40
|
+
* and avoid to render the match with keywords,intents or knowledge base
|
|
41
|
+
*/
|
|
18
42
|
if (firstInteractionContents.at(-1) instanceof FlowBotAction) {
|
|
19
43
|
return firstInteractionContents
|
|
20
44
|
}
|
package/src/action/index.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import React from 'react'
|
|
10
10
|
|
|
11
11
|
import { FlowBuilderApi } from '../api'
|
|
12
|
+
import { DO_NOTHING_PAYLOAD } from '../constants'
|
|
12
13
|
import { FlowContent, FlowHandoff } from '../content-fields'
|
|
13
14
|
import { FlowBotAction } from '../content-fields/flow-bot-action'
|
|
14
15
|
import { ContentFilterExecutor } from '../filters'
|
|
@@ -125,7 +126,7 @@ async function getContents(
|
|
|
125
126
|
return []
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
if (request.input.payload?.startsWith(
|
|
129
|
+
if (request.input.payload?.startsWith(DO_NOTHING_PAYLOAD)) {
|
|
129
130
|
request.input.payload = undefined
|
|
130
131
|
}
|
|
131
132
|
|