OL Connect automation with Node-RED

Node-RED is a programming tool for wiring together hardware devices, APIs and online services. It was originally developed by IBM as an open source project and evolved into a general purpose IoT/IIoT (Internet of Things/Industrial Internet of Things) programming tool. It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette.

Objectif Lune has added its own set of nodes to this palette: OL Connect nodes. These nodes allow Node-RED to communicate with the OL Connect server and access the OL Connect database and File Store.

The information in this chapter will help you get started using Node-RED as an automation tool with OL Connect. It focuses on the OL Connect nodes, the settings that need to be made to communicate with the OL Connect server, and the most common flows in OL Connect solutions with Node-RED.
Tips and techniques regarding standard nodes and tasks in such solutions can be found in another topic: Node-RED: nodes and common techniques.

For general information about Node-RED, please refer to Node-RED's website: nodered.org.

Installation

Follow the instructions on Downloading and installing Node.js and npm | npm Docs (npmjs.com).

Start the Node-RED editor. Next, download and install the OL Connect Nodes using the Palette module: in the right-hand sidebar, click Manage Palette and look for 'olc'.

OL Connect nodes

In a Node-RED application for OL Connect, flows communicate with the Connect Server and access its Database and/or File Store through one or more OL Connect nodes.

  • capture folder

    This node monitors a folder for incoming files. The folder path can be set via a global variable. Typically these global variables are populated in a startup flow.

  • data mapping, data get, set properties

    These three nodes access the OL Connect database in order to either store or retrieve data - extracted from data files - or to set properties on the data.

  • paginated content, paginated job, paginated output, all in one, preview pdf

    These nodes are create print output.

  • email content

    This node renders emails, which can then be sent using third party nodes, via an Email Service Provider (for example SendGrid).

  • html content

    This node renders web pages or Capture OnTheGo forms based on an OL Connect template.

  • preview image

    This node merges the Print, Email or Web context of an OL Connect template with a single record and returns an image.

  • file upload, file download, file delete

    These nodes access the OL Connect File Store, which holds OL Connect resources such as templates and data mapping configurations as well as output files such as email content and PDF files.

  • set properties

    This node allows to set properties on data in the OL Connect Database.

  • cotg publish, cotg delete

    Using these nodes, Capture OnTheGo forms can be published to or deleted from the Capture OnTheGo repository.

In addition, one configuration node is used by all nodes except the cotg nodes:

  • Add new OL Connect Server config node

    This node allows entering a URL and credentials to connect to an OL Connect server.
    Note that these OL Connect Server settings are not exported with a flow and must be reconfigured in each flow.

The documentation of all individual nodes is embedded in Node-RED's editor. Hover over a node in the palette at the left, or select the node in a flow; then click the book icon.

Connection settings for OL Connect Server

In order to setup a OL Connect Server connection:

  1. Add one of the OL Connect nodes (not a cotg node) to a flow.

  2. Double-click the node to open its Properties window and click the Edit Server icon (a pencil).

  3. Enter the URL, user name and password to use to connect to the OL Connect Server.

  4. Click Done.

The next time you add an OL Connect node to this flow, the server will appear in the list of servers in that node's Properties window.

OL Connect Server settings are not exported with a flow and must be reconfigured in each flow.

OL Connect resources in Node-RED

OL Connect resources are files created with the Designer or DataMapper. In order to use them in the OL Connect nodes in a flow in Node-RED they need to be deployed to the OL Connect Server first.

Deployed resources are registered in the OL Connect database and saved in the File Store. OL Connect nodes can either refer to them by name or by using the internal database ID (also referred to as the managed file ID). The simplest approach is to use the resource name in the respective field of the node.

There are two ways to deploy OL Connect resources to the File Store: using the Designer or from within a flow in Node-RED's editor.

Flows in an OL Connect application

These are some of the typical flows in a Node-RED OL Connect solution.

  • Startup flow

    A Startup flow initializes variables in Node-RED's context - through which information is shared between nodes without using the messages that pass through a flow - and deploys Connect resources for the project. See OL Connect Startup flow for a detailed description.

  • Print flow

    A print flow creates and outputs paginated content. See An OL Connect print flow in Node-RED.

  • Email flow

    An email flow creates email content and stores it in the File Store or sends it immediately using an email service provider. See An OL Connect email flow in Node-RED.

  • Web (form) flow

    A web flow creates web content and stores it in the File Store or serves it immediately. See An OL Connect web flow in Node-RED.

  • COTG flows

    Capture OnTheGo flows create and send forms to the Capture OnTheGo mobile application and process data that is sent back from the application. See Capture OnTheGo flows in Node-RED.

  • PDF preview flows

    A PDF preview flow provides a PDF preview, usually at the request of a browser. See An OL Connect preview PDF flow in Node-RED.