@leesiongchan/botstream
TypeScript icon, indicating that this package has built-in type declarations

0.0.10 • Public • Published

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[]): void
  • server A Fastify server.

Observables

  • event$
  • eventReplay$
  • messageEvent$
  • postbackEvent$

Operators

  • ask
  • hears
  • say
  • sendButtonTemplate
  • sendGenericTemplate
  • sendQuickReplies
  • showSenderAction

TODO

  • [ ] xstate Integration
  • [ ] Support multiple channels?

Package Sidebar

Install

npm i @leesiongchan/botstream

Weekly Downloads

0

Version

0.0.10

License

MIT

Unpacked Size

28 kB

Total Files

52

Last publish

Collaborators

  • leesiongchan