Catenis Flow Guide

Send Message Node

The “Send Message” node on Catenis Flow allows you to send directed messages to other Catenis Virtual devices and have them also recorded to the blockchain. Additionally, this node has the ability to send a message requesting a Read confirmation. When the message is read by the recipient virtual device it is marked on the blockchain (by spending and additional output on the Bitcoin transaction) making it cryptographically provable that the receiving device has read the message. Read confirmation also triggers a notification event that can be received by the sending virtual device.

Image of the Send Message Node

Node Properties Panel Field Description

Node property configuration slide-out panel (this panel is accessed by double-clicking on the node).

2020-07-27_19-56-02
Image of The Log Message Node

Node-RED Specific Fields

  1. Name Field:  Add a descriptive name of your choice that will help differentiate this node from others of the same type on the Node-RED workspace (not required).
  2. Connection Field: This drop-down selection is required.  Set a previously configured Catenis connection (virtual device). If you need to configure a new virtual device. click the pencil button to the right of the field and follow the direction on setting up a new virtual device that can be found here.

Catenis Flow Setting Fields

  1. Target Device ID: Enter the device ID of the device you wish to send the message to.
  2. Product Unique ID: Check this box if the supplied ID in #3 is a product unique ID.
  3. Encoding Drop-Down: Catenis Flow will automatically encode the content you send into one of three types you designate:
    1. UTF-8: Typically associated with textual content and is the default encoding type Catenis uses
    2. Base-64: Typically used when one wants to handle data stored in the form of a document.
    3. Hexadecimal: Typically used when one wants to express binary numbers in hex. It makes it easier than using any other base number system.
  4. Encrypt Checkbox: Catenis Flow defaults to encrypting all content it logs with military-grade encryption. Deselect this checkbox if you want your data to be logged in clear-text
  5. Off-Chian Checkbox: All Catenis messages default to being sent via the Catenis off-chain protocol. You can choose to disable off-chain messages and sent a standard message instead. Disabling off-chain messages is highly discouraged as standard messages incur higher fees, cost more Catenis credits and create unneeded bitcoin transactions.
  6. Storage Drop-Down: Catenis Flow supports two different modes of storage and adds automatic detection based on content size:
    1. Auto – This mode will automatically detect the size of the content you are logging and if the content is 75 bytes or less it will place the content in a Bitcoin transaction. If the content is above 75 bytes is will create a signature hash of the content and placed the signature hash in the Bitcoin transaction and place the content on IPFS.
    2. Embed – This setting will force the content being logged to be embedded within a Bitcoin transaction.  If the content is above 75 bytes Catenis Flow will return an error message.
    3. External – This setting will force the content being logged to be hashed, it’s hash will be placed within a Bitcoin transaction and its content will be placed in external IPFS storage even if the content is smaller than 75 bytes.
  7. Read confirmation: Indicate whether you wish to send the message with the read confirmation capability enabled. This will record the target devices read event to the blockchain and send a notification confirmation to the device sending the message that the message has been read. The notification is sent in real-time and requires that a notification channel is active.
  8. Async Checkbox: This setting forces the content to be logged asynchronously and is useful when handling content that is large in size, typically above 10 Megabytes.

Note: Additional properties can be set by passing a JSON object when handling large content. Please refer to handling large content which can be found here: https://blockchainofthings.com/docs/large-message-handling/

