Using OpenCore Forms

Create a Form in OpenCore

In this section, users will learn how to create a Form in OpenCore. Refer to the Forms section for more information.

  1. Navigate to the Forms page and click the Add Form button. Add Form Button

  2. Drag a Text Field form to the Form designer. Drag Text Field

  3. Change the Label parameter to Please enter 'Hello from OpenCore!' below. Change Label

  4. Click on the API tab and change the Property Name to hello_from_openflow. Change Property Name

  5. Click the Save button, set the Form name as hellofromopenflow, and save it. Save Form

Congratulations! You have successfully configured a Form in OpenCore.

Configure Form in Node-RED

Next, learn how to configure the Form in Node-RED.

  1. Create a new flow in Node-RED and rename it to Forms. Rename Flow

  2. Drag a workflow in node to the workspace. Drag Workflow In

  3. Set up the workflow in node properties. Configure Workflow In

  4. Drag a switch node and configure it for processing the variable returned from the Form. Configure Switch Node Configure Cases Switch

  5. Drag workflow out nodes and configure them based on the user input. Drag Workflow Out Configure Workflow Out Drag Second Workflow Out Configure Second Workflow Out

  6. Add a debug node to observe the message passed into the Form. Drag Debug Node

  7. Deploy the configuration. Flow Configuration Finished

Now your Form is configured in Node-RED and ready to be used!

Invoking the Form

In this section, users will learn how to invoke the Form just created using Node-RED.

  1. Drag an inject node to the workspace. Drag Inject Node

  2. Drag an assign node to the workspace and wire it to the inject node. Drag Assign Node

  3. Configure the assign node’s properties to assign the Workflow to openflowformsexample. Configure Assign Node

  4. Click the Deploy button to update the Flow. Click Deploy Button

  5. Click the button inside the inject node to assign an instance of the Workflow to the users role.

  6. Navigate to OpenCore’s home page to see the instance of the Workflow. OpenCore Homepage

  7. Test the Form by entering Hello from OpenCore! in the text field and clicking the Submit button. A debug message will appear in Node-RED. Debug Message

This completes the process of invoking the Form using Node-RED. Users can now test and interact with the Form they have created.

Email Receive, Send

There are two types of “email” nodes in Node-RED: “email watcher” for receiving emails and “email sender” for sending emails.

Receive Emails

Setting Up Email Watcher

The email watcher node searches for new emails from an IMAP server and forwards them as messages.

  • Configuration:
    • Provide e-mail ID and password.
    • Set “Disposition” to “Mark Read” to avoid constant messages about the same emails.
    • Use the suggested port (993).
    • Some e-mail services require enabling less secure apps for access. Email Watcher Node

Redirecting Emails

A “switch” node filters messages based on properties like msg.payload, msg.date, or msg.from. For instance, msg.date can be used to delay redirecting weekend emails to Monday.

Email Redirecting

Send Emails

Using Email Sender

The email sender node sends an email to the specified address. It requires an e-mail address and password of the sender.

Email Sender Node

Creating an HTTP Endpoint

API’s Basic Structure

To create an HTTP endpoint in Node-RED, use “HTTP In” and “HTTP Response” nodes.

Steps

  1. Drag the “HTTP In” and “HTTP Response” nodes into the Workspace and connect them.
  2. Add a “Template” node for HTML content between these nodes.
  3. Configure the “HTTP In” node:
    • Method: “GET”
    • URL: “/homepage”

HTTP Endpoint Basic Structure

Creating a Database and Adding New Items

To add items to a MongoDB database, use a “HTTP In” node with a “POST” method and an “Add” node from the API category.

Steps

  1. Configure the “HTTP In” node with the method “POST” and URL “/newuser”.
  2. Configure the “add” node with collection details and input/output fields.
  3. Test the API using an API tester with a “POST” request and JSON formatted body.

Adding New Items

Get a Full List of Items

Retrieve a list of all items using the “HTTP In” node with a “GET” method and a “Get” node.

Steps

  1. Set the method of the “HTTP In” node to “GET” and URL to “/listusers”.
  2. Configure the “get” node to retrieve the desired information.

Getting Full List of Items