Code Monkey home page Code Monkey logo

Comments (14)

janober avatar janober commented on May 13, 2024 1

Ah yes n8n can listen to GET or POST request it receives. Simply look under the "Trigger" nodes for "Webhook". It allows you to specify what to listen for exactly and when and how to respond.
It can either respond directly as soon as it receives the webhook (to really just trigger a workflow to start) or it can return the data of the last node (json or binary).

Here a simple example workflow which writes text on an image depending on what was given via the query parameter. Hope it helps. If not simply get back to me. Want to launch the website with more example workflows the next days.

To test it simply press "Execute Workflow" and then visit the test URL which gets displayed in the node under "Webhook URLs". Make sure to save the workflow first as webhooks only work for saved workflows (as the workflow-id is part of the URL).
The URL will look like this:
http://localhost:5678/webhook-test//webhook/test?name=Jim
(You can simply attach the "?name=Jim" yourself.)

Simply copy & paste the following in an empty n8n workflow:

{
  "nodes": [
    {
      "parameters": {
        "path": "test",
        "reponseMode": "lastNode",
        "reponseData": "firstEntryBinary"
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        -100,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://www.needpix.com/file_download.php?url=//storage.needpix.com/thumbs/newspaper-412809_1280.jpg"
      },
      "name": "Read File URL",
      "type": "n8n-nodes-base.readFileFromUrl",
      "typeVersion": 1,
      "position": [
        100,
        300
      ]
    },
    {
      "parameters": {
        "operation": "text",
        "text": "=They found the killer it was {{$node[\"Read File URL\"].data[\"query\"][\"name\"]}}!",
        "fontSize": "=25",
        "positionX": 150,
        "positionY": 180,
        "lineLength": 18
      },
      "name": "Edit Image",
      "type": "n8n-nodes-base.editImage",
      "typeVersion": 1,
      "position": [
        300,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Read File URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read File URL": {
      "main": [
        [
          {
            "node": "Edit Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

from n8n.

smart-reports avatar smart-reports commented on May 13, 2024 1

Hi Jan

Thanks for that. I pasted the code in and it seems to create a workflow.

When I look at the Webhooks URL for test I get this URL:

http://localhost:5678/webhook-test/2/webhook/test

Via Postman I input this as the URL

http://localhost:5678/webhook-test/2/webhook/test?name=Stuart

Auth: None
HTTP Method: Post
Path: test
Response Mode: On Received 200 (how do I change this to give a 201 response to the send of the webhook?
Property Name: name (i changed this manually.

I then get this error on post:

{"code":404,"message":"The requested webhook is not registred.","stack":"ReponseError: The requested webhook is not
registred.\n at TestWebhooks.callTestWebhook

from n8n.

smart-reports avatar smart-reports commented on May 13, 2024

I finally got it to the point of waiting for the webhook-call.....

How do I keep it in persistent listening mode? As soon as it runs once it stops the webhook trigger from listening.

from n8n.

janober avatar janober commented on May 13, 2024

The test webhook does always just listens till it receives the first call and then displays that data in the editor UI as it is only for development and debugging. If you want that it keeps on listening, you have to activate the workflow (top right corner of the window).

If you do that you have to make sure that you use the production webhook URL and not the test one (does not have the "-test" in the URL).

from n8n.

smart-reports avatar smart-reports commented on May 13, 2024

Jan - thanks very much! it works.

Do you know how to change the OnReceived response from 200 to 201?

Do I have to configure it somewhere?

I currently get 200 response with this message:

{
"message": "Workflow got started."
}

from n8n.

janober avatar janober commented on May 13, 2024

On success it always returns 200, changing it to 201 is currently not possible. I can look how complicated it would be to make that configurable for the next release.

When you have "Response Mode" set to "On Received" it will always return just "Workflow got started". If you want to return something else you have to set it to "Last Node" and then make sure that the last node returns the data you want it to return.

from n8n.

smart-reports avatar smart-reports commented on May 13, 2024

Thanks Jan - much appreciated. Any plans to connect with the Quickbooks Online API?

from n8n.

janober avatar janober commented on May 13, 2024

You are welcome. Glad that it works now.
Actually want to have a connection to more or less every online service. Sadly does each integration take some time to create and my time is limited. So hope that the other people from the community (once it exists, some point after the proper launch) create more.
For now have planned to make it possible somewhere for people to suggest integrations and I will then create one after another with the most demand. Can inform you here once I have something in place.

Close the ticket for now as your problem seems to be solved.

from n8n.

janober avatar janober commented on May 13, 2024

Just released a new version of n8n (0.18.1) which includes the functionality to set a custom response code on the Webhook-Node.

from n8n.

smart-reports avatar smart-reports commented on May 13, 2024

Just released a new version of n8n (0.18.1) which includes the functionality to set a custom response code on the Webhook-Node.

Thanks Jan - I am going to test it

from n8n.

gabrieligbastos avatar gabrieligbastos commented on May 13, 2024

hi, it's me again =(
testing this sample, i'm receiving now:

Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:146:25)
    at writeGeneric (internal/stream_base_commons.js:137:3)
    at Socket._writeGeneric (net.js:698:11)
    at Socket._write (net.js:710:8)
    at doWrite (_stream_writable.js:428:12)
    at writeOrBuffer (_stream_writable.js:412:5)
    at Socket.Writable.write (_stream_writable.js:302:11)
    at gm._spawn (/Users/gbastos/Development/ThirdParties/n8n/node_modules/gm/lib/command.js:253:18)
    at /Users/gbastos/Development/ThirdParties/n8n/node_modules/gm/lib/command.js:140:19
    at series (/Users/gbastos/Development/ThirdParties/n8n/node_modules/array-series/index.js:11:36)

am i missing any library for this specific node?

from n8n.

janober avatar janober commented on May 13, 2024

That is possible as the problem is in "gm" which is http://www.graphicsmagick.org/
So you should look that you get graphicsmagick installed and then also that problem is fixed and the "Edit Image" node should work.

from n8n.

gabrieligbastos avatar gabrieligbastos commented on May 13, 2024

thanks, that was what i thought.
now working but not writting the text indeed.
image

maybe some error in the lib yet?
another doubt, something in the build process should had installed it? do u think is interesting some way to learn node dependencies?

from n8n.

janober avatar janober commented on May 13, 2024

Sorry sadly can not really help there. Must be something graphicsmagick related in combination with MacOS. You can try some of their examples on the website via the commandline and see if they work.

The docker-image has everything included and there everything will run for sure. Self installing is always more problematic especially on systems that run MacOS. Would be suprised if everything would run perfectly as I do not have a Mac and it is known to make problems.

When n8n gets build it installs all the packages but not additional software and that is correct like that. Graphicsmagick is also just needed for that one node and that one is also more to show what can be done and playing around than something people are currently using for anything at all. But have to add somewhere that if people want to use that node they have to make sure that this package is installed.

from n8n.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.