npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

botmaster-fulfill

v5.0.0

Published

Declarative markup API and engine to integrate internal or external APIs with botmaster

Downloads

563

Readme

Build Status Coverage Status

Botmaster fulfill

Battle-tested middleware for botmaster https://botmasterai.github.io/).

Now updated to handle malformed tags! This is a breaking change since it requires negative look-behind in nodejs, so only nodejs > 9 is supported. You can get it at

Enable chatbots to perform actions on Node.js.

Developers write "action specs" that specify how an XML tag should be replaced in a chatbot response, such as confirming that the action was performed simply returning an empty string so that the tag is removed.

Chatbot designers then place the XML tags in their flows for easy integration.

Also check out our pre-made actions:

| Actions | Repository | | --------------- | ------------------------------------------------------------------------------------- | | pause, greet | botmaster-fulfill-actions | | button, buttons | botmaster-button |

Quick start

// 1. Import botmaster and setup your bots, for example telegram
const Botmaster = require('botmaster');
const Telegram = require('botmaster-telegram');
const telegramSettings = require('./my-telegram-bots-settings');
const botmaster = new Botmaster();
const telegramBot = new TelegramBot(telegramSettings);
botmaster.addBot(TelegramBot);

// 2. set up any incoming middleware that you might need

// 3. at the end set up fulfill outgoing ware...
const {fulfillOutgoingWare} = require('botmaster-fulfill');
const actions = {
        hi: {
            controller: () => 'hi there!'
        },
        bye: {
            controller: () => 'bye please come again'
        }
}
botmaster.use(fulfillOutgoingWare({actions}));

// Profit. Any messages that telegram bot sends will be processed by fulfill
telegramBot.sendTextMessageTo('<hi />', 1234);
telegramBot.sendTextMessageTo('<bye />', 1234);

API Reference

isPendingActions

Test for remaining actions in a string

Parameters

  • string String input string to test for actions
  • actions Object actions to test for

Returns Boolean whether any actions were found

fulfill

Fulfill any actions found in the input text

Parameters

  • actions Object actions to run
  • context Object an object of aditional properties to expost though params
  • input String the string to look for actions in
  • tree Array? provided as a way to speed up recursion. You probably don't need to use this and providing it without fulfillPromise (or vice versa) will cause an error.
  • fulfillPromise Array? Used to let controllers know that fulfill has completed (or hit an error) even though this is a recursed function. You probably don't need to use this.
  • cb Function error first callback

defaultInput

Default function to extraxt input for fulfill from botmaster context. Uses simply message.message.text. If it does not exist then fulfill does not run.

Parameters

  • $0 Object context object consisting of botmaster objects and next
    • $0.message Object the botmaster message

defaultResponse

Default function to update botmaster middleware context with fulfill response and call next. It only sets message.message.text if the response is a non empty string after trimming. Otherwise it calls next with "cancels" which cancels the outgoing message.

Parameters

  • $0 Object context object consisting of botmaster objects, fulfill response, and next
    • $0.message Object botmaster message
    • $0.response String respopnse from fulfill
    • $0.next Function next function from botmaster outgoing middleware

FulfillWare

Generate outgoing middleware for fulfill

Parameters

  • options Object options
    • options.actions Object the actions to use
    • options.inputTransformer Function? a function that receives {bot, message, update} and returns the fulfill input or a falsy value to skip running fulfill.
    • options.reponseTransformer Function? a function that receives ({bot, message, update, response, next}) updates the message and calls next.
    • options.params Object? an object of additional names to provide in params.

Returns function outgoing middleware