Automate Hacker News Insights with n8n AI Agent Workflow

This n8n workflow automates retrieving and analyzing the top Hacker News posts using an AI agent to answer your queries quickly. It saves time and manual effort by fetching data, cleaning it, and generating insights on demand.
chatTrigger
agent
toolWorkflow
+6
Workflow Identifier: 1482
NODES in Use: chatTrigger, agent, toolWorkflow, hackerNews, set, code, lmChatOpenAi, executeWorkflowTrigger, stickyNote

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

Opening Problem Statement

Meet Sarah, a data analyst who regularly tracks trends and insights from tech communities like Hacker News to inform her startup’s content strategy. Every week, she spends hours manually scraping Hacker News for top posts, cleaning the data, and compiling reports. This tedious process often leads to delays, incomplete data, and missed insights, costing her valuable time and potential growth opportunities. The manual steps are error-prone and drain her focus from higher-value tasks like strategic analysis.

Imagine if Sarah could instantly ask, “What is the 5th most popular post ever on Hacker News?” and get an immediate, accurate response without sifting through pages of data. This specific challenge of extracting, cleaning, and analyzing Hacker News data on demand requires an intelligent, automated approach.

What This Automation Does

This n8n workflow leverages an AI agent combined with custom data-fetching and cleaning steps to provide quick answers about Hacker News trends. When you send a chat message with a query related to Hacker News posts, the workflow:

  • Receives your natural language chat input via the LangChain chat trigger node.
  • Uses a custom tool node that invokes a sub-workflow fetching the top 50 Hacker News posts with the Hacker News node.
  • Cleans and restructures fetched data (title, points, URL, author, creation date) for consistent output readable by the AI model.
  • Converts the cleaned data into a JSON string using a code node for easy consumption.
  • Processes the query and data in the AI Agent node using OpenAI’s GPT-4o-mini model.
  • Delivers a concise, informed response based on real-time data from Hacker News, right in your chat interface.

This workflow removes hours of manual data handling, reduces errors, and enables real-time insights for smarter decision-making.

Prerequisites ⚙️

  • n8n account (cloud or self-hosted) 🔑
  • OpenAI API account with access to GPT-4o-mini model 🔐
  • n8n LangChain nodes enabled (for chat triggers, AI agent, and tool workflow)
  • Hacker News node configured (built-in in n8n) 📊

Step-by-Step Guide

Step 1: Set Up the Chat Trigger Node

Navigate to your workflow editor, drag the When chat message received node (type: @n8n/n8n-nodes-langchain.chatTrigger), and position it as the entry point. This node listens for incoming chat requests from the user.

In parameters, leave options default unless you want to customize message filtering.

You should see the webhook ID generated ready for integration with your chat interface.

A common mistake: forgetting to set or test your webhook externally, resulting in no messages reaching n8n.

Step 2: Add the AI Agent Node

Connect the output of the chat trigger to the AI Agent node (@n8n/n8n-nodes-langchain.agent). This node orchestrates the conversation by handling AI model interactions and tool invocations.

Configure the AI Agent node with default settings to enable calling the custom tool.

Expected outcome: the agent is ready to process chat queries through the next nodes.

Step 3: Configure the Custom Tool Workflow Node

Insert the Custom tool to call the wf below1 node (@n8n/n8n-nodes-langchain.toolWorkflow). This node calls a separate sub-workflow named “hn_tool” which fetches Hacker News data.

Important: Ensure the workflow ID is correctly set to your current workflow; this enables modularization and clean design.

Result: The AI agent can invoke this tool to retrieve fresh Hacker News posts as JSON data.

Step 4: Inside the Sub-workflow (hn_tool), Fetch Hacker News Posts

In the sub-workflow, add the Hacker News node (type: n8n-nodes-base.hackerNews) configured as follows:

  • Resource: all
  • Limit: 50

This node queries the Hacker News API for the top 50 most popular posts.

Expected: The node returns post data with fields like title, points, url, author, and created_at.

Step 5: Clean Up the Data

Attach the Clean up data node (type: n8n-nodes-base.set) to organize and fix the data structure. Map fields to key properties:

  • title => json._highlightResult.title.value
  • points => json.points
  • url => json.url
  • created_at => json.created_at
  • author => json.author

This simplifies the JSON response the AI agent will process.

Common mistakes: referencing incorrect JSON paths, which leads to missing or wrong data.

