flowchat
flowchat
is a modern ES6 reactive framework for building scalable, maintainable and testable chat bots.
With flowchat
your chat bot consists of multiple flows that are triggered by incoming messages or by other flows.
Flows
Each flow determines how the state of the conversation changes and how the bot responds.
A flow consists of three elements:
activator
- a function that determines whether the flow should run for a given input and conversation state. Synchronous or Promise-based.reducer
- a redux reducer that specifies how the conversation state should change for a given input.saga
- a redux-saga that allows running asynchronous code for a given input at ease, including replying to the user or communicating with APIs.
I/O
flowchat
provides Subject input
, output
and state
, making no assumptions on where the conversation input comes from and where the output should go, or how you persist the conversation state. Using Subject for input, output and state also allows for their easy and modular mapping.
The Gist
helloFlow.js
; const activator = input === 'hello'; const reducer = Object; { ;} const helloFlow = activator reducer saga;
app.js
; ; const bot = ;let sessionId = Math; bot; botstate;botoutput; botinput;// logs "state: { saidHello: true }"// logs "data: Hello, user!"
Getting started
Install
$ npm install --save flowchat
or
$ yarn add flowchat
Documentation
Basics concepts
- Getting started [COMING SOON]
- Session [COMING SOON]
- Creating a Facebook Messenger chat bot [COMING SOON]
Advanced topics
- Plugging AI [COMING SOON]
- i18n
- Creating a middleware [COMING SOON]
- Using with Immutable.js [COMING SOON]