How to use

  1. Drag and drop this node from the Catenis Flow pallet area to the Node-RED workspace. Double-click it to display its properties slide-out panel.
  2. On the “Device” drop-down field of the properties slide-out panel, choose the Catenis virtual device you previously configured. The virtual device is a configuration node containing the Catenis Virtual device information (device ID and API Secret key). If you do not have a virtual device configured see the section titled: “Configure your first virtual device on Node-RED” 
  3. Add the node’s configuration information based on your needs to each field of the properties slide-out panel.  Please refer to the description of each field under the section named “Node Properties Panel Field Description” on proper usage.
  4. Wire this node to a debug node. 
  5. Next, drag and drop an “inject” node to the Node-RED workspace.
  6. Wire the “inject” node to the  “send message” node, then double click the inject node to open its properties slide-out panel. 
  7. Alter the information in the “inject” node’s properties slide-out panel by selecting the drop-down “Payload” field and choose the “JSON” Type. An Ellipse button “…” will appear to the right of the field. Click this ellipse button to display a JSON edit box. 
  8. Enter the JSON information you wish to pass as input to the Catenis Node (an example JSON input is below). After entering your JSON text entry click the red Done button. Then click the Done button again to exit the properties dialogue box.
  9. Click the red Deploy button on the upper right-hand side of the Node-RED dashboard to deploy this flow.
  10. Now let’s test the flow: Click the button on the left attached to the “inject” node to send the input from the “inject” node to the flow.
  11. The debug sidebar should display the returned JSON object containing the API call results to the right side of the workspace.

Example JSON Object that can be passed to this node


{
    "message": "Hello World",
    "targetDevice": {
        "id": "########",
        "isProdUniqueId": false
    },
    "options": {
        "encoding": "utf8",
        "encrypt": false,
        "storage": "auto",
        "readConfirmation": true,
        "async": false
    }
}


Note: Inputs injected into this node via a JSON object containing alternate node properties will override the properties set on this node's slide-out properties panel. In addition, you will also need to set the proper target device Id in the input JSON object. Replace the "#####" with your target device Id.

Example Flow - Import Into Node-Red to Get Started


[{"id":"8e499725.2b5c68","type":"debug","z":"50d73d42.5eecf4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":750,"y":140,"wires":[]},{"id":"9891448c.8671b8","type":"send message","z":"50d73d42.5eecf4","name":"","device":"","toDeviceId":"","isProdUniqueId":false,"encoding":"utf8","storage":"auto","encrypt":false,"readConfirmation":true,"async":false,"x":460,"y":140,"wires":[["8e499725.2b5c68"]]},{"id":"3264da4a.45a076","type":"inject","z":"50d73d42.5eecf4","name":"","topic":"","payload":"{\"message\":\"Hello World\",\"targetDevice\":{\"id\":\"Enter target device ID\",\"isProdUniqueId\":false},\"options\":{\"encoding\":\"utf8\",\"encrypt\":false,\"storage\":\"auto\",\"readConfirmation\":true,\"async\":false}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":140,"wires":[["9891448c.8671b8"]]},{"id":"23a53f13.7e44","type":"comment","z":"50d73d42.5eecf4","name":"Set virtual device for this Catenis node","info":"All Catenis nodes require that you set the proper virtual device on its slideout property panel on the device field.\n\nNot setting the device properly will result in a \"TypeError: Cannot read property 'ctnApiClient' of null\" ","x":470,"y":100,"wires":[]},{"id":"44d1d0aa.dba86","type":"comment","z":"50d73d42.5eecf4","name":"Double click for instructions","info":"**For Injection Node:**\nYou must update the target device Id field in the JSON file to a target device of your own\n\nExample: Update this part of the JSON file\n    \"targetDevice\": {\n        \"id\": \"Replace with your target device ID\",\n    },\n    \n**For Send Message node:**\nEnter your own target device ID\n\nYou must enter your target device ID (device you are sending a message to) in either the Target Device ID field of the node's properties slide out panel or pass the Target device ID from the inject node via the JSON file configured in the inject node.\n\nKeep in mind that inputs injected into this node via a JSON object containing alternate node properties will override the properties set on this node's slide out properties panel.","x":130,"y":40,"wires":[]}]

Note: After importing this flow you will need to set the Catenis Flow node(s) in this flow to use a previously configured virtual devices. Instructions on how to set up your virtual device on Node-RED can be found here: https://blockchainofthings.com/docs/configure-your-first-virtual-device-on-catenis-flow/

Related Articles

CompanyElement_SM_LightBackgrounds
How can we make things Better for you?
  • Accepted file types: jpg, gif, png, pdf.
  • This field is for validation purposes and should be left unchanged.