reactflowchat-core
v0.0.2
Published
Core engine for flow-based chat systems used by ReactFlowChat
Maintainers
Readme
reactflowchat-core
Core engine for flow-based chat systems.
Installation
npm install reactflowchat-coreBasic usage
import { initState, step } from "reactflowchat-core";
import type { Flow } from "reactflowchat-core";
const flow: Flow = {
id: "demo",
start: "welcome",
nodes: {
welcome: {
type: "message",
text: "Hello!",
next: "askName",
},
askName: {
type: "input",
key: "name",
placeholder: "Your name",
next: "end",
},
end: {
type: "end",
text: "Thanks, {{name}}",
},
},
};
let state = initState(flow);
state = step(flow, state, { type: "start" });
state = step(flow, state, { type: "submit_input", value: "David" });Exports
initStatesteploadStatesaveStateclearStateuidtemplateFlowNodeMessageNodeInputNodeChoiceNodeEndNodeChatMessageChatStatePersistence
Persistence
type Persistence = "localStorage" | "sessionStorage" | "none";License
MIT
