Build your own stock sentiment pipeline with Apify and n8n

Create an automated workflow to collect stock sentiment signals from X/Twitter and Yahoo Finance, save structured datasets, and analyze them with AI.

If you’re tracking stock sentiment manually, you’re probably stuck in one of two modes. You’re either checking social media and finance sites yourself, searching for ticker mentions and reading posts one by one, or you’re using a closed sentiment platform that gives you prebuilt dashboards, but little control over the data sources, search terms, or how often the data is collected.

There’s a third option, though: build your own stock sentiment analysis pipeline. By combining Apify Actors for web data extraction with n8n for workflow automation, you can collect social media chatter, enrich it with financial market data, and store clean JSON files in Google Drive on schedule.

n8n workflow for stock sentiment analysis

In this tutorial, we’ll build a stock sentiment data pipeline for the freight and logistics sector. The workflow will collect X/Twitter posts about freight, trucking, rail, logistics, and transportation stocks, as well as Yahoo Finance data for relevant freight and logistics tickers. JSON files will be saved automatically to Google Drive on a daily basis.

By the end of this tutorial, you’ll have a reusable workflow you can adapt to any stock, ETF, sector, or market theme.

How to build a stock sentiment pipeline with Apify and n8n

We’ll create a workflow using two Apify Actors:

ℹ️
Apify tools are called Actors. They can perform both simple actions and complex data extraction tasks, such as scraping social media posts, collecting finance data, crawling websites, or transforming datasets. Actors can be run from Apify Console, through the API, or inside automation tools like n8n.

Our n8n workflow will contain the following steps:

  1. Daily trigger
  2. Running the X/Twitter scraper with freight-related search terms
  3. Running the Yahoo Finance scraper with logistics-related tickers
  4. Aggregating both datasets
  5. Converting the results to JSON files
  6. Uploading the files to Google Drive
👉
To follow along with this tutorial, make sure you have access to n8n and have both an active Apify account and a Google account.

Step 1: Create a daily trigger in n8n

Open n8n and create a new workflow. Add a Schedule Trigger node as the first step. In this example, the workflow runs once per day at 9 AM, but you can adjust it to your needs - once per day for long-term sentiment tracking or every few hours during earnings season.

n8n Schedule Trigger node - daily runs

Step 2: Add the X/Twitter scraper

Next, add an Apify node to the workflow. Search for the Apify node in your canvas (and install it if you haven’t already). Select the Run an Actor and get dataset operation.

Once you open the node, you can connect n8n to your Apify account. Click on Create new credential to get started.

Create New Credential in n8n

Next, you’ll be asked for your Apify API key. You can find it in Apify Console under Settings → API & Integrations, where you can copy your API token.

Get your Apify API token

Paste the token into n8n and save the credential. Your Apify connection is ready to use.

Next, you’ll select the Actor you want to run from Apify Store and grab its JSON input so n8n can run it. Go to Twitter (X.com) Scraper Unlimited and adjust the scraping session to your needs using the UI. This Actor will collect recent X/Twitter posts matching the search terms you provide. For this workflow, we’re tracking freight and logistics stock sentiment, so the search terms include a mix of ETFs, sector keywords, and industry signals.

This gives us a useful mix of data - ticker-based searches like $IYT and $XTN, sector searches like freight stocks, and industry condition searches like freight recession.

💡
Tip: A cashtag is a stock ticker symbol prefixed with a dollar sign - $TSLA, $NVDA, $AAPL, $FDX. They work the same way hashtags do on social media: clickable links that aggregate every post tagged with the same symbol. X/Twitter and a few other platforms render them as searchable links.

Go back to the n8n node, and paste the JSON input into the input field:

Screenshot 2026-04-28 at 17.08.51.png

Once the node runs, you’ll get structured tweet data back from Apify. Now you can test it by clicking Execute step at the top. Once the Actor finishes running, you’ll see its output displayed as JSON next to the node:

Screenshot 2026-04-28 at 17.12.07.png

Step 3: Scrape Yahoo Finance

