0.0.14 • Published 7 years ago

chatbot-flow v0.0.14

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

Building Conversations for Chatbots

NPM version Build Status Coverage Status License

chatbot-flow is an implementation of finite state machines built with chatbot conversations in mind.

Install

npm install chatbot-flow

Usage

import {Flow} from 'chatbot-flow'

const flowConfig = {
  defaultState: 'ONE',
  states: {
    ONE: {
      next: 'TWO',
      message: {
        text: 'This is an initial statement that doesn\'t need a response',
      },
      noReply: true,
    },
    TWO: {
      next: 'END',
      message: {
        text: 'This is my first question',
      },
    },
    END: {
      noReply: true,
      next: null,
      message: user => ({
        text: `Your answer to my first question was "${user.responses.TWO.text}"`,
      }),
    },
  },
}

const flow = new Flow(flowConfig)

flow.getMessages('123', {text: 'Hey There'})
.then(messages => {
  /*
  messages:
  [{text: 'This is an initial statement that doesn\'t need a response'},
   {text: 'This is my first question'}]

  You can use send this array using whatever platform you choose: Facebook Messenger, Slack, etc...
  */
})
.then(() => flow.getMessages('123', {text: 'This is my answer'}))
.then(messages => {
  /*
  messages:
  [{text: 'Your answer to my first question was "This is my answer"'}]
  */
})

Contact

If you have any feedback, ideas, requests, or other thoughts, feel free to reach out to me at dbsullivan23@gmail.com

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago