RedBot 1.0

A new version of RedBot was released today, the biggest change is Mission Control: a persistance layer and pluggable control panel for RedBot's bots.

Key features:

  • Storage for inbound and outbound messages (SQLite)
  • Chatbot user management and persisted chat context (SQLite)
  • Admins management with multiple roles
  • Basic Content Management System with custom fields
  • Chatbot simulator
  • GraphQL endpoint to access SQLite database
  • New Node-RED nodes (MC GraphQL, MC Simulator, etc)
  • Plugins repository for additional features
  • Pluggable and open architecture
  • Docker image
Mission Control is not enabled by default to ensure maximum retro-compatibility. Run Node-RED with the env variable REDBOT_ENABLE_MISSION_CONTROL (i.e. REDBOT_ENABLE_MISSION_CONTROL=true node-red -u /my-node-red-project)

User Management

Users management

When enabled, the bot is persisting bot's user information (fist name, last name, language, chat context, etc) that can be inferred or extracted from the chat platforms. All users can be searched, modified or deleted from Mission Control (i.e. change user's detail or inspecting the current chat context).

Each new user receives a unique userId which can be used to identify the user within the chatbot indipendently from the chat platform (i.e. the same user can access the bot with multiple platforms, there's a 1-to-many relation between userId and chatId).

A custom JSON payload field can be used to store anything related to a user, it can be modified from Mission Control or - programmatically - using the MC GraphQL node in Node-RED.

Messages Storage

Messages are automatically stored in SQLite, it's now possible to inspect messages filtering for chatId, platform, userId or chatId.


Access can be granted to an unlimited number of admins with fine grain permissions.

Every feature has it own set of permissions that can be added individually to each admin.
The Mission Control's panel can handle multiple chatbots, admins can be assigned to all or specific chatbots.

Chatbot Simulator

It's now possible to simulate the bot with the chatbot simulator inside Mission Control, it's even possible to impersonate an existing user to investigate on production problems.

Implementing the simulator is easy, just drop the MC Simulator nodes in the flow like normal senders and receivers.

GraphQL support

SQLite database can be accessed with GraphQL: chabots can read/write data using MC GraphQL node, admins can read/write data using Mission Control's panel, third party systems can read/write data using the /graphql endpoint (with a security token).

These are the available entities

users chatbot's user
messages the inbound and outbound messages
content the post-like contents
records user-related entities (i.e. orders, invoices, etc)

Content Management System

Content Management System

It's a simple post-like content management system with some basic fields (i.e. title, body, category, language, etc) plus

slug it's an arbitrary id to identify a content. For example it's possible to fetch the content with MC Content node using the slug instead of the numeric id or it's possible to use it to identify the same content in different languages (multi-language support)
custom fields a list of structured and typed fields for a content (string, number, etc)
payload a custom JSON field that can contain anything
namespace contents are grouped by namespace, the default one is content, but it's possible to develop plugins using different namespaces and reusing the same UI, the Mission Control's CMS can be used to store anything

New Node-RED nodes

A bunch of new nodes are available to use the power of Mission Control:

MC Content to easily fetch content from Mission Control's CMS using the slug or the id
MC GraphQL to explore and persist data on SQLite using simple GraphQL queries
MC Simulator sender / receiver add these nodes to simple add support for the simulator in Mission Control
MC User Payload to store and persist any kind of json payload into the user's space in SQLite


This is actually the most important feature. Mission Control has an open architecture and it's pluggable: every feature is a plugin, new and optional features can just be plugged into the control panel.

Some simple plugins are already available in the Plugins Store like Send Direct Message, Commands, Knowledge Base, Authorization and more to come in the future.

Since RedBot is open source, everyone can develop custom plugins using React and RSuite (docs for this is still not available).

Docker image

There's an official Docker image for RedBot, just run it to quickly test RedBot in a local environment or to easily deploy in production.

Just run (Mission Control is not enabled by default)

 docker run -d -p 1880:1880 \

Authenticating Node-RED web sockets

While developing extension nodes for Node-RED is sometimes useful to re-use the built-in Web Sockets channel (/comms) to provide two ways communication between the extension and Node-RED.

Everything works fine until the moment we put everything in production and we secure the Node-RED server, the web socket connection remains pending. That's because the Web Socket connection is initiated through the http:// protocol (which requires authentication) and then upgraded to ws://.

I've found the solution after digging a little in the Node-RED code (since the lack of documentation on this topic)

import Sockette from 'sockette';
const ws = new Sockette(
  'http://localhost:1880/comms', // the Node-RED server  
    // ...
    onopen: () => {
      const raw = localStorage.getItem('auth-tokens');
      let json;
      try {
        json = JSON.parse(raw)
      } catch(e) {
        // do nothing
      if (json != null && !_.isEmpty(json.access_token)) {

Basically the trick is to use the same Node-RED authentication token to authenticate the web socket connection.

RedBot 0.19.4

Some recent changes in Slack API remove the bot scope from RTM API. That basically means the for all new applications it's not possible to use the RTM API and the old ones will stop working at the end of 2020.

The 0.19.4 will use the Event API which has the drawback of being not compatible with the Express stack of Node-RED, for this reason the web hook server is running in a separate Express app on a different port (that can be configured in the connection panel).

Follow the updated instruction here to upgrade to the new connection params.

Twilio connector for RedBot

Create an account on Twilio (you'll need to verify a mobile number to proceed)

In order to create a SMS service you have to buy a Twilio phone number (any country is fine).

Twilio sends notification of incoming messages with a callback, use ngrok to expose your development instance of Node-RED to a public address, open a Terminal window and

ngrok http localhost:1880

You should get something like this


The address https://* is the public URL that

Setting up a dev chatbot for Facebok and RedBot

This is a quick tutorial to setup a very simple chatbot with Facebook Messenger and RedBot.

First of all install Node-RED

sudo npm install -g node-red

Then open the user data directory $HOME/.node-red and install the package

cd $HOME/.node-red npm install node-red-contrib-chatbot

Then run node-red.

Setting up a Facebook Messenger is quite tricky since Facebook API talks to Red-Node via a https callback (a self signed certificate is not enough). It also requires a verify token that makes

Store user response in RedBot

Working with chatbots it's sometimes useful to parse and store the user response somewhere.

In RedBot there's the chat context, it's a volatile memory space where it's possible to store variables related to the current chat user, for example consider this flow in which we ask the user to type in his email.


The first Message node just sends out the question to the user "What is your email?" (always use a conversational tone with a chatbot and not cold

Logging conversations with RedBot

Running a chat bot requires some caring, in particular you're never done training it.

A good habit is to inspect the chat bot log searching for user sentences that were not recognized by the bot and then update the parsers Listen node, RiveScript node, etc) in order to support it.

Log filename

In RedBot every platform receiver can log the conversation to a file, it looks like

196520947 [Guido Bellomo] > Wed Oct 05 2016 12:08:45 GMT+0000

NetAtmo dashboard for Node-RED

There are few Node-RED nodes for the NetAtmo weather station, most of them return data of the sensors as time series.

I needed something simpler for my chatbot, a way to get fetch all current values from all sensors, something like this

  "temperature": 27.5,
  "co2": 246,
  "humidity": 60,
  "noise": 38,
  "pressure": 1009.5,
  "pressureTrend": "stable",
  "externalTemperature": 30,
  "externalHumidity": 51,

Setup a simple Telegram chatbot with RedBot

This is a quick tutorial to setup a very simple chatbot with Telegram and RedBot.

First of all install Node-RED

sudo npm install -g node-red

Then open the user data directory $HOME/.node-red and install the package

cd $HOME/.node-red npm install node-red-contrib-chatbot

Then run


The next step is to create a chat bot, I recommend to use Telegram since the setup it's easier ( Telegram allows polling to receive messages, Facebook requires a https callback and a valid https

RedBot, a chatbot framework for Node-RED


RedBot is a Node-RED framework to create chatbots for Telegram, Facebook and Slack. Almost no coding skills required.

Node-RED is a tool for wiring together hardware devices, APIs and online services in new and interesting ways.

With RedBot it's possible to easily create chatbots just wiring together basic blocks like message, audio, location, etc. and interact with the Node-RED ecosystem. If you have particular need, you can do it by yourself in NodeJS, it's all open source!

RedBot is able

Middleware in NodeJS

Talking with a collegue of mine I came up with this solution about organizing the code in NodeJS+Express using middlewares.
Consider this example in which we have a simple page that performs two queries and shows the result in a template.
Since everything is asynchronous, we chain in two queries in this way

app.get('/mypage', function(req,res,next) {
    .on('success', function(res_query1) {
        .on('success', function(res_query2) { 

Tiny little JavaScript polling object

Few days I came across this situation where I had to check, at predefined interval, against a remote server for some conditions. So just for not having the setTimeout and setInterval ids hanging around my code, I wrapped everything in a small JavaScript object Poller.

It's pretty simple: just configure any number of intervals, a callback in case of success, a callback in case of failure, and the function that checks the server

var poller = new Poller();