4 min read

addTwoNumbers Documentation

Overview

The node is a lightweight utility designed to sum two numerical inputs. It is ideal for applications where simple arithmetic operations are needed. This function ensures that the inputs are valid numbers and returns their sum, making it easy to integrate basic calculations into larger workflows or data processing pipelines.

Purpose

The primary purpose of the node is to provide a straightforward solution for adding two numbers. This can be useful in various scenarios, including data processing, analytics applications, or any context where numerical sums are required.

Settings

The node offers the following settings:

1. Input Configuration

Setting Name: input1

Setting Name: input2

Behavior: Both input1 and input2 can accept values in various forms (as numbers or strings). The function will attempt to convert these inputs into numbers using the node. If either of the inputs is non-numeric, the function will throw an error.

Output

Setting Name: output1

How It Works

The node begins by destructuring inputs and config objects to retrieve the values for input1 and input2. If the values are not found, it defaults to 0. It then converts the inputs to numbers and checks their validity:

  1. Converts input1 and input2 to numerical values.
  2. Validates that both values are numbers. If either input is invalid (e.g., non-numeric), it throws an error.
  3. Computes the sum of input1 and input2.
  4. Returns the computed sum as an object with a property named output1.

Expected Data

The node expects the following data format:

Use Cases & Examples

Use Cases

  1. Data Transformation in ETL Processes: Useful in Extract, Transform, Load (ETL) processes where constant summation of various numerical fields is required, like aggregating sales revenue.
  2. Real-Time Calculations: Can be employed in dashboards to calculate and display real-time statistics involving user input, such as total expenses or revenue.
  3. Integration in APIs: Can be used as part of a backend service that provides additional functionality for applications requiring simple arithmetic operations.

Example Configuration

Use Case: Summing two numerical inputs for an expense tracker application where users input their daily expenditures.

Configuration Example

json
{
  "inputs": {
    "input1": "150",
    "input2": "250"
  },
  "config": {}
}

Expected Output:

json
{
  "output1": 400
}

In this example, the user inputs values for input1 as 150 and input2 as 250. When passed to the node, it computes the sum, resulting in an output of 400.

AI Integrations and Billing Impacts