Author: Cheng-Liang Lu (James)
This project's purpose is to establish an automated news aggregation system to provide users with a focused overview of recent travel news. The system, built using the workflow automation tool n8n, leverages the OpenAI GPT model to intelligently analyze incoming articles from various news sources.
Upon processing, each article is automatically assigned a category tag. The system then filters out content that has a low relevance score to the specified category or other unrelated themes, ensuring the user receives a highly curated and valuable news summary. The final curated news digest is then delivered directly to the user via the Slack API, creating a seamless and efficient notification experience. This end-to-end automation, from aggregation and analysis to delivery, eliminates the manual effort of searching and sifting through irrelevant content, thereby saving time and providing a speedy, high-quality information feed.
It triggers our automatic system. When a person mention the agent in the slack specific channel. This node received the event from the slack and get the information from the slack.
// Define a map of resource names to their URLs.
// This is simpler since we only need the URL.
const resourceMap = {
"cnn": "<http://rss.cnn.com/rss/cnn_travel.rss.xml>",
"bbc": "<https://www.bbc.com/travel/feed.rss>",
"tac": "<https://www.travelagentcentral.com/rss/xml>",
// Add more resources here if needed.
};
// Get the user's message text from the Slack Trigger output.
const messageText = $input.first().json.blocks[0].elements[0].elements[1].text;
const requestedResourceName = messageText.trim().toLowerCase();
// Look up the URL from our map
const urlToFetch = resourceMap[requestedResourceName] || null; // We set null if the key is not found in the map
// Also get a list of all available resources for the error message.
const availableResources = Object.keys(resourceMap).join(', ');
// Return a single item with the URL (or null) and other helpful info.
return [{ json: {
url: urlToFetch,
requestedResource: requestedResourceName,
availableResources: availableResources
} }];
Here we can see, we have a map for three resources, CNN, BBC, and Travel Agent Central. Each of their keys match with the value which is their RSS feed. The variable fetch the url that another variable “requestedResourceName”, the key, match to.
“availableResources” is another variable that we will show on the slack if the error happens. It will be seen later.
It will see if the “url” in jason includes something not null. If a real url in the url property, it will trigger the next node to parse the RSS feed information through the url. However, if it is a null value, then, it will launch an event to send a message in Slack.