Error sending message to Discord via webhook

I’m trying to send the summary of a workflow to a private channel in a discord server. I’m not trying to do anything fancy, such as react to anything in the channel, I’m just trying to “dump” the results via a webhook. For some reason, the node keeps erroring out and I’m not sure if it’s a permissions thing or what. FWIW, I can successfully “curl” the webhook sending data just fine from the N8N node’s host, even though N8N itself is running on that node in Kubernetes. Shelling into the pod itself, I CAN ping discord.com and resolve to a valid IP address, but due to apk being locked down in the Docker container, you can’t do much more than ping or nslookup.

Here is a copy/pasta stacktrace of the error from the node:

{
  "errorMessage": "Cannot read properties of undefined (reading 'error')",
  "errorDetails": {},
  "n8nDetails": {
    "n8nVersion": "1.102.4 (Self Hosted)",
    "binaryDataMode": "default",
    "stackTrace": [
      "TypeError: Cannot read properties of undefined (reading 'error')",
      "    at ExecuteContext.parseDiscordError (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/Discord/v2/helpers/utils.ts:32:30)",
      "    at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/Discord/v2/actions/webhook/sendLegacy.operation.ts:153:34)",
      "    at processTicksAndRejections (node:internal/process/task_queues:105:5)",
      "    at ExecuteContext.router (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/Discord/v2/actions/router.ts:70:17)",
      "    at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/Discord/v2/DiscordV2.node.ts:33:10)",
      "    at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1212:9)",
      "    at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1582:27",
      "    at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:2153:11"
    ]
  }
}

and the node itself:

Any help moving beyond this would be immensely appreciated!

Information on your n8n setup

  • n8n version: 1.102.4
  • Database (default: SQLite): Postgresql
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker in Kubernetes
  • Operating system: K8S nodes: Debian 12

Hi Skippy,

You’re on the right track narrowing it down to the Discord webhook call. When n8n throws that undefined error it usually means the Discord API returned a non-JSON body or a non-2xx status that the node didnt parse.

A quick framework I use for webhook issues:

  1. Confirm the webhook URL includes /webhooks/{id}/{token} exactly and no extra path segments.
    1. Send a minimal payload first (content field only) using the HTTP Request node in POST mode to verify the endpoint outside of the Discord node.
    1. Check the response status and headers in the execution log; Discord often replies with 204 No Content for success. Any 4xx will include a JSON message field that hints at missing permissions.
      A couple of questions to pinpoint it:
       Is the channel a private thread under a public channel or a standalone private channel?
       Does the bot have the Send Messages permission in that channel and is the webhook owner role still active?

Typical next steps:
 Regenerate the webhook in Discord to get a fresh token, then update the credentials in n8n.
 If running behind a proxy check that the outbound request isnt being rewritten to HTTP/1.0 which Discord rejects.

This is general guidance based on my experience with similar projects.

Thanks for the quick reply!

I’ll answer each bullet above here:

  1. I’ve done that. Copy pasted it into a text editor just for sanity’s sake and it is in the expected format: https://discord.com/api/webhooks/{id}/{token} with no trailing anything else.
  2. Also tried that, as the paste of the node above shows, I’ve removed all content and replaced it with the text test, same result.
  3. That’s part of the problem, I can’t see any result codes being sent back from within N8N, I just get the stacktrace I pasted in the original message. Tailing the output from the pod, I get only Cannot read properties of undefined (reading 'error') in the pod’s output. I have to get the actual stacktrace from the N8N gui.

It is a top-level channel that is marked as Private (It has the hashmark with a tiny padlock on it) and the channel SAYS that the bot has send message permissions enabled on it, but I’ll try regenerating a new webhook and re-setting permissions.