Skip to main content

First integration

1. What you'll learn​

This introductory lesson covers the main components of the "Integrations" module and walks through a practical example. You'll learn how to:

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

2. Inject node​

The Inject node simulates input data and starts the flow.

3. Function node​

Use the Function node to pass in the input number.

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

This sets the number 5 and passes it into the flow.

4. Switch node:​

The Switch node checks whether the number is positive, negative, or zero and routes the data based on the result.

  • Setting:
    • If the number is greater than 0, pass it to the "Positive" branch.
    • If the number is less than 0, pass it to the "Negative" branch.
    • If the number equals 0, pass it to the "Zero" branch.

5. Template node:​

In the Template node, create a template for the output message.

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

This node inserts the text produced by the previous node and prepares it for output.

6. Debug node:​

The Debug node writes the result to the console so you can see the final message.

  • Setting: Set the output to msg.payload to print the generated message to the console.

7. Result:​

If the number passed into the flow is 5, Debug shows:

Result of the check: The number is positive

If you change the number to -3, the result is:

Result of the check: The number is negative

If the number is 0, the result is:

Result of the check: The number is zero