-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.ts
39 lines (35 loc) · 1.03 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import GetStartedInput from "./GetStartedInput";
import { InputRule, InputPlugin } from "../../common/interfaces/input-plugin";
import { registerInputPlugin } from "../helper";
import getMessagesListWithoutControlCommands from "../../webchat-ui/utils/filter-out-control-commands";
const rule: InputRule = ({
config: {
settings: {
startBehavior: {
startBehavior,
getStartedButtonText,
getStartedData,
getStartedPayload,
getStartedText,
},
},
},
messages,
}) =>
(messages.length === 0 ||
(messages.length === 1 && messages[0].source === "engagement") ||
getMessagesListWithoutControlCommands(messages)?.length === 0) &&
startBehavior === "button" &&
!!getStartedPayload &&
(!!getStartedButtonText ||
!!getStartedText ||
(!!getStartedData &&
typeof getStartedData === "object" &&
Object.keys(getStartedData).length > 0));
const getStartedInputPlugin: InputPlugin = {
type: "rule",
rule,
component: GetStartedInput,
};
registerInputPlugin(getStartedInputPlugin);
export default getStartedInputPlugin;