0.0.10 • Published 6 years ago
@leesiongchan/botstream v0.0.10
botstream
Facebook Messenger + RxJS + xstate = botstream (POC)
Motivation
WIP
Usage
import botstream, { messageEvent$ } from '@leesiongchan/botstream';
const bot = botstream({
facebookAccessToken: '1234',
facebookApiVersion: 'v4', // Optional, default = 'v4'
facebookVerifyToken: '2345',
port: 3000,
});
const echoConvo$ = messageEvent$.pipe(say(ev => `Echo: ${ev.message.text}`));
const helloConvo$ = event$.pipe(
hears(['hello'], 'message'),
say('Ok, hello! How can I help you?'),
);
bot.loadSkills(echoConvo$, helloConvo$);APIs
botstream
botstream(config: BotstreamConfig)loadSkills(skills: Observable[]): voidserverA Fastify server.
Observables
event$eventReplay$messageEvent$postbackEvent$
Operators
askhearssaysendButtonTemplatesendGenericTemplatesendQuickRepliesshowSenderAction
TODO
- xstate Integration
- Support multiple channels?