Return code when using Webhook's "Response Data" feature

Hi,

I need to return a response code to Webhook for a bot to work.

So far I’ve been able to do this just by putting a code in the “Response Data:” field:

{
  "replies": [
    {
      "message":"Response OK"
    }
  ]
}

However, I wanted to use functions from other nodes ahead, but he can’t get the result.

ex:

{
  "replies":[
    {
      "message":"Response: {{$node["HASH"].parameter["functionCode"]}}"
    }
  ]
}

How could I do that? because in my tests, it returns only the encoding and not the result.

tks

Sorry, do not understand what exactly you want to do. But it is not possible to get data from nodes “ahead” as that nodes would not have been executed yet and would so not have any data.

Anyway here a basic example that returns custom data from a previous node:

1 Like

Hi, thanks again for the reply.

I did not get it yet.

See the example:

{
  "nodes": [
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "message",
              "value": "=TEST OK"
            }
          ]
        },
        "options": {}
      },
      "name": "set message",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        750,
        550
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n  replies: [\n    {\n      \"message\":\"SET HERE\"\n    }\n  ]\n}\n  }\n];\n"
      },
      "name": "json",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        950,
        550
      ]
    }
  ],
  "connections": {
    "set message": {
      "main": [
        [
          {
            "node": "json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

I want to display the result of the set message node (TEST OK) on line 6 of the json node (SET HERE).

tried in many ways and failed.

In short, I need to display a result of the set message inside json, how to do this?

Honestly still do not understand how exactly the response should look like but here are two different version. Activate only one Webhook-Node at a time, else it will cause problems:

Hope that helps!

1 Like

thanks! that was exactly it.

you are amazing :clap:

Glad to hear that it helped. Have fun!

1 Like