AutomationFlowsGeneral › Add Comment to Discussion via Webhook

Add Comment to Discussion via Webhook

Original n8n title: Add Discussion Comment

Add Discussion Comment. Uses respondToWebhook. Webhook trigger; 4 nodes.

Webhook trigger★★★★☆ complexity4 nodes
General Trigger: Webhook Nodes: 4 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "BMqI4wb9boKML4Ix",
  "name": "Add Discussion Comment",
  "description": null,
  "active": true,
  "isArchived": false,
  "nodes": [
    {
      "parameters": {
        "path": "add-discussion-comment",
        "httpMethod": "POST",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook-1",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const fs = require('fs');\nconst path = '/home/paul/Projects/wf-monorepo/.agentTask/discussion.md';\n\n// Read current discussion file\nlet currentContent = '';\ntry {\n  currentContent = fs.readFileSync(path, 'utf8');\n} catch (error) {\n  throw new Error('No active discussion found. Create a discussion first.');\n}\n\n// Check if discussion is already resolved\nif (currentContent.includes('[x]') || currentContent.includes('[X]')) {\n  throw new Error('Discussion is already resolved. Create a new discussion instead.');\n}\n\nconst body = $input.item.json.body || $input.item.json;\nconst { comment, agent = 'unknown' } = body;\n\nif (!comment) {\n  throw new Error('comment is required');\n}\n\nconst timestamp = new Date().toISOString();\n\nreturn {\n  json: {\n    currentContent,\n    comment,\n    agent,\n    timestamp\n  }\n};"
      },
      "id": "validate-comment",
      "name": "Validate Comment",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const fs = require('fs');\nconst data = $input.item.json;\n\nconst newComment = `\\n**${data.agent}** - ${data.timestamp}\\n> ${data.comment}\\n`;\n\n// Find the Resolution section and insert before it\nconst resolutionIndex = data.currentContent.indexOf('## Resolution');\n\nlet updatedContent;\nif (resolutionIndex !== -1) {\n  updatedContent = \n    data.currentContent.substring(0, resolutionIndex) +\n    newComment +\n    '\\n---\\n\\n' +\n    data.currentContent.substring(resolutionIndex);\n} else {\n  // If no Resolution section found, append to end\n  updatedContent = data.currentContent + '\\n---\\n' + newComment;\n}\n\nconst discussionPath = '/home/paul/Projects/wf-monorepo/.agentTask/discussion.md';\n\ntry {\n  fs.writeFileSync(discussionPath, updatedContent, 'utf8');\n  return {\n    json: {\n      success: true,\n      message: 'Comment added to discussion',\n      agent: data.agent,\n      timestamp: data.timestamp\n    }\n  };\n} catch (error) {\n  throw new Error(`Failed to update discussion file: ${error.message}`);\n}"
      },
      "id": "append-comment",
      "name": "Append Comment",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "allIncomingItems",
        "options": {}
      },
      "id": "webhook-response",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        900,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Validate Comment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Comment": {
      "main": [
        [
          {
            "node": "Append Comment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append Comment": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": true
  },
  "staticData": null,
  "versionId": "b13ea6c0-a892-472e-9a4f-be1f09523eaa",
  "createdAt": "2025-12-21 02:31:52.700",
  "updatedAt": "2025-12-26 13:28:07.619"
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Add Discussion Comment. Uses respondToWebhook. Webhook trigger; 4 nodes.

Source: https://github.com/pchambless/wf-monorepo/blob/47cd16469735c59a12b7c76e2552861f899e335d/.n8n/workflows/add-discussion-comment.json — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

A production-ready authentication workflow implementing secure user registration, login, token verification, and refresh token mechanisms. Perfect for adding authentication to any application without

Crypto, Data Table, Execute Workflow Trigger
General

Portfolio Orchestrator. Uses httpRequest. Webhook trigger; 59 nodes.

HTTP Request
General

This n8n template demonstrates how a simple Multi-Layer Perceptron (MLP) neural network can predict housing prices. The prediction is based on four key features, processed through a three-layer model.

General

github code Try yourself

Google Calendar
General

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

N8N Nodes 1Shot