Step 6: Serialize Data to JSON String

Use the Stringify code node (type: n8n-nodes-base.code) with the following JavaScript code:

return {
  'response': JSON.stringify($input.all().map(x => x.json))
}

This converts the cleaned array of posts into a JSON string for the AI to parse within the conversation.

Expected Result: A single JSON string under the key “response”.

Step 7: Link the OpenAI Chat Model

Place the OpenAI Chat Model node (@n8n/n8n-nodes-langchain.lmChatOpenAi) between your custom tool call and AI agent to handle GPT-4o-mini responses. Configure the model parameter to “gpt-4o-mini” and provide your OpenAI credentials.

This node powers the NLP understanding and response generation.

Step 8: Activate and Test Your Workflow

After making connections consistent with the workflow’s edges, save and activate your workflow.

Test by sending chat queries, e.g., “What is the 5th most popular post ever on Hacker News?”

You should receive a ChatGPT-like detailed answer with current data fetched live from Hacker News.

Customizations ✏️

  • Change Post Limit: In the Hacker News node, modify the “limit” parameter to fetch more or fewer posts per request, adapting to your analysis needs.
  • Adjust Cleaned Data Fields: Update the “Clean up data” node to add or remove fields like “comments” or “story_text” based on what Hacker News API returns.
  • Swap AI Model: In the OpenAI Chat Model node, switch from “gpt-4o-mini” to another compatible GPT model like “gpt-4” for richer responses if you have access.
  • Extend Custom Tool: Modify the sub-workflow “hn_tool” to include additional processing or filters, e.g., only posts from specific time frames.
  • Implement Error Handling: Add error catch nodes after the Hacker News or API call nodes to manage downtime or rate limits gracefully.

Troubleshooting 🔧

Problem: No response from chat trigger node.
Cause: Webhook URL not set up or not triggered.
Solution: Go to the “When chat message received” node → Copy webhook URL → Test it using a REST client or chat integration to confirm it triggers the workflow.

Problem: Incorrect or empty data fields after Hacker News fetch.
Cause: Wrong JSON path references in “Clean up data” node.
Solution: Open the “Clean up data” node and verify JSON path expressions against actual output from Hacker News node by running it standalone.

Problem: AI agent returns generic or irrelevant answers.
Cause: The model or prompt configuration in the OpenAI Chat Model node might be missing required context.
Solution: Check the input to the AI agent to ensure it includes the JSON stringified data and confirm the correct model is selected in the OpenAI Chat Model node.

Pre-Production Checklist ✅

  • Verify OpenAI API key is valid and has proper access rights.
  • Test the Hacker News node independently to confirm data retrieval.
  • Run the sub-workflow “hn_tool” alone to confirm it outputs expected JSON.
  • Confirm the chat trigger webhook is reachable from your chat client.
  • Test the AI Agent responds correctly to example queries.
  • Backup your workflow and credentials before deployment.

Deployment Guide

Activate the workflow in your n8n environment by toggling the active switch.

Integrate the chat webhook URL with your frontend or chat platform to route user queries to n8n.

Monitor execution logs in n8n to ensure smooth processing and catch any runtime errors.

Schedule regular tests to maintain workflow health and updates for API changes.

FAQs

Q: Can I use another AI model besides GPT-4o-mini?
A: Yes, the workflow supports switching to other OpenAI models like GPT-4 or GPT-3.5, provided you update the model name in the OpenAI Chat Model node.

Q: Does this workflow consume OpenAI API credits?
A: Yes, each chat interaction calls the OpenAI API and uses credits as per your OpenAI plan.

Q: Is user data secure when using external APIs?
A: This workflow uses authenticated APIs and secure credential storage in n8n, but always follow best practices for data privacy in your environment.

Q: Can this handle high volumes of queries?
A: It’s designed for moderate use; for scaling, consider load balancing and API rate limits.

Conclusion

By following this guide, you’ve built a powerful n8n AI automation that fetches and analyzes Hacker News’ top posts to answer your queries instantly. This automation saves you countless manual hours spent on data scraping and analysis, opens up new insights on demand, and keeps your content strategies fresh and informed.

Next, explore expanding this framework to other news sources, integrating Slack notifications for real-time alerts, or building dashboards with Google Sheets to visualize Hacker News trends.

Let this workflow empower your data-driven decisions and give you back precious time for what matters most.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n (Beginner Guide)

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free