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

api-bot

v0.0.1

Published

NodeJS lib to handle various instructions for an api-bot.

Downloads

4

Readme

api-bot

An api-bot is an customizable chat bot that can proxy with any APIs and transform the results into a bot message. A JSON or YAML config file is used to describe the both the interaction with the API and the transformation of the output. The config file/doc can also easily be served via a noSQL database.

This is a NodeJS library to handle various instructions for an api-bot.

Quick start

yarn add api-bot --save

API Reference

BotMsg

Module for handling messages from bot.

BotMsg.BaseCmd

Base class to parse message string into commands and arguments.

Kind: static class of BotMsg
Properties

| Name | Type | Description | | --- | --- | --- | | payload | Object | payload from bot. | | text | String | text message from the payload. | | cmd | String | Command string. | | tokens | Array.<String> | Argument tokens. |

new BaseCmd(payload, textAccessor)

Create a new BaseCmd instance.

| Param | Type | Description | | --- | --- | --- | | payload | Object | payload from bot. | | textAccessor | function | accessor function to extract message text from the payload. |

baseCmd.text ⇒ String

Kind: instance property of BaseCmd
Returns: String - text message from the payload

baseCmd.payload ⇒ Object

Kind: instance property of BaseCmd
Returns: Object - payload payload from bot.

baseCmd.cmd ⇒ Object

Kind: instance property of BaseCmd
Returns: Object - cmd Command string.

baseCmd.tokens ⇒ Array.<String>

Kind: instance property of BaseCmd
Returns: Array.<String> - tokens Argument tokens.

BotMsg.SlashCmd ⇐ BaseCmd

Class to extract a slash command string (i.e. /hello) and the argument tokens from a text message.

Kind: static class of BotMsg
Extends: BaseCmd

new SlashCmd(payload, textAccessor)

Create a new SlashCmd instance.

| Param | Type | Description | | --- | --- | --- | | payload | Object | payload from bot. | | textAccessor | function | accessor function to extract message text from the payload. |

slashCmd.text ⇒ String

Kind: instance property of SlashCmd
Returns: String - text message from the payload

slashCmd.payload ⇒ Object

Kind: instance property of SlashCmd
Returns: Object - payload payload from bot.

slashCmd.cmd ⇒ Object

Kind: instance property of SlashCmd
Returns: Object - cmd Command string.

slashCmd.tokens ⇒ Array.<String>

Kind: instance property of SlashCmd
Returns: Array.<String> - tokens Argument tokens.

FbHook

Module for handling Facebook messenger hooks.

FbHook ⏏

Utility class to handle Facebook messenger APIs.

Kind: Exported class

FbHook.send(id, payload) ⇒ Promise

Utility class to handle Facebook messenger APIs.

Kind: static method of FbHook

| Param | Type | Description | | --- | --- | --- | | id | String | id of the Facebook recipient to send the message to. | | payload | Payload | Payload to Facebook messenger. |

FbHook.process(cmds, botCmd) ⇒ Promise

Function to process a bot message from Facebook messenger.

Kind: static method of FbHook

| Param | Type | Description | | --- | --- | --- | | cmds | Object.<String, Api.Transformer> | A map of Api.Transformer. | | botCmd | BotMsg.BaseCmd | BotMsg.BaseCmd instance. |

FbHook~Attachment : Object

attachment object for response message to Facebook messenger. details

Kind: inner typedef of FbHook
Properties

| Name | Type | Description | | --- | --- | --- | | type | String | Type of attachment, may be image, audio, video, file or template. | | payload | Any | Payload of attachment. |

FbHook~QuickReply : Object

quick_reply object for response message to Facebook messenger. details

Kind: inner typedef of FbHook
Properties

| Name | Type | Description | | --- | --- | --- | | content_type | String | text or location. | | title | String | Caption of button. | | payload | String | Number | Custom data that will be sent back to you via webhook. | | image_url | String | URL of image for text quick replies. |

FbHook~Message : Object

message object for response message to Facebook messenger. details

Kind: inner typedef of FbHook
Properties

| Name | Type | Description | | --- | --- | --- | | text | String | Message text. Previews will not be shown for the URLs in this field. Use attachment instead. Must be UTF-8 and has a 640 character limit. | | attachment | Attachment | attachment object. Previews the URL. Used to send messages with media or Structured Messages. | | quick_replies | Array.<QuickReply> | Array of quick_reply to be sent with messages. | | metadata | String | Custom string that is delivered as a message echo. 1000 character limit. |

FbHook~Recipient : Object

payload object for response message to Facebook messenger.

Kind: inner typedef of FbHook
Properties

| Name | Type | Description | | --- | --- | --- | | id | String | Number | id of the Facebook messenger recipient. |

FbHook~Payload : Object

payload object for response message to Facebook messenger. details

Kind: inner typedef of FbHook
Properties

| Name | Type | Description | | --- | --- | --- | | recipient | Recipient | Recipient object. | | message | Message | Message object. | | sender_action | String | typing_on, typing_off or mark_seen. | | notification_type | String | REGULAR, SILENT_PUSH, NO_PUSH. Defaults to REGULAR. | | tag | String | The message tag string. See Message Tags. |