AI Financial Chatbot to Telegram
Answers stock market queries using Google Finance data via SerpAPI. An AI agent generates concise financial reports and delivers them to Telegram and email.
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:
- Listens for incoming questions about financial data via a webhook trigger.
- Parses and validates the query input, defaulting to an S&P 500 market overview if none is given.
- Fetches relevant market data from Google Finance through SerpAPI using the ticker symbol.
- Processes and summarizes the raw financial data to extract key details like summaries, market trends, news, and financials.
- Merges all gathered data and user input into a single structured dataset.
- Uses an AI agent to analyze the information and compose a detailed, user-friendly financial report.
- 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
| Node | Description |
|---|---|
| Webhook Trigger | Receives 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 SerpAPI | Pulls 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. |
| Merge | Combines parsed input and financial data into a single object for the AI to analyze. |
| AI Agent Node | Generates a detailed, engaging financial report based on the data and user query, using fallback web search tools if needed. |
| Telegram Send Message | Sends the AI-generated financial response as a Telegram message to the user. |
| Gmail Send Email | Sends the financial report as an HTML-formatted email if an email address was provided. |
Setup Instructions
Step 1: SerpAPI Key
- Create an account at serpapi.com.
- Copy your API key.
- In the workflow, go to Variables and set
SERPAPI_KEY(mark it as secret).
Step 2: Telegram Bot
- Message @BotFather on Telegram.
- Create a new bot with
/newbot. - Copy the bot token.
- Connect your Telegram Bot API connector in the workflow.
Step 3: Gmail
- Connect your Gmail account via the connector.
- Update the
REPORT_EMAILvariable 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.
