What This Automation Does
This workflow automatically gets the top 50 posts ever on Hacker News.
It cleans the data and answers your chat questions about these posts using AI.
You get quick and clear info about popular Hacker News stories without looking them up yourself.
Who Should Use This Workflow
This is for data analysts, content creators, or anyone who wants fast access to Hacker News trends.
It fits people who want to save time and avoid mistakes from manual data fetching.
Tools and Services Used
- n8n Platform: For building and running the workflow.
- OpenAI API: Powers the AI chat model that understands and replies.
- Hacker News API Node: Fetches top 50 posts in JSON format.
- JavaScript Code Node: Converts data to JSON string output.
- Manual Chat Message Node: Allows you to type questions to start the workflow.
Inputs, Processing Steps, and Outputs
Inputs
- User types a question in the Manual Chat Message node.
- Workflow receives the trigger to start the process.
Processing Steps
- AI Agent gets the question and plans actions.
- Custom tool workflow fetches top 50 Hacker News posts using the Hacker News node.
- Set node cleans and picks main fields from post data.
- Code node converts this cleaned data into JSON string.
- AI Agent reads this data and replies to the user question.
Outputs
- Clear, formatted answers to Hacker News queries in chat.
- JSON string with top post details for other uses.
Beginner Step-by-Step: How to Use This Workflow in n8n
1. Import the Workflow
- Download the workflow file using the Download button on this page.
- Inside the n8n editor, click “Import from File” and load the downloaded workflow.
2. Configure Credentials and Settings
- Add your OpenAI API Key in the OpenAI Chat Model node credentials.
- Check the Hacker News node if any limit or filters need changes.
- Update any workflow IDs or references if required, especially in the custom tool node.
3. Test the Workflow
- Trigger the manual chat message by typing a question like “What is the 5th most popular post ever on Hacker News?”
- Review the AI agent’s reply for correctness.
4. Activate for Production
- Switch the workflow toggle to ON in n8n.
- Monitor runs to ensure smooth operation.
If hosting n8n yourself, visit self-host n8n to explore hosting options.
Customizations
- Change how many posts are fetched by adjusting the limit in the Hacker News node.
- Add more data fields in the cleanup Set node for richer info.
- Adjust max interaction rounds in the AI Agent node.
- Add other news sources by modifying the sub-workflow.
- Customize chat prompts for team style or language preferences.
Troubleshooting
AI Agent does not respond
Check if the OpenAI Chat Model has correct API key and is connected to the AI Agent.
Hacker News node returns no data
Test network connection and check for API limits.
JSON formatting error in Code node
Confirm upstream nodes provide an array input matching the code’s expectation.
Pre-Production Checklist
- Validate OpenAI API key is active.
- Confirm manual chat triggers proper AI Agent reply.
- Test sub-workflow returns Hacker News data correctly.
- Review cleaned data fields output.
- Run a test query “What is the 5th most popular post ever on Hacker News?”
- Backup the workflow before going live.
Conclusion
This workflow saves time by automating Hacker News data collection and answering questions fast.
It helps stay updated on top tech news without manual work or errors.
Consider adding alerts or other platforms later to grow automation.
Sample Code for JSON Stringify in the Code Node
This code turns all posts data into a JSON string for output.
return {
'response': JSON.stringify($input.all().map(x => x.json))
}Example User Question to Start Chat
Use this example question in the Manual Chat Message node to test:
What is the 5th most popular post ever on Hacker News?Summary of Results
→ Fast answers to Hacker News top posts questions.
✓ Clean, easy-to-read post data in JSON for use.
✓ Saves hours of manual data work.
✓ Quick setup and testing inside n8n.
✓ Flexible to customize for many needs.
