MUFG Stock Holding Email Summariser

MUFG Stock Holding Email Summariser

Workflow to consume complex stock holding email using n8n and LLM

What this solves

MUFG Investor Services sends frequent email updates about stock holdings from @in.mpms.mufg.com. These emails are formatted for compliance, not readability — dense tables, regulatory language, and buried context. I needed the core takeaway from each email delivered to a channel I actually check, in plain English, in under 100 words.

How it works

The entire pipeline runs on my self-hosted n8n instance and processes each email through five nodes in sequence.

Gmail Trigger polls my inbox every hour for unread emails matching the sender pattern \*@in.mpms.mufg.com. When it finds one, it passes the email ID downstream.

Fetch Full Email takes that ID and retrieves the complete email — HTML body, headers, subject line — via the Gmail API using OAuth2 credentials.

LLM Summarisation is where the magic happens. The full email body and subject line are fed to an AI Agent node connected to my self-hosted Ollama instance running gpt-oss:120b. The prompt is tuned for a stock-trading context:

Text
You are a pro stock trader. Go through this email body and summarise
in less than 5 sentences what this email is trying to communicate
in layman-understandable English.

Find the company name from the email subject.

Output as a simple formatted text message with the company name
as a heading and the summary as the body.

The model extracts the company name from the subject line (which MUFG emails reliably include) and produces a concise, jargon-free summary. Telegram Delivery sends the formatted output to my private chat via a custom bot called Stock Summariser Bot. The message arrives as:

Company name in bold as the heading

Summary broken into bullet points, one per sentence

This gives me a scannable, mobile-friendly notification I can process in under ten seconds. LogSnag Event logs every successfully delivered summary to the stock\_email\_summariser project on LogSnag. Each event captures the bot username, timestamp, and full summary text — giving me an audit trail and volume tracking for free.

The pipeline at a glance

  • Gmail Trigger (hourly poll, filtered to @in.mpms.mufg.com)
  • Fetch full email via Gmail API
  • Summarise with Ollama gpt-oss:120b (self-hosted)
  • Deliver to Telegram as formatted bullet summary
  • Log event to LogSnag for observability

Why self-hosted LLM

These are financial communications from a brokerage. Routing their contents through a third-party API — even one with strong privacy guarantees — felt unnecessary when I already run an Ollama instance. With gpt-oss:120b running locally, every byte of email content stays on my infrastructure. No API keys to manage, no per-token billing, no data leaving the network.

Why Telegram

I evaluated Slack, email digests, and Discord. Telegram won for three reasons: push notifications work flawlessly on both mobile and desktop, the Bot API supports Markdown formatting out of the box (bold headings, bullet points), and message delivery is near-instant. The Stock Summariser Bot took under five minutes to set up via BotFather.

Why hourly polling

MUFG emails are holding updates and regulatory disclosures, not trade signals. They don't need sub-minute latency. Polling every hour keeps the workflow lightweight, avoids Gmail API rate limits, and still surfaces every email well within the same trading session.

Error handling

The workflow is wired to a dedicated n8n error workflow that catches failures at any node — Gmail auth expiry, Ollama timeouts, Telegram delivery failures — and routes them separately. This keeps the happy path clean while ensuring nothing silently fails.

Stack

  • Orchestration: n8n (self-hosted)
  • LLM: Ollama running gpt-oss:120b (self-hosted)
  • Email: Gmail API with OAuth2
  • Delivery: Telegram Bot API
  • Observability: LogSnag
  • Error handling: n8n error workflow