Listed companies in India publish a steady stream of announcements on the NSE and BSE websites: order wins, board meeting outcomes, regulatory approvals, capacity expansions. For traders and research teams, the useful facts are buried inside PDFs, and the good ones need to be read quickly. A client asked for a bot that does the reading for them.
What the bot does
- Watches the corporate announcements pages on NSE and BSE.
- Picks up every new filing and downloads the PDF.
- Sends the document to Google Gemini with a prompt that asks for specific fields: who awarded the order, its value, the contract period and a one-line summary.
- Adds market context such as market cap, P/E and current price from screener sites like Trendlyne.
- Posts a formatted message to a Telegram channel and logs every filing to a spreadsheet.
Getting the data reliably
Exchange websites are not built for automated access. Plain HTTP requests are often blocked, and the announcement lists load through the browser. I used Selenium with a persistent Chrome session, so cookies and headers look like a normal visitor, and kept the request rate low.
The bot keeps a list of PDF URLs it has already processed. Every run compares new announcements against that list, so a restart or a network hiccup never causes duplicate alerts. Failures are written to an error log with a screenshot of the page, which makes it quick to see when a website layout has changed.
Letting AI read the PDF
Filings don't follow a template. One company writes "LoA received for ₹142 crore", another spreads the same facts across three paragraphs and a table. Rules and regular expressions break quickly, so this is where an LLM earns its place.
The prompt asks Gemini to return JSON with fixed keys (order value, awarded by, period, summary). The code then validates that JSON before using it: missing fields stay empty rather than being guessed. When a daily API quota runs out, the bot switches to the next key instead of stopping.
The Telegram message
The output is designed to be read on a phone in a few seconds: company and symbol, the subject line, the extracted order details, three market numbers, a one-line AI summary and a link to the original PDF. The same record goes into an Excel log, so the client can filter by date or company later.
What I'd tell anyone building something similar
- De-duplicate first. A bot that sends the same alert twice loses trust fast.
- Ask the LLM for structured output and validate it. Never paste free-form AI text straight into an alert.
- Log with screenshots. Websites change; a screenshot shows what changed in seconds.
- Keep API keys out of the code. Environment variables or a secrets store, never hard-coded strings.
For another client I built a lighter variant of the same idea: a BSE notifier that checks every hour during Indian market hours, using only Telebot and a timezone-aware scheduler.