Alpha Vantage, Google Gemini AI and Slack Integration
This n8n workflow provides an end-to-end solution for automated financial analysis. By combining real-time market data with generative AI, it transforms raw stock numbers into actionable narrative insights delivered directly to your team's communication hub.
Stay ahead of the market without manual research. This workflow fetches the day's top-performing and underperforming stocks, identifies the "winner" of the day, pulls the latest news headlines for that specific company and uses Google Gemini AI to write a professional summary of why the market moved the way it did.
This automation acts as a digital financial analyst that works 24/7. It begins by querying the Alpha Vantage API to retrieve a list of the "Top Gainers and Losers." Instead of just passing raw data, it uses a custom logic gate to calculate the overall market sentiment—determining if the day was "Bullish" (positive) or "Bearish" (negative) based on the average percentage moves.
Once the top-performing stock is identified, the workflow performs "Deep Research." It isolates that stock's ticker symbol and searches for the most recent news headlines related to it. This ensures that the final report isn't just about numbers, but about the real-world events (like earnings calls or product launches) driving those numbers.
Finally, all this gathered context is fed into Google Gemini. The AI processes the market sentiment, the stock performance and the news headlines to draft a concise, 3-4 line professional report. This report is then automatically formatted and posted to a Slack channel, keeping you and your team informed without ever leaving your chat app.
The workflow is divided into three logical groups to ensure data integrity and ease of use.
apikey value with your Alpha Vantage key. The JavaScript code in the following node automatically calculates the average move of the top 10 stocks to determine the daily sentiment.^) so the News API doesn't error out. It then pulls the top 3 headlines to provide "The Why."Change the AI Provider: If you prefer OpenAI, delete the Google Gemini Chat Model node and replace it with the OpenAI Chat Model node. Connect it to the Generate Financial Insight agent.
Adjust Sentiment Logic: You can edit the code in the Calculate Market Sentiment node to change how "Bullish" or "Bearish" is defined (e.g., based on a specific index instead of gainers/losers).
Filter News: You can adjust the Keep Top 3 Headlines node to keep more or fewer articles depending on how much detail you want the AI to analyze.
Email Reports: Add a Gmail or Outlook node at the end to send the same report to your email subscribers.
Database Logging: Add a PostgreSQL or Google Sheets node to keep a historical record of daily market sentiment for long-term trend analysis.
Multi-Stock Analysis: Duplicate the "Research" branch to analyze both the Top Gainer and the Top Loser in the same report.
Morning Briefings: Schedule the workflow to run 30 minutes after market open to see early movers.
Competitor Tracking: Modify the search to look for specific tickers of competitors and alert Slack when they have high volatility.
Content Creation: Use the AI-generated summary as a draft for a "Daily Market Update" LinkedIn post.
Portfolio Hedge Alerts: Set the sentiment logic to trigger a "High Alert" message if the average loser move exceeds -10%.
Educational Tool: Use the news context to learn which types of headlines (e.g., FDA approvals, CEO changes) drive the biggest price swings.
| Issue | Possible Cause | Solution |
|---|---|---|
| API Rate Limit Error | Alpha Vantage free tier allows limited calls per minute. | The "API Rate Limit Guard" (Wait node) is included; increase the wait time if errors persist. |
| Empty News Context | The top gainer might be a new or obscure ticker with no recent news. | The workflow will still run, but the AI will have less context. Try increasing the news search window. |
| Slack Message Not Sent | Incorrect Channel ID or User ID. | Re-select the destination in the Slack node dropdown menu. |
| AI Output is Too Long | The prompt instructions are being ignored. | Edit the "System Message" in the AI Agent node to explicitly state a word count limit. |
Need assistance setting up your API keys or want to customize this workflow with advanced add-ons? We are here to help!
WeblineIndia specializes in building complex business process automations that save time and reduce overhead.