While social media tells you what people are saying, Yahoo Finance gives you market context. Add a second Apify node to the workflow and choose the same operation:  Run an Actor and get dataset . Connect it to the same trigger. This way, both Actors run every time the workflow starts: one collects X/Twitter posts, and the other collects Yahoo Finance data.

Screenshot 2026-04-28 at 17.24.08.png

Select Yahoo Finance - Full stock info, news, cheapest, real-time from the list and configure the run in Apify Console, as before. In this workflow, we’re collecting stock data for freight, logistics, rail, trucking, delivery, and related transport tickers. Paste the JSON input into the n8n node.

Again, you can test the node by executing this step.

Step 4: Aggregate the Twitter and Yahoo Finance results

After each Apify Actor runs, add an Aggregate node - one for Twitter and one for Yahoo Finance. In this workflow, both Aggregate nodes use Aggregate All Item Data (Into a Single List) option. Aggregating the items first makes it easier to create one clean file per source:

  • One JSON file for Twitter/X data
  • One JSON file for Yahoo Finance data
Screenshot 2026-04-28 at 17.39.59.png

Step 5: Convert each dataset to a JSON file

Next, add a Convert to File node after each Aggregate node. The date in the filename makes the workflow easier to manage over time. Instead of overwriting the same file every day, n8n creates a dated snapshot:

For the Twitter branch, name the file twitter_freight_{{ $now.format('yyyy-MM-dd') }}.json

For the Yahoo Finance branch, name the file yahoo_freight_{{ $now.format('yyyy-MM-dd') }}.json.

Over time, your Google Drive folder becomes a daily archive of stock sentiment inputs.

Your workflow up to this point has one trigger and two branches, three nodes in each branch:

Screenshot 2026-04-28 at 17.50.25.png

Step 6: Upload the files to Google Drive

The final step is to upload both JSON files to Google Drive. Add a Google Drive node after each Convert to File node. Connect your Google account and select a folder for your files. Set the file name to twitter_freight_{{ $now.format('yyyy-MM-dd') }}.json for Twitter and yahoo_freight_{{ $now.format('yyyy-MM-dd') }}.json for Yahoo Finance.

Screenshot 2026-04-28 at 17.53.31.png

Execute the whole workflow to test it out.

Screenshot 2026-04-29 at 9.23.39.png

Check Google Drive for your new datasets. You now have a daily stock sentiment data pipeline running with Apify and n8n.

Files created automatically in Google Drive

Files created automatically in Google Drive

Step 7: AI analysis

The n8n workflow gives you the raw material for stock sentiment analysis, ready to be processed by AI tools.

The Twitter/X dataset can be used to analyze positive or negative language around the sector, as well as the discussion volume around demand, stocks, or tariffs. You can scrape posts mentioning ETFs or monitor sudden changes in market chatter. The Yahoo Finance dataset adds the market context with the current stock data and company comparisons.

Feed both JSON files to your AI tool to classify tweets, compare sentiment scores against daily market data, and track most-discussed tickers or phrases.

Your stock sentiment analysis can look like this (created by Claude):

Screenshot 2026-04-29 at 8.55.29.png
Screenshot 2026-04-29 at 9.03.44.png

How to adapt this workflow

The easiest way to adapt this workflow is to change the search terms and tickers. For example, to monitor banking stocks, you could replace the Twitter freight search terms with bank stocks, credit risk, $KBE, and $KRE. Your Yahoo Finance tickers would be JPM, BAC, WFC, or GS. For AI stocks, you could use $NVDA, $MSFT, and AI stocks.

You’re not locked into a predefined dataset or dashboard - change the market theme whenever you want.

Start tracking stock sentiment

This workflow turns stock sentiment monitoring from a manual research task into a structured data pipeline. Because the workflow lives in n8n, it's easy to extend. Today it ends at Google Drive, but you can add an AI sentiment-scoring node, a database write, or a Slack alert as separate steps - the data collection layer stays the same.

Apify logo
Try Apify for free
Start collecting finance data
On this page

Build the scraper you want

No credit card required

Start building