Basic example for HTTP trigger node?

hi forum, is there any code example of a custom http trigger node? I need to implement one and would probably save loads of time if someone could point me to an example. (coming from python I’m totally new to typescript and node development, that stepping stone would be awesome :slight_smile: )
cheers! axel.

Hi Axel!

One idea would be finding an already existing trigger node for a service similar to the one you are interested in, and locating its file in the codebase to use it as an example.

You will find all trigger nodes as <Service>Trigger.node.ts in this directory:

FYI I know that our DevRel is actively working on some documentation on node creation so better learning resources are on the way soon!

that’s good to hear :smiley: .

any “recommendations” for an easy HTTP trigger node? :wink:

You could look at the Pushcut trigger node: https://github.com/n8n-io/n8n/blob/master/packages/nodes-base/nodes/Pushcut/PushcutTrigger.node.ts

Quick overview:

  • checkExists() returns a boolean for whether the webhook is currently registered at the third-party service.
  • If the webhook is not registered, create() registers the webhook at the third-party service and immediately checks if the registration was successful. This occurs when you activate the workflow from the top-right toggle (production mode, persistent) or when you click on “Execute Node” (test mode, for 2 minutes).
  • webhook() receives the payload from the third-party service and sends it into the workflow.
  • delete() de-registers the webhook from the third-party service. This occurs when the workflow is de-activated or when test mode expires.

This could also come in handy: https://medium.com/n8n-io/webhooks-fun-with-n8n-and-mattermost-4ebf7e2b4d2a

3 Likes