Custom node, output type or test data

Describe the issue/error/question

We’re building private custom webhook nodes, and we’d like to put test data or output type of the webhook incoming information, so the user can later use the Variable Selector on the expressions, is it possible?

Test Data:

Variable Selector:

Custom Node

import { IWebhookFunctions } from "n8n-core";

import {
  IDataObject,
  INodeTypeDescription,
  INodeType,
  IWebhookResponseData,
} from "n8n-workflow";

export class MicrochipPreRegisteredByPartner implements INodeType {
  description: INodeTypeDescription = {
    displayName: "Microchip Pre Registered By Partner",
    name: "microchipPreRegisteredByPartner",
    icon: "file:upet-logo.svg",
    group: ["trigger"],
    version: 1,
    description: "Microchip pre-registered by partner",
    defaults: {
      name: "Microchip Pre Registered By Partner",
      color: "#FFFFFF",
    },
    inputs: [],
    outputs: ["main"],
    webhooks: [
      {
        name: "default",
        httpMethod: "POST",
        responseMode: "onReceived",
        // Each webhook property can either be hardcoded
        // like the above ones or referenced from a parameter
        // like the "path" property bellow
        path: '={{$parameter["path"]}}',
      },
    ],
    properties: [
      {
        displayName: "Path",
        name: "path",
        type: "string",
        default: "microchip-preregistered",
        placeholder: "",
        required: true,
        description: "The path to listen to",
      },
      {
        displayName: "Filters",
        name: "filters",
        type: "collection",
        placeholder: "Add Field",
        default: {},
        options: [
          {
            displayName: "Type",
            name: "type",
            type: "options",
            options: [
              {
                name: "Automated",
                value: "automated",
              },
              {
                name: "Past",
                value: "past",
              },
              {
                name: "Upcoming",
                value: "upcoming",
              },
            ],
            default: "",
          },
        ],
      },
    ],
  };

  async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
    // The data to return and so start the workflow with
    const returnData: IDataObject[] = [];
    returnData.push({
      headers: this.getHeaderData(),
      params: this.getParamsData(),
      query: this.getQueryData(),
      body: this.getBodyData(),
    });

    return {
      workflowData: [this.helpers.returnJsonArray(returnData)],
    };
  }
}

Hey @Daniel_F_Jaramillo,

What happens when you run the node, Do you not get any data out of it at all?

Hi @Jon Yeah we get the data, but I was thinking if we can put an example on the node code so the user does not have to run the node in order to have an example schema.

Oh I see, As far as I know there is no way to automatically create an output for the node without it running but the good news is with data pinning they would only need to run the node once.

I am not sure if we are going to add an option to nodes to allow some mock data to be present but it sounds like a solid feature request.

@Jon Thanks for the quick answer Jon, do you know if there is a way I can consume an API to automatically subscribe the webook url?

Like

  1. User created webhook node →

  2. The URL webhook is generated →

  3. Custom API is consumed for subscribing

e.g:

POST: http://custom.api.com/webhookSubscription Body: { event: 'Custom_event', url: 'https://test.n8n.upet.co/webhook/55061d9a-0b95-472f-8294-a6eb7cb2acb6/' }

Hey @Daniel_F_Jaramillo,

That should be fine if you look at some of the Trigger nodes that do this already like Zendesk you will find the create method that gets called this goes off to set up the webhook on the third party system as long as it has an API to allow it.

@Jon Thanks Jon