#
n8n, a popular open-source project on GitHub in recent years, has become a powerful tool for many developers to implement workflow automation. With its node-based workflow design and high extensibility, it offers an open-source alternative to commercial products like Zapier. This guide will demonstrate, through a practical example, how to use n8n to build an automated content delivery system integrated with a Large Language Model (LLM) for intelligent information filtering and distribution.
1. System Architecture and Preparation
Before starting the project, it’s essential to define the core components of the workflow and prepare the necessary environment. This automation process aims to simulate the work of a human editor: periodically checking information sources, evaluating and summarizing content, and then pushing high-quality information to designated channels.
1. Core Tech Stack
- n8n Environment: The core workflow engine. You can either use the hosted service on n8n Cloud or self-host it on a local server via Docker. The latter provides greater control over data privacy and customization.
- Content Source (RSS): Real Simple Syndication (RSS) is a standardized format for content distribution, making it an ideal choice for fetching updates from blogs, news sites, and more. This example will use a public tech blog’s RSS feed.
- Large Language Model (LLM) API: The key module for content processing. By calling APIs from models like OpenAI or Alibaba Cloud’s Tongyi Qianwen, you can automate article summarization, quality scoring, and keyword extraction. A valid API Key is required.
- Delivery Platform (Webhook): The final output of the system. This example uses Lark, receiving formatted messages via its custom bot Webhook URL. This method is also applicable to other platforms that support webhooks, such as WeCom, Slack, and Telegram.
2. Environment Setup
- Get an n8n instance: Visit the official n8n website or set up a Docker container according to their documentation.
- Configure a Lark Bot: In the target Lark group, navigate to “Group Settings” -> “Bots” and add a “Custom Bot”. Record the generated Webhook URL. This URL is the endpoint where n8n will send messages to Lark.
2. Steps to Build the Automation Workflow
The entire workflow is constructed on the n8n canvas as a series of interconnected nodes, with data flowing and being processed sequentially through them.
1. Step 1: Scheduled Trigger and Content Fetching
- Schedule Trigger Node: This is the starting point of the workflow. Configure this node to set the execution schedule, for example, “every weekday at 9 AM”.
- RSS Read Node: Following the trigger, this node is responsible for accessing the specified content source URL (e.g.,
https://www.smashingmagazine.com/feed/) and outputting a list of the latest articles as data items.
- Limit Node: To facilitate debugging and control API costs, it’s advisable to add a Limit node. By setting a small number (e.g., 10), you can limit the number of articles processed in each run.
2. Step 2: Integrating an LLM for Intelligent Analysis
This step is the “brain” of the workflow. It uses an HTTP Request node to call an external LLM API for in-depth processing of each article. This is the key to achieving “intelligent” filtering and is also the main challenge in the configuration process.
- HTTP Request Node (Calling the LLM):
- Request Method:
POST
- URL: Enter the API endpoint address of your chosen Large Language Model.
- Authentication & Headers: In the HTTP Headers, configure the
Authorization field with the value Bearer YOUR_API_KEY, and set Content-Type to application/json.
- Request Body: This is the core of the interaction with the model. You need to construct a JSON request body that includes a carefully designed Prompt. This prompt instructs the model to analyze the input article content and return the results in a predefined format. For example, you can ask the model to rate the article on dimensions like “informational value” and “technical depth” (on a scale of 1-10), generate a brief summary, and finally, return the score, title, link, and summary as a single JSON object.
An example of an effective prompt structure is as follows:
Please analyze and score the following article content.
Scoring Dimensions:
- Informational Value (1-10)
- Technical Depth (1-10)
- Recommendation Score (1-10)
Please respond strictly in the following JSON format, without any additional explanations:
{
“score”: <overall_score>,
“title”: “<article_title>”,
“link”: “<article_link>”,
“summary”: “<one_sentence_summary>”
}
The article content is as follows:
Title: {{$json.title}}
Description: {{$json.content}}
Link: {{$json.link}}
Content Snippet: {{$json[“content:encoded”].slice(0, 1000)}}
3. Step 3: Data Cleaning and Formatting
Although the data returned by the LLM is structured, it is often encapsulated within a string and may sometimes include Markdown code markers (like ). Therefore, an intermediate step is needed to clean and parse this data.
- Code Node: Using JavaScript, this node processes the output from the previous step.
- Functionality: It extracts the core content from the API response, removes unnecessary characters (like code block markers), and then uses
JSON.parse() to convert the string into a standard JavaScript object.
- Error Handling: It’s recommended to use a
try...catch block in your code to prevent the entire workflow from failing due to unexpected format errors from the model. If parsing fails, you can assign default values to ensure the robustness of the process.
4. Step 4: Pushing Content to the Target Platform
The final step is to send the processed, structured data to the Lark group.
- HTTP Request Node (Pushing to Lark):
- Request Method:
POST
- URL: Enter the Lark bot Webhook URL obtained in the first step.
- Request Body: Following the Lark bot documentation, construct the JSON for a message card or a plain text message. By referencing variables from the output of the preceding Code node (e.g.,
{{$json.title}}, {{$json.score}}), you can populate the message template with dynamic content to create the final notification.
A simple Lark text message example is as follows:
{
“msg_type”: “text”,
“content”: {
“text”: "Today’s Article Recommendation
Title: {{$json.title}}
Score: {{$json.score}}
Summary: {{$json.summary}}
Read Original: {{$json.link}}"
}
}
3. Application Value and Expansion Possibilities
With the workflow described above, a basic automated content processing pipeline is complete. Its value lies in automating the repetitive task of information filtering, incorporating artificial intelligence for preliminary quality assessment, which significantly improves information processing efficiency.
Based on this framework, several functional extensions are possible:
- Multi-Source Aggregation: Add multiple RSS Read nodes to consolidate and process information from different sources within the same workflow.
- Advanced Filtering and Sorting: Before pushing to Lark, add an
IF or Switch node to filter articles based on the LLM’s score, pushing only those that exceed a certain threshold.
- Richer Message Formats: Utilize Lark’s “Message Card” feature to design more visually appealing and informative push formats that include buttons, multi-column layouts, and images.
- Multi-Platform Distribution: By duplicating and modifying the final push node, you can easily distribute content simultaneously to multiple collaboration platforms like WeCom and Slack.
In conclusion, the combination of n8n and Large Language Models opens up new possibilities for low-code/no-code automation. It can not only handle simple tasks but also, by incorporating the analytical power of AI, build complex workflows that can assist in decision-making and possess a degree of ‘intelligence’, thereby freeing up individuals and teams from tedious routine tasks.