@botonic/core 2.26.0 → 2.28.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/CHANGELOG.md +17 -0
- package/package.json +7 -2
- package/src/index.d.ts +3 -1
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/lib/actions/index.d.ts +1 -0
- package/src/lib/actions/index.js +2 -0
- package/src/lib/actions/index.js.map +1 -0
- package/src/lib/actions/update-webchat-client-settings.d.ts +5 -0
- package/src/lib/actions/update-webchat-client-settings.js +51 -0
- package/src/lib/actions/update-webchat-client-settings.js.map +1 -0
- package/src/lib/core-bot/index.d.ts +14 -11
- package/src/lib/core-bot/index.js +55 -44
- package/src/lib/core-bot/index.js.map +1 -1
- package/src/lib/plugins/index.d.ts +2 -2
- package/src/lib/plugins/index.js +6 -6
- package/src/lib/plugins/index.js.map +1 -1
- package/src/lib/routes/router.d.ts +4 -4
- package/src/lib/routes/router.js +13 -13
- package/src/lib/routes/router.js.map +1 -1
- package/src/lib/routes/types.d.ts +2 -2
- package/src/lib/server/bot-server-message.d.ts +71 -0
- package/src/lib/server/bot-server-message.js +111 -0
- package/src/lib/server/bot-server-message.js.map +1 -0
- package/src/lib/server/botonic-context/botonic-action.d.ts +10 -0
- package/src/lib/server/botonic-context/botonic-action.js +9 -0
- package/src/lib/server/botonic-context/botonic-action.js.map +1 -0
- package/src/lib/server/botonic-context/botonic-context-input.d.ts +96 -0
- package/src/lib/server/botonic-context/botonic-context-input.js +124 -0
- package/src/lib/server/botonic-context/botonic-context-input.js.map +1 -0
- package/src/lib/server/botonic-context/botonic-context-session.d.ts +159 -0
- package/src/lib/server/botonic-context/botonic-context-session.js +297 -0
- package/src/lib/server/botonic-context/botonic-context-session.js.map +1 -0
- package/src/lib/server/botonic-context/botonic-context-settings.d.ts +16 -0
- package/src/lib/server/botonic-context/botonic-context-settings.js +48 -0
- package/src/lib/server/botonic-context/botonic-context-settings.js.map +1 -0
- package/src/lib/server/botonic-context/botonic-context.d.ts +59 -0
- package/src/lib/server/botonic-context/botonic-context.js +42 -0
- package/src/lib/server/botonic-context/botonic-context.js.map +1 -0
- package/src/lib/server/botonic-context/botonic-session-patch-slice.d.ts +30 -0
- package/src/lib/server/botonic-context/botonic-session-patch-slice.js +80 -0
- package/src/lib/server/botonic-context/botonic-session-patch-slice.js.map +1 -0
- package/src/lib/server/botonic-context/factory.d.ts +29 -0
- package/src/lib/server/botonic-context/factory.js +31 -0
- package/src/lib/server/botonic-context/factory.js.map +1 -0
- package/src/lib/server/botonic-context/index.d.ts +9 -0
- package/src/lib/server/botonic-context/index.js +10 -0
- package/src/lib/server/botonic-context/index.js.map +1 -0
- package/src/lib/server/botonic-context/send-messages-utils.d.ts +3 -0
- package/src/lib/server/botonic-context/send-messages-utils.js +33 -0
- package/src/lib/server/botonic-context/send-messages-utils.js.map +1 -0
- package/src/lib/server/botonic-context/types.d.ts +24 -0
- package/src/lib/server/botonic-context/types.js +6 -0
- package/src/lib/server/botonic-context/types.js.map +1 -0
- package/src/lib/server/factory.d.ts +169 -0
- package/src/lib/server/factory.js +192 -0
- package/src/lib/server/factory.js.map +1 -0
- package/src/lib/server/index.d.ts +3 -0
- package/src/lib/server/index.js +4 -0
- package/src/lib/server/index.js.map +1 -0
- package/src/lib/services/hubtype-api-service.d.ts +13 -0
- package/src/lib/services/hubtype-api-service.js +67 -0
- package/src/lib/services/hubtype-api-service.js.map +1 -0
- package/src/lib/services/hubtype-external-api-client.d.ts +22 -0
- package/src/lib/services/hubtype-external-api-client.js +111 -0
- package/src/lib/services/hubtype-external-api-client.js.map +1 -0
- package/src/lib/services/index.d.ts +2 -0
- package/src/lib/services/index.js +3 -0
- package/src/lib/services/index.js.map +1 -0
- package/src/lib/hubtype-service/handoff.d.ts +0 -4
- package/src/lib/hubtype-service/handoff.js +0 -32
- package/src/lib/hubtype-service/handoff.js.map +0 -1
- package/src/lib/hubtype-service/index.d.ts +0 -10
- package/src/lib/hubtype-service/index.js +0 -96
- package/src/lib/hubtype-service/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## 2.28.0 (2026-05-06)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 2.27.0 (2026-04-29)
|
|
6
|
+
|
|
7
|
+
### 🚀 Features
|
|
8
|
+
|
|
9
|
+
- typing to work again and improve it with few modes when sending messages ([#831](https://github.com/metis-ai/hubtype-product/pull/831))
|
|
10
|
+
- receiving db_id, bot_interaction_id and working capture_user_input_id and first_interaction updatable ([#822](https://github.com/metis-ai/hubtype-product/pull/822))
|
|
11
|
+
- supporting isFirstInteraction editable by bot, with snapshot logic ([#815](https://github.com/metis-ai/hubtype-product/pull/815))
|
|
12
|
+
- **botonic:** session and Hubtype API adaptations (non-webviews) ([#810](https://github.com/metis-ai/hubtype-product/pull/810))
|
|
13
|
+
|
|
14
|
+
### ❤️ Thank You
|
|
15
|
+
|
|
16
|
+
- Marc Rabat @vanbasten17
|
|
17
|
+
|
|
1
18
|
## 2.26.0 (2026-03-31)
|
|
2
19
|
|
|
3
20
|
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.28.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./src/index.d.ts",
|
|
6
6
|
"module": "./src/index.js",
|
|
@@ -8,10 +8,15 @@
|
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./src/index.d.ts",
|
|
10
10
|
"import": "./src/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./server": {
|
|
13
|
+
"types": "./src/lib/server/index.d.ts",
|
|
14
|
+
"import": "./src/lib/server/index.js",
|
|
15
|
+
"default": "./src/lib/server/index.ts"
|
|
11
16
|
}
|
|
12
17
|
},
|
|
13
18
|
"dependencies": {
|
|
14
|
-
"@botonic/shared": "2.
|
|
19
|
+
"@botonic/shared": "2.28.0",
|
|
15
20
|
"tslib": "^2.3.0"
|
|
16
21
|
},
|
|
17
22
|
"references": [
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export * from './lib/actions';
|
|
1
2
|
export * from './lib/core-bot';
|
|
2
|
-
export * from './lib/hubtype-service';
|
|
3
3
|
export * from './lib/routes/types';
|
|
4
|
+
export * from './lib/server';
|
|
5
|
+
export * from './lib/services';
|
|
4
6
|
export * from './lib/utils';
|
|
5
7
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/botonic/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/botonic/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './update-webchat-client-settings';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { parseUpdateWebchatClientSettingsPayload, } from '@botonic/shared';
|
|
3
|
+
import { BotServerMessageFactory } from '../server';
|
|
4
|
+
function isSettingsPatch(value) {
|
|
5
|
+
return (typeof value === 'object' &&
|
|
6
|
+
value !== null &&
|
|
7
|
+
!Array.isArray(value) &&
|
|
8
|
+
Object.keys(value).length > 0);
|
|
9
|
+
}
|
|
10
|
+
function mergeSettingsPatch(current, patch) {
|
|
11
|
+
var _a, _b, _c, _d, _e;
|
|
12
|
+
return {
|
|
13
|
+
block_inputs: (_a = patch.block_inputs) !== null && _a !== void 0 ? _a : current.block_inputs,
|
|
14
|
+
user_input_enabled: (_b = patch.user_input_enabled) !== null && _b !== void 0 ? _b : current.user_input_enabled,
|
|
15
|
+
attachments_enabled: (_c = patch.attachments_enabled) !== null && _c !== void 0 ? _c : current.attachments_enabled,
|
|
16
|
+
emoji_picker_enabled: (_d = patch.emoji_picker_enabled) !== null && _d !== void 0 ? _d : current.emoji_picker_enabled,
|
|
17
|
+
custom: Object.assign(Object.assign({}, current.custom), ((_e = patch.custom) !== null && _e !== void 0 ? _e : {})),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function updateWebchatClientSettingsAction(botonicContext) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const payload = botonicContext.input.payload;
|
|
23
|
+
if (!payload) {
|
|
24
|
+
return {
|
|
25
|
+
status: 400,
|
|
26
|
+
response: 'No payload',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const { settings } = parseUpdateWebchatClientSettingsPayload(payload);
|
|
30
|
+
if (!isSettingsPatch(settings)) {
|
|
31
|
+
return {
|
|
32
|
+
status: 400,
|
|
33
|
+
response: 'No settings to update',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const mergedSettings = mergeSettingsPatch(botonicContext.session.webchatClientSettings, settings);
|
|
37
|
+
yield botonicContext.updateBotSession({
|
|
38
|
+
webchatClientSettings: mergedSettings,
|
|
39
|
+
});
|
|
40
|
+
yield botonicContext.sendMessages([
|
|
41
|
+
BotServerMessageFactory.createWebchatClientSettings({
|
|
42
|
+
settings: mergedSettings,
|
|
43
|
+
}),
|
|
44
|
+
], { typingMode: false });
|
|
45
|
+
return {
|
|
46
|
+
status: 200,
|
|
47
|
+
response: 'OK',
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=update-webchat-client-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-webchat-client-settings.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/actions/update-webchat-client-settings.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,uCAAuC,GAExC,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAkB,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAKnE,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAC9B,CAAA;AACH,CAAC;AAED,SAAS,kBAAkB,CACzB,OAA8B,EAC9B,KAAiC;;IAEjC,OAAO;QACL,YAAY,EAAE,MAAA,KAAK,CAAC,YAAY,mCAAI,OAAO,CAAC,YAAY;QACxD,kBAAkB,EAAE,MAAA,KAAK,CAAC,kBAAkB,mCAAI,OAAO,CAAC,kBAAkB;QAC1E,mBAAmB,EACjB,MAAA,KAAK,CAAC,mBAAmB,mCAAI,OAAO,CAAC,mBAAmB;QAC1D,oBAAoB,EAClB,MAAA,KAAK,CAAC,oBAAoB,mCAAI,OAAO,CAAC,oBAAoB;QAC5D,MAAM,kCACD,OAAO,CAAC,MAAM,GACd,CAAC,MAAA,KAAK,CAAC,MAAM,mCAAI,EAAE,CAAC,CACxB;KACF,CAAA;AACH,CAAC;AAED,MAAM,UAAgB,iCAAiC,CACrD,cAA8B;;QAE9B,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,OAAO,CAAA;QAC5C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;gBACL,MAAM,EAAE,GAAG;gBACX,QAAQ,EAAE,YAAY;aACvB,CAAA;QACH,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,GAAG,uCAAuC,CAAC,OAAO,CAAC,CAAA;QAErE,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,OAAO;gBACL,MAAM,EAAE,GAAG;gBACX,QAAQ,EAAE,uBAAuB;aAClC,CAAA;QACH,CAAC;QAED,MAAM,cAAc,GAAG,kBAAkB,CACvC,cAAc,CAAC,OAAO,CAAC,qBAAqB,EAC5C,QAAQ,CACT,CAAA;QAED,MAAM,cAAc,CAAC,gBAAgB,CAAC;YACpC,qBAAqB,EAAE,cAAc;SACtC,CAAC,CAAA;QAEF,MAAM,cAAc,CAAC,YAAY,CAC/B;YACE,uBAAuB,CAAC,2BAA2B,CAAC;gBAClD,QAAQ,EAAE,cAAc;aACzB,CAAC;SACH,EACD,EAAE,UAAU,EAAE,KAAK,EAAE,CACtB,CAAA;QAED,OAAO;YACL,MAAM,EAAE,GAAG;YACX,QAAQ,EAAE,IAAI;SACf,CAAA;IACH,CAAC;CAAA"}
|
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
import { BotContext, BotonicRequest, ResolvedPlugins } from '@botonic/shared';
|
|
2
|
-
import { HubtypeExternalAPIService } from '../hubtype-service';
|
|
3
1
|
import { Route } from '../routes/types';
|
|
2
|
+
import { BotonicContext, BotonicRequest, ResolvedPlugins, TypingMode } from '../server';
|
|
3
|
+
import { HubtypeApiService } from '../services/hubtype-api-service';
|
|
4
4
|
/** Config for CoreBot. */
|
|
5
5
|
export interface CoreBotConfig {
|
|
6
6
|
appId?: string;
|
|
7
7
|
defaultDelay?: number;
|
|
8
|
-
defaultRoutes?: (
|
|
8
|
+
defaultRoutes?: (botonicContext: BotonicContext) => Route[];
|
|
9
9
|
defaultTyping?: number;
|
|
10
|
+
defaultTypingMode?: TypingMode;
|
|
10
11
|
plugins?: ResolvedPlugins;
|
|
11
|
-
routes: (
|
|
12
|
+
routes: (botonicContext: BotonicContext) => Route[];
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
|
-
* CoreBot: accepts
|
|
15
|
-
*
|
|
15
|
+
* CoreBot: accepts v2-shaped `BotonicRequest` and runs
|
|
16
|
+
* input() → createBotonicContext → runInput (route, plugins, redirect).
|
|
16
17
|
*/
|
|
17
18
|
export declare class CoreBot {
|
|
18
19
|
appId?: string;
|
|
19
20
|
defaultDelay: number;
|
|
20
|
-
defaultRoutes: (
|
|
21
|
+
defaultRoutes: (botonicContext: BotonicContext) => Route[];
|
|
21
22
|
defaultTyping: number;
|
|
23
|
+
defaultTypingMode: TypingMode;
|
|
22
24
|
plugins: ResolvedPlugins;
|
|
23
|
-
routes: (
|
|
24
|
-
hubtypeService:
|
|
25
|
+
routes: (botonicContext: BotonicContext) => Route[];
|
|
26
|
+
hubtypeService: HubtypeApiService;
|
|
25
27
|
private readonly botonicContextFactory;
|
|
26
|
-
constructor({ appId, defaultDelay, defaultRoutes, defaultTyping, plugins, routes, }: CoreBotConfig);
|
|
27
|
-
|
|
28
|
+
constructor({ appId, defaultDelay, defaultRoutes, defaultTyping, defaultTypingMode, plugins, routes, }: CoreBotConfig);
|
|
29
|
+
run(botonicRequest: BotonicRequest): Promise<void>;
|
|
28
30
|
private runInput;
|
|
29
31
|
private runPrePlugins;
|
|
30
32
|
private getRoute;
|
|
33
|
+
private getCoreRoutes;
|
|
31
34
|
private runPostPlugins;
|
|
32
35
|
private runRedirectAction;
|
|
33
36
|
}
|
|
@@ -1,106 +1,117 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { isUpdateWebchatClientSettingsPayload, MessageType, } from '@botonic/shared';
|
|
3
|
+
import { updateWebchatClientSettingsAction } from '../actions';
|
|
4
4
|
import { runPlugins } from '../plugins';
|
|
5
5
|
import { Router } from '../routes/router';
|
|
6
|
+
import { BotonicAction, BotonicContextFactory, PluginMode, } from '../server';
|
|
7
|
+
import { HubtypeApiService } from '../services/hubtype-api-service';
|
|
6
8
|
/**
|
|
7
|
-
* CoreBot: accepts
|
|
8
|
-
*
|
|
9
|
+
* CoreBot: accepts v2-shaped `BotonicRequest` and runs
|
|
10
|
+
* input() → createBotonicContext → runInput (route, plugins, redirect).
|
|
9
11
|
*/
|
|
10
12
|
export class CoreBot {
|
|
11
|
-
constructor({ appId, defaultDelay = 0.4, defaultRoutes = () => [], defaultTyping = 0.6, plugins, routes, }) {
|
|
12
|
-
this.hubtypeService = new
|
|
13
|
+
constructor({ appId, defaultDelay = 0.4, defaultRoutes = () => [], defaultTyping = 0.6, defaultTypingMode = 'inBetweenTyping', plugins, routes, }) {
|
|
14
|
+
this.hubtypeService = new HubtypeApiService();
|
|
13
15
|
this.appId = appId;
|
|
14
16
|
this.defaultDelay = defaultDelay;
|
|
15
17
|
this.defaultRoutes = defaultRoutes;
|
|
16
18
|
this.defaultTyping = defaultTyping;
|
|
19
|
+
this.defaultTypingMode = defaultTypingMode;
|
|
17
20
|
this.plugins = plugins || {};
|
|
18
21
|
this.routes = routes;
|
|
19
|
-
this.botonicContextFactory = new BotonicContextFactory(this.hubtypeService, this.plugins, this.defaultTyping, this.defaultDelay);
|
|
22
|
+
this.botonicContextFactory = new BotonicContextFactory(this.hubtypeService, this.plugins, this.defaultTyping, this.defaultDelay, this.defaultTypingMode);
|
|
20
23
|
}
|
|
21
|
-
|
|
24
|
+
run(botonicRequest) {
|
|
22
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const
|
|
24
|
-
yield this.runInput(
|
|
25
|
-
if (
|
|
26
|
-
yield this.runRedirectAction(
|
|
26
|
+
const botonicContext = this.botonicContextFactory.create(botonicRequest);
|
|
27
|
+
yield this.runInput(botonicContext);
|
|
28
|
+
if (botonicContext.session.isBotonicActionRedirect()) {
|
|
29
|
+
yield this.runRedirectAction(botonicContext);
|
|
27
30
|
}
|
|
28
31
|
});
|
|
29
32
|
}
|
|
30
|
-
runInput(
|
|
33
|
+
runInput(botonicContext) {
|
|
31
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
35
|
var _a;
|
|
33
|
-
if (
|
|
34
|
-
|
|
36
|
+
if (botonicContext.input.type === MessageType.TypingEvent) {
|
|
37
|
+
botonicContext.response = {
|
|
35
38
|
status: 200,
|
|
36
39
|
response: 'OK',
|
|
37
40
|
};
|
|
38
|
-
return
|
|
41
|
+
return botonicContext;
|
|
39
42
|
}
|
|
40
|
-
yield this.runPrePlugins(
|
|
41
|
-
const route = yield this.getRoute(
|
|
42
|
-
const actionResponse = yield ((_a = route.action) === null || _a === void 0 ? void 0 : _a.call(route,
|
|
43
|
-
yield this.runPostPlugins(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
botContext.response = actionResponse !== null && actionResponse !== void 0 ? actionResponse : { status: 200, response: 'OK' };
|
|
48
|
-
return botContext;
|
|
43
|
+
yield this.runPrePlugins(botonicContext);
|
|
44
|
+
const route = yield this.getRoute(botonicContext);
|
|
45
|
+
const actionResponse = yield ((_a = route.action) === null || _a === void 0 ? void 0 : _a.call(route, botonicContext));
|
|
46
|
+
yield this.runPostPlugins(botonicContext, actionResponse);
|
|
47
|
+
botonicContext.response = actionResponse !== null && actionResponse !== void 0 ? actionResponse : { status: 200, response: 'OK' };
|
|
48
|
+
return botonicContext;
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
runPrePlugins(
|
|
51
|
+
runPrePlugins(botonicContext) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
53
|
if (this.plugins) {
|
|
54
54
|
yield runPlugins({
|
|
55
|
-
|
|
55
|
+
botonicContext,
|
|
56
56
|
mode: PluginMode.PRE,
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
getRoute(
|
|
61
|
+
getRoute(botonicContext) {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const computedRoutes = this.routes(
|
|
63
|
+
const computedRoutes = this.routes(botonicContext);
|
|
64
64
|
const router = new Router([
|
|
65
|
+
...this.getCoreRoutes(botonicContext),
|
|
65
66
|
...computedRoutes,
|
|
66
|
-
...this.defaultRoutes(
|
|
67
|
+
...this.defaultRoutes(botonicContext),
|
|
67
68
|
]);
|
|
68
|
-
const route = router.processInput(
|
|
69
|
+
const route = router.processInput(botonicContext);
|
|
69
70
|
return route;
|
|
70
71
|
});
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
+
getCoreRoutes(botonicContext) {
|
|
74
|
+
return [
|
|
75
|
+
{
|
|
76
|
+
path: 'update-webchat-client-settings',
|
|
77
|
+
payload: payload => typeof payload === 'string' &&
|
|
78
|
+
isUpdateWebchatClientSettingsPayload(payload),
|
|
79
|
+
action: () => __awaiter(this, void 0, void 0, function* () { return yield updateWebchatClientSettingsAction(botonicContext); }),
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
runPostPlugins(botonicContext, response) {
|
|
73
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
85
|
if (this.plugins) {
|
|
75
86
|
yield runPlugins({
|
|
76
|
-
|
|
87
|
+
botonicContext,
|
|
77
88
|
mode: PluginMode.POST,
|
|
78
89
|
response,
|
|
79
90
|
});
|
|
80
91
|
}
|
|
81
92
|
});
|
|
82
93
|
}
|
|
83
|
-
runRedirectAction(
|
|
84
|
-
return __awaiter(this, arguments, void 0, function* (
|
|
94
|
+
runRedirectAction(botonicContext_1) {
|
|
95
|
+
return __awaiter(this, arguments, void 0, function* (botonicContext, numOfRedirects = 0) {
|
|
85
96
|
var _a;
|
|
86
97
|
if (numOfRedirects > 10) {
|
|
87
98
|
throw new Error('Maximum BotAction recursive calls reached (10)');
|
|
88
99
|
}
|
|
89
|
-
const nextPayload =
|
|
100
|
+
const nextPayload = botonicContext.session.getBotonicActionPayload(BotonicAction.Redirect);
|
|
90
101
|
const hadPayload = Boolean(nextPayload);
|
|
91
102
|
if (!hadPayload) {
|
|
92
|
-
yield
|
|
93
|
-
|
|
103
|
+
yield botonicContext.updateBotSession({ botonicAction: null });
|
|
104
|
+
botonicContext.response = {
|
|
94
105
|
status: 200,
|
|
95
106
|
response: 'OK',
|
|
96
107
|
};
|
|
97
|
-
return
|
|
108
|
+
return botonicContext;
|
|
98
109
|
}
|
|
99
|
-
yield
|
|
100
|
-
|
|
101
|
-
const followUpContext = yield this.runInput(
|
|
102
|
-
if (
|
|
103
|
-
return yield this.runRedirectAction(
|
|
110
|
+
yield botonicContext.updateBotSession({ botonicAction: null });
|
|
111
|
+
botonicContext.input.setAsPostback(nextPayload);
|
|
112
|
+
const followUpContext = yield this.runInput(botonicContext);
|
|
113
|
+
if (botonicContext.session.isBotonicActionRedirect()) {
|
|
114
|
+
return yield this.runRedirectAction(botonicContext, numOfRedirects + 1);
|
|
104
115
|
}
|
|
105
116
|
followUpContext.response = (_a = followUpContext.response) !== null && _a !== void 0 ? _a : {
|
|
106
117
|
status: 200,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/core-bot/index.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/core-bot/index.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,oCAAoC,EACpC,WAAW,GACZ,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EACL,aAAa,EAEb,qBAAqB,EAErB,UAAU,GAGX,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAan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ACrD,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,cAAc,GAAG,CAAC,CAAC,CAAA;YACzE,CAAC;YAED,eAAe,CAAC,QAAQ,GAAG,MAAA,eAAe,CAAC,QAAQ,mCAAI;gBACrD,MAAM,EAAE,GAAG;gBACX,QAAQ,EAAE,IAAI;aACf,CAAA;YACD,OAAO,eAAe,CAAA;QACxB,CAAC;KAAA;CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RunPluginArgs } from '
|
|
2
|
-
export declare function runPlugins({
|
|
1
|
+
import { RunPluginArgs } from '../server';
|
|
2
|
+
export declare function runPlugins({ botonicContext, mode, response, }: RunPluginArgs): Promise<void>;
|
package/src/lib/plugins/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { PluginMode } from '
|
|
2
|
+
import { PluginMode } from '../server';
|
|
3
3
|
export function runPlugins(_a) {
|
|
4
|
-
return __awaiter(this, arguments, void 0, function* ({
|
|
5
|
-
const plugins =
|
|
4
|
+
return __awaiter(this, arguments, void 0, function* ({ botonicContext, mode, response = { status: 200, response: 'OK' }, }) {
|
|
5
|
+
const plugins = botonicContext.plugins;
|
|
6
6
|
for (const key in plugins) {
|
|
7
7
|
const plugin = plugins[key];
|
|
8
8
|
try {
|
|
9
9
|
if (mode === PluginMode.PRE && typeof plugin.pre === 'function') {
|
|
10
|
-
yield plugin.pre(
|
|
10
|
+
yield plugin.pre(botonicContext);
|
|
11
11
|
}
|
|
12
12
|
if (mode === PluginMode.POST && typeof plugin.post === 'function') {
|
|
13
|
-
|
|
14
|
-
yield plugin.post(
|
|
13
|
+
botonicContext.response = response;
|
|
14
|
+
yield plugin.post(botonicContext);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/plugins/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAU,UAAU,EAAiB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/plugins/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAU,UAAU,EAAiB,MAAM,WAAW,CAAA;AAE7D,MAAM,UAAgB,UAAU;yDAAC,EAC/B,cAAc,EACd,IAAI,EACJ,QAAQ,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,GAC5B;QACd,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAA;QACtC,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,MAAM,MAAM,GAAW,OAAO,CAAC,GAAG,CAAC,CAAA;YACnC,IAAI,CAAC;gBACH,IAAI,IAAI,KAAK,UAAU,CAAC,GAAG,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;oBAChE,MAAM,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;gBAClC,CAAC;gBACD,IAAI,IAAI,KAAK,UAAU,CAAC,IAAI,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;oBAClE,cAAc,CAAC,QAAQ,GAAG,QAAQ,CAAA;oBAClC,MAAM,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;gBACnC,CAAC;YACH,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YAChB,CAAC;QACH,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BotonicContext } from '../server';
|
|
2
2
|
import { Route } from './types';
|
|
3
3
|
export declare const NOT_FOUND_PATH = "404";
|
|
4
4
|
export declare class NoMatchingRouteError extends Error {
|
|
5
|
-
|
|
6
|
-
constructor(
|
|
5
|
+
botonicContext: BotonicContext;
|
|
6
|
+
constructor(botonicContext: BotonicContext);
|
|
7
7
|
}
|
|
8
8
|
export declare class Router {
|
|
9
9
|
private routes;
|
|
10
10
|
constructor(routes: Route[]);
|
|
11
|
-
processInput(
|
|
11
|
+
processInput(botonicContext: BotonicContext): Route;
|
|
12
12
|
private routeMatches;
|
|
13
13
|
private matchesStringValue;
|
|
14
14
|
}
|
package/src/lib/routes/router.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
export const NOT_FOUND_PATH = '404';
|
|
2
2
|
export class NoMatchingRouteError extends Error {
|
|
3
|
-
constructor(
|
|
4
|
-
super(`No route found for input '${JSON.stringify(
|
|
5
|
-
this.
|
|
3
|
+
constructor(botonicContext) {
|
|
4
|
+
super(`No route found for input '${JSON.stringify(botonicContext.input)}' and no ${NOT_FOUND_PATH} route defined`);
|
|
5
|
+
this.botonicContext = botonicContext;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
export class Router {
|
|
9
9
|
constructor(routes) {
|
|
10
10
|
this.routes = routes;
|
|
11
11
|
}
|
|
12
|
-
processInput(
|
|
12
|
+
processInput(botonicContext) {
|
|
13
13
|
for (const route of this.routes) {
|
|
14
|
-
if (this.routeMatches(route,
|
|
14
|
+
if (this.routeMatches(route, botonicContext)) {
|
|
15
15
|
return route;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
throw new NoMatchingRouteError(
|
|
18
|
+
throw new NoMatchingRouteError(botonicContext);
|
|
19
19
|
}
|
|
20
|
-
routeMatches(route,
|
|
20
|
+
routeMatches(route, botonicContext) {
|
|
21
21
|
var _a, _b, _c;
|
|
22
22
|
const hasMatchers = !!(route.text ||
|
|
23
23
|
route.payload ||
|
|
@@ -28,9 +28,9 @@ export class Router {
|
|
|
28
28
|
if (!hasMatchers) {
|
|
29
29
|
return route.path === NOT_FOUND_PATH;
|
|
30
30
|
}
|
|
31
|
-
const textValue =
|
|
32
|
-
const payloadValue =
|
|
33
|
-
const typeValue =
|
|
31
|
+
const textValue = botonicContext.input.text;
|
|
32
|
+
const payloadValue = botonicContext.input.payload;
|
|
33
|
+
const typeValue = botonicContext.input.type;
|
|
34
34
|
const stringMatcherChecks = [
|
|
35
35
|
{ matcher: route.text, value: textValue },
|
|
36
36
|
{ matcher: route.payload, value: payloadValue },
|
|
@@ -41,13 +41,13 @@ export class Router {
|
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
if ((_a = route.input) === null || _a === void 0 ? void 0 : _a.call(route,
|
|
44
|
+
if ((_a = route.input) === null || _a === void 0 ? void 0 : _a.call(route, botonicContext.input)) {
|
|
45
45
|
return true;
|
|
46
46
|
}
|
|
47
|
-
if ((_b = route.session) === null || _b === void 0 ? void 0 : _b.call(route,
|
|
47
|
+
if ((_b = route.session) === null || _b === void 0 ? void 0 : _b.call(route, botonicContext.session)) {
|
|
48
48
|
return true;
|
|
49
49
|
}
|
|
50
|
-
if ((_c = route.context) === null || _c === void 0 ? void 0 : _c.call(route,
|
|
50
|
+
if ((_c = route.context) === null || _c === void 0 ? void 0 : _c.call(route, botonicContext)) {
|
|
51
51
|
return true;
|
|
52
52
|
}
|
|
53
53
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/routes/router.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAA;AAEnC,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAE7C,YAAY,
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/routes/router.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAA;AAEnC,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAE7C,YAAY,cAA8B;QACxC,KAAK,CACH,6BAA6B,IAAI,CAAC,SAAS,CACzC,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KAAK,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,mBAAmB,EAAE,CAAC;YACrD,IAAI,OAAO,IAAI,KAAK,IAAI,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;gBAChE,OAAO,IAAI,CAAA;YACb,CAAC;QACH,CAAC;QAED,IAAI,MAAA,KAAK,CAAC,KAAK,sDAAG,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;YACxC,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,MAAA,KAAK,CAAC,OAAO,sDAAG,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5C,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,MAAA,KAAK,CAAC,OAAO,sDAAG,cAAc,CAAC,EAAE,CAAC;YACpC,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC;IAEO,kBAAkB,CAAC,OAAsB,EAAE,KAAa;QAC9D,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,OAAO,KAAK,KAAK,CAAA;QAC1B,CAAC;aAAM,IAAI,OAAO,YAAY,MAAM,EAAE,CAAC;YACrC,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC5B,CAAC;aAAM,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;YACzC,OAAO,OAAO,CAAC,KAAK,CAAC,CAAA;QACvB,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Action,
|
|
1
|
+
import type { Action, BotonicContext, BotonicContextInput, BotonicContextSession } from '../server';
|
|
2
2
|
export interface Route {
|
|
3
3
|
action?: Action;
|
|
4
4
|
path?: string;
|
|
@@ -12,4 +12,4 @@ export interface Route {
|
|
|
12
12
|
export type StringMatcher = RegExp | string | ((data: string) => boolean);
|
|
13
13
|
export type InputMatcher = (input: BotonicContextInput) => boolean | Promise<boolean>;
|
|
14
14
|
export type SessionMatcher = (session: BotonicContextSession) => boolean | Promise<boolean>;
|
|
15
|
-
export type ContextMatcher = (
|
|
15
|
+
export type ContextMatcher = (botonicContext: BotonicContext) => boolean | Promise<boolean>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { BotMessageMetadata } from '@botonic/shared';
|
|
2
|
+
import { BotonicOutput, BotonicOutputAudioData, BotonicOutputDocumentData, BotonicOutputImageData, BotonicOutputVideoData, OutputMessageType, OutputMessageTypeMap } from '@botonic/shared';
|
|
3
|
+
import { BotonicButtonMessageData, BotonicCarouselData, BotonicCustomData, BotonicLocationData, BotonicTextData, BotonicTypingEventData, MessageType } from '@botonic/shared';
|
|
4
|
+
import { BotonicWhatsappButtonListData, BotonicWhatsappCatalogData, BotonicWhatsappCTAUrlButtonData, BotonicWhatsappMediaCarouselData, BotonicWhatsappProductCarouselData, BotonicWhatsappProductData, BotonicWhatsappProductListData, BotonicWhatsappTemplateData } from '@botonic/shared';
|
|
5
|
+
import { WebchatClientSettings } from '@botonic/shared';
|
|
6
|
+
export declare abstract class BotServerMessage<T extends OutputMessageType = OutputMessageType> extends BotonicOutput<T> implements BotMessageMetadata {
|
|
7
|
+
readonly bot_interaction_id?: string;
|
|
8
|
+
readonly feedback_enabled?: boolean;
|
|
9
|
+
readonly inference_id?: string;
|
|
10
|
+
readonly typing?: number;
|
|
11
|
+
readonly delay?: number;
|
|
12
|
+
constructor(type: T, data: OutputMessageTypeMap[T], metadata?: BotMessageMetadata);
|
|
13
|
+
}
|
|
14
|
+
export declare class BotServerMessageText extends BotServerMessage<MessageType.Text> {
|
|
15
|
+
constructor(data: BotonicTextData, metadata?: BotMessageMetadata);
|
|
16
|
+
}
|
|
17
|
+
export declare class BotServerMessageAudio extends BotServerMessage<MessageType.Audio> {
|
|
18
|
+
constructor(data: BotonicOutputAudioData, metadata?: BotMessageMetadata);
|
|
19
|
+
}
|
|
20
|
+
export declare class BotServerMessageImage extends BotServerMessage<MessageType.Image> {
|
|
21
|
+
constructor(data: BotonicOutputImageData, metadata?: BotMessageMetadata);
|
|
22
|
+
}
|
|
23
|
+
export declare class BotServerMessageVideo extends BotServerMessage<MessageType.Video> {
|
|
24
|
+
constructor(data: BotonicOutputVideoData, metadata?: BotMessageMetadata);
|
|
25
|
+
}
|
|
26
|
+
export declare class BotServerMessageDocument extends BotServerMessage<MessageType.Document> {
|
|
27
|
+
constructor(data: BotonicOutputDocumentData, metadata?: BotMessageMetadata);
|
|
28
|
+
}
|
|
29
|
+
export declare class BotServerMessageLocation extends BotServerMessage<MessageType.Location> {
|
|
30
|
+
constructor(data: BotonicLocationData, metadata?: BotMessageMetadata);
|
|
31
|
+
}
|
|
32
|
+
export declare class BotServerMessageButtonMessage extends BotServerMessage<MessageType.ButtonMessage> {
|
|
33
|
+
constructor(data: BotonicButtonMessageData, metadata?: BotMessageMetadata);
|
|
34
|
+
}
|
|
35
|
+
export declare class BotServerMessageCarousel extends BotServerMessage<MessageType.Carousel> {
|
|
36
|
+
constructor(data: BotonicCarouselData, metadata?: BotMessageMetadata);
|
|
37
|
+
}
|
|
38
|
+
export declare class BotServerMessageCustom extends BotServerMessage<MessageType.Custom> {
|
|
39
|
+
constructor(data: BotonicCustomData, metadata?: BotMessageMetadata);
|
|
40
|
+
}
|
|
41
|
+
export declare class BotServerMessageTypingEvent extends BotServerMessage<MessageType.TypingEvent> {
|
|
42
|
+
constructor(data: BotonicTypingEventData, metadata?: BotMessageMetadata);
|
|
43
|
+
}
|
|
44
|
+
export declare class BotServerMessageWhatsappButtonList extends BotServerMessage<MessageType.WhatsappButtonList> {
|
|
45
|
+
constructor(data: BotonicWhatsappButtonListData, metadata?: BotMessageMetadata);
|
|
46
|
+
}
|
|
47
|
+
export declare class BotServerMessageWhatsappCTAUrlButton extends BotServerMessage<MessageType.WhatsappCTAUrlButton> {
|
|
48
|
+
constructor(data: BotonicWhatsappCTAUrlButtonData, metadata?: BotMessageMetadata);
|
|
49
|
+
}
|
|
50
|
+
export declare class BotServerMessageWhatsappCatalog extends BotServerMessage<MessageType.WhatsappCatalog> {
|
|
51
|
+
constructor(data: BotonicWhatsappCatalogData, metadata?: BotMessageMetadata);
|
|
52
|
+
}
|
|
53
|
+
export declare class BotServerMessageWhatsappProduct extends BotServerMessage<MessageType.WhatsappProduct> {
|
|
54
|
+
constructor(data: BotonicWhatsappProductData, metadata?: BotMessageMetadata);
|
|
55
|
+
}
|
|
56
|
+
export declare class BotServerMessageWhatsappProductList extends BotServerMessage<MessageType.WhatsappProductList> {
|
|
57
|
+
constructor(data: BotonicWhatsappProductListData, metadata?: BotMessageMetadata);
|
|
58
|
+
}
|
|
59
|
+
export declare class BotServerMessageWhatsappProductCarousel extends BotServerMessage<MessageType.WhatsappProductCarousel> {
|
|
60
|
+
constructor(data: BotonicWhatsappProductCarouselData, metadata?: BotMessageMetadata);
|
|
61
|
+
}
|
|
62
|
+
export declare class BotServerMessageWhatsappMediaCarousel extends BotServerMessage<MessageType.WhatsappMediaCarousel> {
|
|
63
|
+
constructor(data: BotonicWhatsappMediaCarouselData, metadata?: BotMessageMetadata);
|
|
64
|
+
}
|
|
65
|
+
export declare class BotServerMessageWhatsappTemplate extends BotServerMessage<MessageType.WhatsappTemplate> {
|
|
66
|
+
constructor(data: BotonicWhatsappTemplateData, metadata?: BotMessageMetadata);
|
|
67
|
+
}
|
|
68
|
+
export declare class BotServerMessageWebchatClientSettings extends BotServerMessage<MessageType.WebchatClientSettings> {
|
|
69
|
+
constructor(data: WebchatClientSettings, metadata?: BotMessageMetadata);
|
|
70
|
+
}
|
|
71
|
+
export type BotServerMessageType = BotServerMessageText | BotServerMessageAudio | BotServerMessageImage | BotServerMessageVideo | BotServerMessageDocument | BotServerMessageLocation | BotServerMessageButtonMessage | BotServerMessageCarousel | BotServerMessageCustom | BotServerMessageTypingEvent | BotServerMessageWhatsappButtonList | BotServerMessageWhatsappCTAUrlButton | BotServerMessageWhatsappCatalog | BotServerMessageWhatsappProduct | BotServerMessageWhatsappProductList | BotServerMessageWhatsappProductCarousel | BotServerMessageWhatsappMediaCarousel | BotServerMessageWhatsappTemplate | BotServerMessageWebchatClientSettings;
|