Skip to main content
You can also import this template directly from here - https://cloud.activepieces.com/templates/fb3b8HFenLKGNxe8BRJhA This notebook demonstrates how to set up and leverage Activepieces’ automation platform combined with Dappier and OpenAI for stock market analysis. By combining real-time data, AI reasoning, and workflow automation, this notebook walks you through an innovative approach to creating fully automated investment research reports. In this notebook, you’ll explore:
  • Activepieces: A powerful no-code automation platform that enables multi-step workflows with triggers, conditional routing, and app integrations—without writing a single line of code.
  • Dappier: A platform connecting LLMs and automation tools to real-time, rights-cleared data from trusted sources, specializing in domains like stock market, finance, and news. It delivers enriched, prompt-ready data, empowering AI with verified and up-to-date information.
  • OpenAI: A leading provider of advanced AI models capable of natural language understanding, contextual reasoning, and content generation. It enables intelligent, human-like interactions and supports a wide range of applications across various domains.
  • Gmail: Email-based interaction point that triggers this automation and serves as the delivery channel for the final investment report.
This setup not only demonstrates a practical application of AI-driven stock market analysis but also provides a flexible framework that can be adapted to other real-world scenarios requiring real-time data integration, automation logic, and AI-powered summarization.

⚙️ Starting with Setup in Activepieces

To get started, head over to Activepieces and create a new flow. This bot will trigger when a new email is received in your Gmail inbox, analyze the query using AI, fetch real-time financial data from Dappier, and send a full investment report via email.

Step 1: Set the Trigger – New Email in Gmail

Search for the Gmail piece and choose the New Email trigger. Configure the following:
  • Authentication: Connect your Gmail account.
  • Label: Set to INBOX to monitor all incoming messages.
  • Category: Leave it empty to include all categories.
Once this trigger is set, your automation will activate whenever a new email lands in your inbox.

Step 2: Determine Relevance – Is It a Stock Query?

Add a new OpenAI action immediately after the trigger. Configure it as follows:
  • Model: chatgpt-4o-latest
  • Prompt:
  • Max Tokens: 2048
  • Temperature: 0.1

🔀 Conditional Routing & Ticker Extraction

Step 3: Add a Router to Branch Logic

Use the Router to evaluate the result from the previous OpenAI step. Configure two branches:
  • Branch Name: Stock Analysis
    • Condition:
  • Branch Name: Otherwise
    • This fallback branch will do nothing or exit the flow if the email isn’t related to a stock query.

Step 4: Extract the Stock Ticker Symbol

Under the Stock Analysis branch, add a new OpenAI action. Configure it as follows:
  • Model: chatgpt-4o-latest
  • Prompt:
  • Max Tokens: 2048
  • Temperature: 0.1
This action ensures you only extract the relevant stock ticker (e.g., AAPL from “Tell me about Apple”).

📊 Real-Time Financial Data Retrieval using Dappier

With the extracted stock ticker, we’ll now gather structured financial insights using Dappier’s real-time models. For each query below, make sure to use the Real Time Data action from the Dappier piece.

Step 5: Get Company Overview

Add a Dappier action and select Real Time Data. Use the following query:
This gives a detailed snapshot of the company and its basic metadata.

Step 6: Get Financial Performance Metrics

Add another Dappier action (again using Real Time Data) and enter:
This returns structured financial performance metrics and key indicators.

Step 7: Competitive Benchmarking

Add a third Dappier action (also using Real Time Data) with the query:
This enables side-by-side comparison with industry peers.

📈 Real-Time Stock Snapshot & Market News

We’ll now use Dappier’s specialized Stock Market Data action to retrieve detailed market-level insights and the latest categorized financial news.

Step 8: Get Real-Time Stock Snapshot

Add a Dappier action and select Stock Market Data. Use the following query:
This returns a structured snapshot of the company’s live trading metrics and historical movement.

Step 9: Get Categorized Financial News

Add another Dappier action (also using Stock Market Data) with the following query:
This returns categorized, real-time news summaries, perfect for building context in your final investment report.

🧠 Generate Investment Report with OpenAI

Now that we’ve collected all the required data—company profile, financial performance, peer benchmarking, real-time stock snapshot, and categorized news—we’ll synthesize everything into a polished, readable investment report using OpenAI.

Step 10: Compile the Full Report

Add an OpenAI action and configure it with the following:
  • Model: chatgpt-4o-latest
  • Prompt:
This action will generate a clean, richly structured report in semantic HTML format—ready to be delivered by email.

📤 Delivering the Report via Gmail

Now that the investment report is generated, let’s send it back to the original sender as a formatted HTML email using Gmail.

Step 11: Send the Email

Add a Gmail action and choose Send Email. Configure the email fields as follows:
  • To:
Use the dynamic reference to send it back to the email originator:
  • Subject:
  • Body:
  • Body Type: HTML
  • CC/BCC/Reply-To: Leave these empty unless needed.
  • Draft: Set to false to send the email immediately.
Once configured, the flow will respond to every stock-related query with a professional-grade investment report, fully automated.

🌟 Highlights

This notebook has guided you through building a fully automated stock market analysis workflow using Activepieces, OpenAI, Dappier, and Gmail. You’ve seen how to classify queries, extract ticker symbols, fetch real-time financial data, generate detailed reports, and deliver them directly to email—all without writing a single line of backend code. Key tools utilized in this notebook include:
  • Activepieces: A powerful no-code automation platform that enables app-triggered workflows with conditional logic, AI actions, and app integrations.
  • OpenAI: A leading provider of advanced AI models used here to classify stock queries, extract ticker symbols, and generate investment reports in rich HTML format.
  • Dappier: A platform connecting LLMs and automation tools to real-time, rights-cleared data from trusted sources, specializing in domains like stock market, finance, and news. It delivers enriched, prompt-ready data, empowering automations with verified and up-to-date information.
  • Gmail: Serves as both the input trigger and output channel, making the workflow seamlessly email-driven.
This comprehensive setup allows you to adapt and expand the example for various scenarios requiring stock research, financial insights, or real-time data–driven automation.