Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bot-worker-engine

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bot-worker-engine

Simple bot engine

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Bot Worker Engine

Build StatusJavaScript Style Guide

A simple bot engine dispatching workers. (mostly and deliberately without OOP)

Installation

npm install bot-worker-engine

Usage

Here is a simple counting echo bot as example. This might be inside the function which received a web hook call and normalized the input data from one messaging event

const {orchestrate} = require('bot-worker-engine')
const {send, userDate} = require('<platform-dependent-connector>')
const persistence = require('<persistence-layer')
// these are where your code goes
const helpers = require('./helpers') // any helper functions you might need
// example worker just
const workers = {
  main: (dispatcher, store, bot, helpers) => {
    const {text, session} = store.getState().input
    bot.send.text(`Echo (${session.count}): ${text}`)
    store.dispatch({type: 'INCREMENT_COUNT'})
    dispatcher.emit('finished')
  }
}
const reducer = (action, state) => {
  switch(action.type) {
    case 'INCREMENT_COUNT':
      const session = state.session
      session.count++
      return Object.assign({}, state, {session})
    default:
      return state
  }
} // Redux reducer function
const sessionDefaults = {count: 1} // defaults for empty sessions

// this starts the whole process of the normalized input
orchestrate({input, sessionDefaults, workers, reducer, persistence, send, userData, helpers})

Keywords

FAQs

Package last updated on 09 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc