AI Financial Chatbot to Telegram

OpenAItelegram_bot_apiGoogle Mail

Answers stock market queries using Google Finance data via SerpAPI. An AI agent generates concise financial reports and delivers them to Telegram and email.

Google FinanceStock MarketTelegram BotFinancial Reports

What This Workflow Does

This workflow creates an AI-powered financial chatbot that answers user queries about stocks and market data using Google Finance information accessed via SerpAPI. The responses are generated by an AI agent and delivered directly to users through Telegram messages and email reports.

It performs the following steps:

  1. Listens for incoming questions about financial data via a webhook trigger.
  2. Parses and validates the query input, defaulting to an S&P 500 market overview if none is given.
  3. Fetches relevant market data from Google Finance through SerpAPI using the ticker symbol.
  4. Processes and summarizes the raw financial data to extract key details like summaries, market trends, news, and financials.
  5. Merges all gathered data and user input into a single structured dataset.
  6. Uses an AI agent to analyze the information and compose a detailed, user-friendly financial report.
  7. Sends the generated financial report to the user via Telegram and, if an email is provided, also delivers it as a formatted email.

What You Need

  • A Needle platform account with access to workflow automation.
  • A SerpAPI API key with Google Finance engine access.
  • Telegram Bot API credentials and a Telegram bot connected for sending messages.
  • Gmail connector or SMTP setup for sending email reports.

How the Flow Works

NodeDescription
Webhook TriggerReceives incoming financial question requests from users or API calls.
Code (Parse Input)Parses the incoming data, extracting question, ticker symbol, email, and chat ID. Adds defaults if needed.
HTTP Request to SerpAPIPulls financial data for the specified ticker symbol from SerpAPI's Google Finance engine.
Code (Process Financial Data)Extracts and formats key sections like market summary, trends, news, and financials into readable text.
MergeCombines parsed input and financial data into a single object for the AI to analyze.
AI Agent NodeGenerates a detailed, engaging financial report based on the data and user query, using fallback web search tools if needed.
Telegram Send MessageSends the AI-generated financial response as a Telegram message to the user.
Gmail Send EmailSends the financial report as an HTML-formatted email if an email address was provided.

Setup Instructions

Step 1: SerpAPI Key

  1. Create an account at serpapi.com.
  2. Copy your API key.
  3. In the workflow, go to Variables and set SERPAPI_KEY (mark it as secret).

Step 2: Telegram Bot

  1. Message @BotFather on Telegram.
  2. Create a new bot with /newbot.
  3. Copy the bot token.
  4. Connect your Telegram Bot API connector in the workflow.

Step 3: Gmail

  1. Connect your Gmail account via the connector.
  2. Update the REPORT_EMAIL variable with your fallback email address.

Step 4: Test

Send a POST request to the webhook URL with a payload like:

{
  "question": "AAPL stock price?",
  "ticker": "AAPL",
  "email": "you@gmail.com",
  "chatId": "123"
}

All fields are optional. If no question or ticker is provided, the workflow defaults to an S&P 500 market overview.

Output

The user receives a professional and concise financial analysis report tailored to their question. The report includes:

  • Current price and change
  • Key metrics (market cap, P/E ratio, volume, 52-week range)
  • Market context and trends
  • Brief outlook

The report is delivered as a Telegram message and optionally as an HTML-formatted email.

Notes

  • If the user does not provide a specific ticker or question, the workflow defaults to an S&P 500 market overview.
  • The AI agent uses fallback tools to search the web if SerpAPI data is unavailable or incomplete.
  • Ensure your Telegram bot and Gmail connectors have the required permissions configured.
  • The financial data output is kept concise to fit message and email formatting constraints.
  • This workflow can be customized to support additional financial instruments like crypto, forex, and commodities by adjusting the prompt and API queries.

Want to showcase your own workflows?

Become a Needle workflow partner and turn your expertise into recurring revenue.

Try Needle today

Streamline AI productivity at your company today

Join thousands of people who have transformed their workflows.

Agentic workflowsAutomations, meet AI agents
AI SearchAll your data, searchable
Chat widgetsDrop-in widget for your website
Developer APIMake your app talk to Needle
    Needle LogoNeedle
    Like many websites, we use cookies to enhance your experience, analyze site traffic and deliver personalized content while you are here. By clicking "Accept", you are giving us your consent to use cookies in this way. Read our more on our cookie policy .