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
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) :
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
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:
You can now open the OpenWhisk node (“Action”), and configure it with the details from the helloworld action (the left tab):
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:
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):
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
And I would forget to mention — Always DEPLOY when you see 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