示例节点

这是一个示例节点,用于演示如何创建自定义n8n节点

Actions4

Overview

This node is an example custom n8n node designed to demonstrate how to create and manage resources such as users and products. Specifically, for the "产品" (product) resource with the "创建" (create) operation, it allows users to create a new product by providing product details like name, price, and description. The node then returns the created product data including a generated ID and creation timestamp.

This node is beneficial in scenarios where you want to simulate or prototype workflows involving product management without connecting to a real external API. For example, you can use it to test automation flows that require creating product entries before integrating with actual services.

Properties

Name Meaning
产品数据 A collection of fields describing the product to create. Includes:
- 名称 The name of the product.
- 价格 The price of the product (number).
- 描述 A textual description of the product.

Output

The node outputs a JSON array containing one object representing the created product. The structure includes:

  • id: A generated identifier string for the new product (e.g., "新ID").
  • name: The product's name as provided in input.
  • price: The product's price as provided in input.
  • description: The product's description as provided in input.
  • createdAt: ISO 8601 timestamp string indicating when the product was created.

Example output JSON:

[
  {
    "id": "新ID",
    "name": "Example Product",
    "price": 99.99,
    "description": "A sample product description",
    "createdAt": "2024-06-01T12:00:00.000Z"
  }
]

No binary data output is produced by this node.

Dependencies

  • This node does not depend on any external APIs or services; it simulates data internally.
  • It requires an API key credential configured in n8n (generic exampleCredentials) to operate, but this is only for demonstration purposes.

Troubleshooting

  • Common issues:
    • Missing required product fields (e.g., name) may cause incomplete output.
    • If the node throws errors, ensure all required parameters are set correctly.
  • Error messages:
    • Errors will be returned as JSON objects with an error field if the node is set to continue on failure.
    • Typical error messages relate to missing parameters or internal exceptions during execution.
  • To resolve errors, verify input parameters and check the node’s configuration.

Links and References

Discussion