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

api-bot

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-bot

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

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

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

BotMsg.BaseCmd

Base class to parse message string into commands and arguments.

Kind: static class of BotMsg
Properties

NameTypeDescription
payloadObjectpayload from bot.
textStringtext message from the payload.
cmdStringCommand string.
tokensArray.<String>Argument tokens.

new BaseCmd(payload, textAccessor)

Create a new BaseCmd instance.

ParamTypeDescription
payloadObjectpayload from bot.
textAccessorfunctionaccessor 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.

ParamTypeDescription
payloadObjectpayload from bot.
textAccessorfunctionaccessor 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

ParamTypeDescription
idStringid of the Facebook recipient to send the message to.
payloadPayloadPayload to Facebook messenger.

FbHook.process(cmds, botCmd) ⇒ Promise

Function to process a bot message from Facebook messenger.

Kind: static method of FbHook

ParamTypeDescription
cmdsObject.<String, Api.Transformer>A map of Api.Transformer.
botCmdBotMsg.BaseCmdBotMsg.BaseCmd instance.

FbHook~Attachment : Object

attachment object for response message to Facebook messenger. details

Kind: inner typedef of FbHook
Properties

NameTypeDescription
typeStringType of attachment, may be image, audio, video, file or template.
payloadAnyPayload of attachment.

FbHook~QuickReply : Object

quick_reply object for response message to Facebook messenger. details

Kind: inner typedef of FbHook
Properties

NameTypeDescription
content_typeStringtext or location.
titleStringCaption of button.
payloadString | NumberCustom data that will be sent back to you via webhook.
image_urlStringURL of image for text quick replies.

FbHook~Message : Object

message object for response message to Facebook messenger. details

Kind: inner typedef of FbHook
Properties

NameTypeDescription
textStringMessage 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.
attachmentAttachmentattachment object. Previews the URL. Used to send messages with media or Structured Messages.
quick_repliesArray.<QuickReply>Array of quick_reply to be sent with messages.
metadataStringCustom 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

NameTypeDescription
idString | Numberid of the Facebook messenger recipient.

FbHook~Payload : Object

payload object for response message to Facebook messenger. details

Kind: inner typedef of FbHook
Properties

NameTypeDescription
recipientRecipientRecipient object.
messageMessageMessage object.
sender_actionStringtyping_on, typing_off or mark_seen.
notification_typeStringREGULAR, SILENT_PUSH, NO_PUSH. Defaults to REGULAR.
tagStringThe message tag string. See Message Tags.

Keywords

FAQs

Package last updated on 18 Oct 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