n8n Reddit Integration Error with Comment Posting Loop

Issue with n8n Reddit Comment Automation

I have a workflow in n8n that pulls data from Google Sheets and automatically posts comments on Reddit posts. The workflow processes each row from my spreadsheet and should comment on the corresponding Reddit post.

What Should Happen

The automation should go through each row in my sheet, post the comment to the Reddit post ID, pause for some time, then move to the next row.

The Problem

The first comment gets posted successfully to Reddit, but then n8n throws this error:

TypeError: Cannot read properties of undefined (reading 'things')

Even though the comment actually appears on Reddit, the node fails and stops the whole loop from continuing.

What I Already Tried

Setting Continue on Error: This lets the loop finish but seems like a hack rather than fixing the real issue.

Checking Post IDs: I’m using the right fullname format for post IDs.

API Permissions: My Reddit app has all the right scopes and I can post manually.

My Workflow Setup

Here’s how my nodes are configured:

Batch Processing Node:

{
  "parameters": {
    "batchSize": 1,
    "options": {
      "reset": false
    }
  },
  "name": "Process Items",
  "type": "n8n-nodes-base.splitInBatches"
}

Reddit Comment Node:

{
  "parameters": {
    "resource": "postComment",
    "postId": "={{ $('Process Items').item.json.PostID }}",
    "commentText": "={{ $('Process Items').item.json.CommentText }}"
  },
  "name": "Post Reddit Comment",
  "type": "n8n-nodes-base.reddit"
}

Delay Node:

{
  "parameters": {
    "amount": 45,
    "unit": "seconds"
  },
  "name": "Pause",
  "type": "n8n-nodes-base.wait"
}

Questions

  1. Why does the Reddit node work but then fail to handle the response properly?
  2. How can I fix this workflow to run reliably for all items?
  3. Should I add different nodes to handle this better?

Any help would be awesome!

yeah, that error means the response isn’t what ur expecting. add an IF node to check the response b4 continuing. also, try switching to webhooks - they’re usually more reliable with reddit than whatever ur using now.

The Problem:

You’re experiencing issues with your n8n workflow that posts comments to Reddit. The first comment posts successfully, but subsequent comments fail with a TypeError: Cannot read properties of undefined (reading 'things') error, even though the comments appear on Reddit. The workflow stops after the first iteration. Using “Continue on Error” allows the loop to complete, but this is a workaround rather than a fix.

:thinking: Understanding the “Why” (The Root Cause):

The TypeError: Cannot read properties of undefined (reading 'things') error indicates that your n8n workflow is attempting to access a property named things within the Reddit API’s response, but this property is missing or undefined. This is happening because the Reddit API sometimes returns inconsistent response structures, especially when dealing with rate limits or temporary server-side issues. Even if your comment posts successfully, the API might not always return the expected JSON structure, causing the parsing error in your n8n workflow. The standard n8n Reddit node doesn’t robustly handle these inconsistencies.

:gear: Step-by-Step Guide:

  1. Implement Robust Response Handling: The core solution is to add a custom response handler to your n8n workflow. This will allow your workflow to gracefully handle cases where the things property is missing from the Reddit API response. To do this, add a Function node immediately after your “Post Reddit Comment” node. Use the following JavaScript code within the Function node:
if (item.json && item.json.hasOwnProperty('things')) {
    //If the 'things' property exists, proceed as normal
    return items;
} else {
    //If the 'things' property does not exist, log a message (optional) and continue.
    console.log('Reddit response missing "things" property. Comment likely posted successfully');
    return [{json: {success: true, message: 'Comment posted'}}]; // or modify to suit your workflow needs. 
}

This code checks if the things property exists in the Reddit API response. If it does, the workflow continues normally. If not, it logs a message indicating a possible successful post despite the missing property and continues the loop.

  1. Adjust Delay (Optional): The 45-second delay might be excessive and could contribute to connection issues. Consider reducing this to a shorter interval, such as 10-15 seconds. Experiment to find the optimal delay that balances speed and avoids hitting Reddit’s rate limits. Modify the “Pause” node accordingly.

  2. Verify Reddit App Credentials: As a further precaution, double-check your Reddit app’s credentials to ensure they haven’t expired. Expired tokens can lead to intermittent errors like the one you’re encountering.

:mag: Common Pitfalls & What to Check Next:

  • Rate Limiting: If the problem persists after implementing the custom response handler and adjusting the delay, you might be exceeding Reddit’s API rate limits. Monitor your requests closely.
  • Error Logging: For more comprehensive debugging, add more detailed logging throughout your workflow to pinpoint the exact point of failure in various scenarios.
  • Alternative API Interaction: If the inconsistencies are frequent, consider switching to a different method of interacting with the Reddit API. Direct HTTP requests may provide more control and flexibility in handling varied responses.

:speech_balloon: Still running into issues? Share your (sanitized) config files, the exact command you ran, and any other relevant details. The community is here to help!

Had this exact problem a few months ago building something similar. Reddit’s API sometimes returns malformed responses even when the comment actually posts fine. The ‘things’ property is part of Reddit’s response structure - when it’s missing, n8n crashes on it. Here’s what fixed it for me: add a Set node right after the Reddit comment node to clean up the response before the next iteration. Just configure it to set something simple like {“status”: “posted”, “timestamp”: “{{$now}}”}. That way you’re not depending on Reddit’s messy response format. Also, your 45-second delay is probably too much. Reddit’s rate limits aren’t that strict - I’ve been running similar workflows with 10-second delays no problem. Those long delays can actually cause connection timeouts and make the parsing issues worse. One more thing - check if your Reddit app credentials expired. Sometimes these partial failures mean token refresh problems, not actual API issues.

Classic response object parsing issue. Reddit’s API sometimes returns different structures depending on server load or when comments hit spam filters temporarily. When the ‘things’ property goes missing, n8n’s Reddit node can’t parse it.

Don’t switch platforms yet - just add a Function node right after your Reddit comment node. Set it up to catch and standardize the response before the next iteration:

if (!items[0].json.things) {
  return [{json: {success: true, message: 'Comment posted'}}];
}
return items;

This keeps your existing workflow while handling Reddit’s inconsistent responses. I’ve done similar fixes with other API nodes that have flaky response formats. You just intercept the problematic response before n8n tries processing undefined properties.

Also check your Reddit app’s rate limiting settings. These parsing errors sometimes happen when you’re hitting soft limits, even if the requests technically work.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.