- Solan Sync
- Posts
- Building an AI-Powered Financial News Analysis Workflow with n8n
Building an AI-Powered Financial News Analysis Workflow with n8n
In today's fast-paced financial markets, making informed investment decisions requires sifting through vast amounts of daily news to identify truly valuable information. This comprehensive guide will walk you through creating an automated workflow using n8n, a no-code automation platform, that collects financial news from RSS feeds, analyzes them with AI to evaluate investment opportunities, and sends notifications to Telegram.
What is n8n?
n8n is a workflow automation tool that allows you to connect any app with an API to any other app and manipulate data with minimal coding required. You can build workflows with the precision of code or the speed of drag-and-drop operations.
Key Features:
Highly customizable workflows with option to build custom nodes
Flexible deployment: on-premises or cloud hosting
Privacy-focused design with self-hosting capabilities
Extensive library of pre-built nodes
Prerequisites
Before implementing this workflow, prepare the following accounts and API keys:
n8n Account - For workflow creation
ScrapegraphAI API Key - For web scraping (free plan includes 50 credits/month)
OpenAI API Key - For ChatGPT 4.1 usage
Telegram Bot - For sending notifications
Workflow Overview
Our automated workflow consists of 6 main steps:
RSS Feed → Content Search → Data Extraction → AI Analysis → Conditional Filter → Telegram Notification
Step 1: RSS Feed Trigger Setup
Basic Configuration
First, we'll set up the RSS feed as our financial news source.
Create a new workflow in n8n
Add the "RSS Feed Trigger" node
Configure the following settings:
Feed URL:
https://feeds.content.dowjones.io/public/rss/mw_topstories
Poll Time: 1 minute (adjustable based on your needs)
Testing the Setup
Click the "Fetch Event Test" button to verify that data is being correctly retrieved from the RSS feed. If working properly, you should see the latest news item displayed on screen.
Step 2: ScrapegraphAI Search Configuration
Node Addition and Setup
Add the "ScrapegraphAI: search and extract content with AI" node as your second step.
API Key Setup: Register your ScrapegraphAI API key in n8n's credentials
Search Target: Specify the
content
field from the previous nodeThis node generates a list of reference URLs related to the news content
Important Considerations
Premium content sites like MarketWatch often restrict RSS item URLs to subscribers only. This step helps find related publicly accessible URLs for content extraction.
Step 3: ScrapegraphAI Data Extraction
Node Configuration
Add the "ScrapegraphAI: extract and scrape website data with AI" node.
Use the first reference URL obtained from the previous node
Set the prompt:
"Summarize the content of the article"
This node scrapes and summarizes the webpage content
Customizing Prompts
You can adjust prompts based on your specific needs:
"Extract the top 3 key points from this article"
"Analyze this article's potential impact on stock markets"
Step 4: AI Agent Node Configuration
This is the most crucial component where we evaluate the investment value of news.
Basic Setup
Add the "AI Agent" node
User Prompt: Use the summary generated by the previous node
Chat Model: Select ChatGPT 4.1 (requires OpenAI API key)
System Prompt Configuration
Copy and paste the following system prompt:
You are an expert financial analyst tasked with evaluating whether a series of news items represents a genuine opportunity to trade on the stock market and achieve capital gains.
An "opportunity" is defined as any event that could significantly impact the value of a stock, ETF, or index.
#Instructions
Carefully analyze the news, using the provided information and your own financial and macroeconomic knowledge.
Assess the potential impact of the news on asset prices, taking into account market trends and similar past events.
Assign a score to the identified opportunity.
List all involved assets (stocks or ETFs) and indicate their tickers.
Explain the reasoning behind your score.
Highlight any risks or uncertainties related to the trade.
Specify whether to buy or sell the assets.
#Output Format
The score must be between 0 and 5, where 0 indicates insufficient information, 1 indicates a very low opportunity, and 5 indicates a maximum opportunity.
List of tickers for the involved assets (e.g., [AAPL, MSFT])
Structured Output Configuration
Click the "Output Parser" button and configure the following JSON schema:
json
{
"title": "NewsScore",
"type": "object",
"properties": {
"score": {
"title": "Score",
"description": "The score of the opportunity where 1 is the lowest value and 5 is the highest",
"type": "integer"
},
"assets": {
"title": "Assets",
"description": "The list of stocks or ETF involved",
"type": "array",
"items": {
"type": "string"
}
},
"description": {
"title": "Description",
"description": "A brief description of the opportunity and how I can make a profit from it and the motivation of the score",
"type": "string"
}
},
"required": [
"score",
"assets",
"description"
]
}
Step 5: Conditional Logic Setup
Adding the If Node
Set up conditional filtering to only notify about high-scoring news.
Add the "If" node
Condition: Set
score > 3
This ensures only news with scores of 4 or higher proceed to notification
Adjusting Thresholds
Modify conditions as needed:
More restrictive:
score >= 4
More permissive:
score >= 2
Step 6: Telegram Notification Setup
Prerequisites
Create Telegram Bot:
Search for @BotFather in Telegram
Use
/newbot
command to create a botObtain the access token
Channel Preparation:
Create a Telegram channel (public or private)
Add the bot to the channel
Obtain the channel's chat ID
Node Configuration
Add the "Telegram: send a text message" node
Set up credentials with your bot's access token
Enter the chat ID
Configure the message template:
html
📰 <b>News Alert</b>
<b>Title:</b> {{ $('RSS Feed Trigger').item.json.title }}
<b>Link:</b> <a href='{{ $('RSS Feed Trigger').item.json.link }}'>{{ $('RSS Feed Trigger').item.json.link }}</a>
<b>Score:</b>{{ $json.output.score }}/5
<b>Assets:</b> {{ $json.output.assets }}
<b>Description:</b> {{ $json.output.description }}
Testing Your Workflow
Manual Testing
Execute each node sequentially to verify functionality
Review and adjust configurations if errors occur
Confirm that Telegram notifications are received successfully
Activating Automation
Once all tests pass, set your workflow to "Active" to begin automatic execution.
Customization Ideas
This workflow represents a foundational version. Consider these enhancements:
Expanding Information Sources
Add multiple RSS feeds
Integrate direct news site APIs
Include social media data streams
Advanced Analysis Features
Cross-reference with historical stock data
Add sentiment analysis capabilities
Compare multiple AI model outputs
Enhanced Notifications
Add email notifications
Integrate with Slack
Set up different notification channels based on conditions
Data Management
Store analysis results in databases
Implement performance tracking
Generate historical analysis reports
The file is here
Conclusion
This automated workflow transforms financial news monitoring from a manual, time-intensive task into an intelligent, automated process. The flexibility of n8n allows for easy customization to meet specific investment strategies and preferences.
Start with this foundational workflow and gradually add features as your needs evolve. By leveraging AI for financial information analysis, you can make more efficient and objective investment decisions.
Disclaimer: This system should be used for reference purposes only. Always conduct your own due diligence and make investment decisions at your own discretion and risk.
Reply