NO-CODE with Serverless Action — Node-RED and Openwhisk

Blumareks
5 min readJul 27, 2021

This short blog post is about running Node-RED in IBM Cloud in Summer 2021 Saute — just a hello world, and with Serverless on the side with drippings into Cloudant database.

  • Step 1 — Sauté Hello World with Node-RED in IBM Cloud
  • Step 2 — Serverless on the Side, with Cloudant drippings (you will insert results of the action into Cloudant — NOSQL DB)

The Sauté Hello World with Node-RED in IBM Cloud

In order to spin a Node-RED service on IBM Cloud these days you need to simply follow couple steps — visit this 4 min video to see on how to do it. You would need a free LITE account on IBM Cloud.

You can use this link to invoke IBM Cloud registration/signup/login page (this URL gives an author = me some brownie points): https://ibm.biz/Bd2CUa

How to spin a Node-RED service in IBM Cloud — Summer 2021

Et voila — Hello World ici!

Congratulations! You have created Hello World with NO-CODE on IBM Cloud using Node-RED. If you want to check the sides, go on!

The Node-RED main with Serverless on the Side, with Cloudant drippings (you will insert results of the action into Cloudant — NOSQL DB)

After the Node-RED Hello World is done, you might want to use my repository to import a JSON with the flow as shown here (or you might want simply to drag and drop the nodes from the left menu of Node-RED) :

The initial Node-RED flow — the red triangles informing about blank setup of the nodes.

You might find this flow’s JSON in my repo here:

Serverless action — getting your side ready

First of all you want to create a Serverless action using IBM Cloud Functions. Just click start creating and use a template to get a helloworld action there. Then you are ready to create your first Serverless Function (Serverless Skill)

  • From the menu (a hamburger) on the top left pick the Functions

Select Functions and Overview

  • Now you can start creating your first Serverless action
Create a meaningful package name — for the node-red example I used the name of the package (1) node-red-flow, and I chose Python (on a request from Good Tech Scholars Program)

Start with Quickstart “Hello World” Template in Python 🐍 as I used it above, or choose Swift Language, or JavaScript.

Now you can run the hello world example — simply click invoke — and the system would respond back within milliseconds.

The Serverless technology in IBM Cloud ⛅️ (and other clouds) usually has 400,000 GBs free tier PER MONTH — isn’t that great for a developer community?! Read my book — details in the bottom of this blog on where to use Serverless!

Wire your Serverless action to your Node-RED flow

If you open Serverless action and Node-RED tabs side by side you might have such a view:

Opening the Serverless Action and Node-RED flow tabs side by side is a good idea! 💡

You can now open the OpenWhisk node (“Action”), and configure it with the details from the helloworld action (the left tab):

Defining the parameters of the Openwhisk node (right), with the details from Serverless action (left).

Now you need to click on the EYE 👁 icon in the Serverless Endpoints at the CURL to see the API-KEY and copy the shown API Key over to the Node-RED). This is how it is going to look like for you:

Paste the API Key in the Auth Key field, and give it some meaningful Name — it is just for the display on the flow, eh.

As soon as it is done, you might want to open also the Cloudant DB node, and specify a name of the Database, where the output from the Serverless action is going to be inserted (I chose to call it nodered-test).

Check also the Function nodes — I defined the input parameter in the first one — for the Openwhisk = Serverless Action:

{ "name":"node-red" }

When you invoke the flow by clicking on the TIMESTAMP node — you will get the response on the right DEBUG view 🐛 (look for that bug on the top right!)

{greeting : "Hello node-red"}

This is the entire flow:

And this is the insert in the Cloudant NOSQL DB (in the LITE = free mode):

Yay! It did work! To open this view — go to your IBM Cloud Resources (hamburger — resources — services — Cloudant DB ☁️- and launch the management console — then go to the DB you specified in the Node-RED flow, and select a document 📄 to view this :-)

Congratulations! You have wired the Serverless action with the Node-RED no-code flow!

Hint! The flow to copy from the github is here — in order to import it in the Node-RED flow — use the Node-RED hamburger 🍔 menu (top right) — use import — from the clipboard — and paste the entire flow with from the first bracket (including the bracket) { to the last bracket } … https://github.com/blumareks/2021-gtsp/blob/main/node-red-example.md#copy-and-import-the-code-into-node-red

Importing the JSON with the flow from the Clipboard. 📋

And I would forget to mention — Always DEPLOY when you see blue circles 🔵

Always DEPLOY when you see the blue circles!

Let me know if that worked for you — just clap! 👏 That would make me very happy.

And last, but not least:

You might want to checkout my book on Serverless Swift — https://www.apress.com/us/book/9781484258354

Thank you for reading this blog post/book. Follow me on Twitter: http://twitter.com/blumareks

--

--

Blumareks

I am a technology advocate for autonomous robots, AI, mobile and Internet of Things - with a view from both the enterprise and a robotics startup founder.