
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@menome/botframework
Advanced tools
Common functionality for building bots (containerized microservices with a specific set of API calls) for integration with the Menome stack
This package contains a common framework for all bots that integrate with theLink or the Menome stack.
Bots commonly have the following functionality:
To use the framework, just follow these steps:
var bot = new Bot({config, configSchema})
) (See Below)bot.start()
bot.changeState({state: "idle"})
For a complete list of functions that you can utilize, see the API Docs
Configuration is specified in the following structure: (Default values shown)
{
"name": "SQL Harvester",
"desc": "Harvests from something",
"nickname": "World Database Harvester",
"urlprefix": "/",
"logging": true,
"port": 80,
"rabbit": {
"enable": false,
"url": "amqp://rabbitmq:rabbitmq@rabbit:5672?heartbeat=3600",
"routingKey": "syncevents.harvester.updates.example",
"exchange": "syncevents",
"exchangeType": "topic"
},
"neo4j": {
"enable": false,
"url": "bolt://localhost",
"user": "neo4j",
"pass": "password"
},
"ssl": {
"enable": false,
"certpath": "/srv/app/ssl/cert.pem",
"keypath": "/srv/app/ssl/key.pem",
"port": 443
}
}
Configuration is handled through Mozilla Convict. For more information on our baseline config structure, see the config schema.
When creating a new bot, call the constructor and supply an object like the one above as a config parameter.
Additionally, you can specify a configSchema
. This will be merged in with the default bot schema for when you want to supply your own configuration parameters.
For example, this would set up a new bot with some custom config parameters.
var bot = require('@menome/botframework')
var config = {
name: "JSON Placeholder Bot",
desc: "Harvests data from JSON placeholder.",
nickname: "Jerry",
// (Add some additional config params for rabbit, neo4j, ports in use, etc)
}
var configSchema = {
url: {
doc: "The URL of the REST Endpoint we're grabbing",
format: "url",
default: "https://jsonplaceholder.typicode.com",
env: "API_URL"
}
}
var bot = new Bot({ config, configSchema });
The Bot Framework is built to be OpenAPI compliant. Navigate to the [bot address]/docs
to view the bot's OpenAPI spec through the swagger UI
To register additional endpoints, you must call bot.registerPaths(paths, controllersDir);
.
An easy way to sed this up is to have a subdirectory called 'controllers' in which you put your controllers and their swagger stubs. A file in this directory might look like this:
// controllertest.js
module.exports.swaggerDef = {
"/ping": {
"x-swagger-router-controller": "controllertest",
"get": {
"tags": [
"JSONPlaceholder"
],
"responses": {
"200": { "description": "Success" },
"default": { "description": "Error" }
}
}
}
}
module.exports.get = function(req,res) {
return res.send({message: "Pong!"});
}
To load these and register them with the bot, you can do something like this:
var path = require('path');
bot.registerControllers(path.join(__dirname,"./controllers"));
bot.start())
For more information on OpenAPI and Swagger, read their documentation here.
FAQs
Common functionality for building bots (containerized microservices with a specific set of API calls) for integration with the Menome stack
We found that @menome/botframework demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.