Skip to main content

First Integration

1. What will you learn?

In this introductory lesson, we will get acquainted with the main components of the "Integrations" module and create a practical example. You will learn how to:

  • Use the Function node to write your own functions in JavaScript.
  • Apply the Template node to generate text templates with dynamic data.
  • Configure the Inject, Debug, and Switch nodes to initiate flows, check results, and set conditions.

2. Inject Node

The Inject node will be used to simulate input data and start the flow.

3. Function Node

We will use the Function node to pass an input number.

  • Code in Function Node:
    msg.payload = 5; // Input number
    return msg;

Here we set the number 5, which we pass into the flow.

4. Switch Node:

The Switch node will be used to check whether the number is positive, negative, or zero, and pass data accordingly.

  • Configuration:
    • If the number is greater than 0, pass to the "Positive" branch.
    • If the number is less than 0, pass to the "Negative" branch.
    • If the number is equal to 0, pass to the "Zero" branch.

5. Template Node:

In the Template node, we will create a template for outputting a message.

  • Template in Template Node:
    Result of the check: {{payload}}

This node will substitute the text generated in the previous node and prepare it for output.

6. Debug Node:

The Debug node will output the result to the console so we can see the final message.

  • Configuration: Set the output to msg.payload to display the generated message in the console.

7. Result:

If the number passed into the flow is 5, in Debug you will see the message:

Result of the check: The number is positive

If you change the number to -3, the result will be:

Result of the check: The number is negative

If the number is 0, the result will be:

Result of the check: The number is zero