AWS Builder Center
Building an Automated AI Intelligence Briefing Pipeline with Node.js, RSS, Gemini, PDFKit, and Gmail

Building an Automated AI Intelligence Briefing Pipeline with Node.js, RSS, Gemini, PDFKit, and Gmail

Learn how to build a Node.js automation pipeline that collects AI news from RSS feeds, analyzes headlines with Google Gemini, generates a formatted PDF intelligence report, and delivers it through Gmail. The article also covers reliability, rate limits, configuration, and security improvements for production use.

AI teams, technology leaders, and business owners often monitor the same information sources every day: research laboratories, cloud providers, technology publications, and specialist machine learning communities. The challenge is not finding information; it is turning a large volume of updates into a short, repeatable, and actionable briefing.
This article explains the architecture of OpenClew, an automated intelligence-gathering system implemented as a Node.js script. The implementation collects the latest item from a list of AI-related RSS feeds, sends each headline to a Google Gemini model for executive analysis, composes the results into an A4 PDF document, and sends the report as an email attachment.
The complete implementation is available in the  index.mjs  file, while the project metadata and runtime dependencies are defined in  package.json . The design is intentionally straightforward: one master cycle orchestrates collection, analysis, document generation, and delivery.
What the application does
The pipeline follows a deterministic sequence. First, it requests data from multiple RSS endpoints in parallel. Next, it keeps the first <item> element found in each response and extracts its title, link, and source hostname. Each valid item is then analyzed by Gemini. The generated analysis is added to an in-memory array, which is passed to PDFKit to create the final report. Finally, Nodemailer connects to Gmail and sends the PDF to the configured recipient.
Stage Responsibility Main implementation Configuration Reads credentials, recipient, model names, and output path CONFIG object and environment variables Collection Requests RSS feeds and extracts the latest item axios and fetchFromSource() Normalization Converts different RSS responses into a common object title, link, and source fields AI analysis Generates three short executive points for each headline GoogleGenerativeAI and deepAnalyze() Report generation Creates a styled A4 PDF with links and analysis PDFDocument and createMassivePDF() Delivery Sends the report as a Gmail attachment nodemailer and sendMail()
Project dependencies
The repository uses ECMAScript modules and declares index.mjs as its main entry point. The dependency list is small enough to understand and maintain without introducing a large framework.
Package Role in the project Documentation axios Performs HTTP requests to RSS endpoints [Axios documentation] @google/generative-ai Creates a Gemini client and submits prompts [Google Generative AI SDK] nodemailer Sends the generated report by email [Nodemailer documentation] pdfkit Builds the PDF document programmatically [PDFKit documentation] fs and path Writes the PDF file and resolves its path Node.js built-in modules
The project configuration uses "type": "module", so the source file can use import statements. Install the dependencies from the repository directory with the following commands:
Bash
npm install node index.mjs
Before starting the application, provide the required secrets through environment variables. A safer baseline configuration is:
Bash
export GEMINI_API_KEY="your-gemini-api-key" export EMAIL_PASS="your-gmail-app-password" node index.mjs
The script also contains a recipient email address in its configuration. For a reusable deployment, move that value into an environment variable as well:
Plain Text
const CONFIG = { API_KEY: process.env.GEMINI_API_KEY, RECIPIENT: process.env.RECIPIENT_EMAIL, EMAIL_PASS: process.env.EMAIL_PASS, PDF_PATH: path.resolve('./Full_Strategic_Intelligence_Report.pdf') };
Collecting news from multiple RSS sources
The SOURCES array contains feeds from AI companies, research organizations, publishers, and technical communities. The collection phase uses Promise.all():
Plain Text
const rawResults = await Promise.all(SOURCES.map(fetchFromSource)); const validNews = rawResults.filter((item) => item !== null);
This is an important design choice. A slow or unavailable feed does not block the other requests indefinitely because each Axios request has a 15-second timeout. The fetchFromSource() function catches the exception, logs a warning, and returns null. The master cycle then removes failed sources from the working set.
RSS formats are not perfectly uniform. The implementation therefore checks both a conventional <link> element and an Atom-style link with an href attribute. If the link is missing or too short, it attempts to use the <guid> value as a fallback. The normalized output has this shape:
Plain Text
{ title: "A normalized news headline", link: " https://example.com/article ", source: "example.com" }
The current parser intentionally reads only the first item from each feed. This makes the report compact and limits the number of model calls, but it also means that older or additional stories in the same feed are not included. A production version could add a configurable item limit, XML parsing with a dedicated parser, publication dates, and duplicate detection based on the article URL.
Generating executive analysis with Gemini
The deepAnalyze( ) function receives one normalized news object and constructs a Gemini model client. The prompt requests three short executive bullet points in English:
Plain Text
const result = await model.generateContent(  Analyze this AI news title: "${news.title}". Provide 3 short executive bullet points in English.  );
The result is then converted to text and returned to the report builder. If the first model fails because the model is unavailable, the function continues to the next model in POSSIBLE_MODELS. This fallback approach improves resilience against model-not-found errors, although it does not yet distinguish between all possible failures, such as authentication errors, quota exhaustion, malformed requests, or temporary service unavailability.
The five-second delay before each analysis is a basic pacing mechanism:
Plain Text
await sleep(5000);
It can reduce the likelihood of sending requests too quickly, but it is not a complete rate-limit strategy. A stronger implementation would use exponential backoff, retry limits, structured error categories, and a queue with controlled concurrency. It would also ask the model to return JSON with a defined schema, making the PDF output more predictable than free-form text.
The analysis should be interpreted carefully. Because the prompt contains only the headline, the model may not have enough context to identify the article's methodology, limitations, or business impact. For higher-quality intelligence, the next version should fetch the article content, extract the main text, and pass a bounded and cleaned excerpt to the model together with the title, source, and publication date.
Creating the PDF intelligence report
The createMassivePDF() function uses PDFKit to generate an A4 report with a 40-point margin. It creates a dark blue header, adds the report title, prints the synchronization date, and iterates through the analyzed results.
Each entry contains the source hostname, headline, clickable URL, and generated analysis. A page break is inserted after every two entries, which produces a predictable two-item-per-page layout for the current content size.
Plain Text
const doc = new PDFDocument({ margin: 40, size: 'A4' }); const stream = fs.createWriteStream(CONFIG.PDF_PATH); doc.pipe(stream);
The function returns a Promise and resolves only when the file stream emits finish. This is important because the next stage must not attempt to attach the PDF before the file has been fully written. If the stream emits an error, the Promise rejects and the master cycle handles the failure.
The visual design is intentionally restrained: a dark navy header, a blue date line, dark text for titles, and light separators between entries. For a more editorial report, the same structure could be extended with an executive summary page, source statistics, topic labels, confidence indicators, publication dates, and a table of contents.
Sending the report through Gmail
After the PDF is created, the script creates a Nodemailer transport configured for Gmail and sends the report as an attachment:
Plain Text
const transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: CONFIG.RECIPIENT, pass: CONFIG.EMAIL_PASS } });
The email includes the number of valid news records, the current date, and the generated PDF. In practice, Gmail commonly requires an app password or an appropriate authenticated SMTP configuration rather than a normal account password. The credential should never be committed to source control. Nodemailer supports multiple transport configurations, so the delivery layer can later be replaced with another SMTP provider or an email API without changing the collection and analysis stages.
End-to-end control flow
The startMasterCycle() function is the application entry point and acts as the orchestrator:
Plain Text
Start | v Request all RSS feeds in parallel | v Discard failed feeds and normalize valid items | v Analyze each item with Gemini, sequentially | v Generate the A4 PDF report | v Send the PDF through Gmail | v Log success or terminate on a critical failure
The collection stage is parallel, while the AI analysis stage is sequential. This combination reduces waiting time when downloading feeds and provides a simple way to pace model requests. The trade-off is that a large number of valid feeds can make the analysis stage slow. A configurable concurrency limit would offer a better balance between throughput and API safety.
Reliability and production improvements
The current implementation is a useful prototype because each stage has a clear responsibility and failures in individual feeds are isolated. However, production operation requires stronger observability and data quality controls.
Concern Current behavior Recommended improvement Feed parsing Uses string splitting and regular expressions Use an XML/RSS parser and validate required fields Duplicate articles No deduplication Store URLs or GUIDs and remove repeats Content depth Analyzes only the headline Fetch and clean article text before analysis Model output Free-form text Request schema-constrained JSON and validate it Retry behavior Continues mainly for model-not-found errors Add exponential backoff and bounded retries Persistence Keeps results only in memory Store raw items and reports in a database or object storage Scheduling Runs one cycle when started Use a scheduler, CI workflow, or managed event trigger Monitoring Relies on console messages Add structured logs, metrics, and alerting
A useful next step is to separate the application into four modules: sources, analysis, reporting, and delivery. This keeps the master cycle small and allows each component to be tested independently. Unit tests should cover malformed feeds, missing links, model errors, empty responses, PDF write failures, and email delivery failures.
Security note: protect credentials immediately
The public source file contains a fallback value in the GEMINI_API_KEY configuration expression. Any API key that has been committed to a public repository should be treated as compromised, even if the code is later edited. Rotate or revoke the exposed key, remove it from the repository history where appropriate, and use environment variables or a managed secrets service instead.
The same principle applies to email credentials. Do not use a personal mailbox password in application code. Use an app password with the minimum required access, a dedicated reporting mailbox, or a transactional email provider. Log messages should also avoid printing secrets, authorization headers, or complete private email addresses.
Conclusion
OpenClew demonstrates how a small Node.js program can connect several practical capabilities into one automated workflow: multi-source RSS collection, generative AI analysis, document generation, and email delivery. Its greatest strength is the clear end-to-end flow. Each stage transforms the previous stage's output into a useful artifact, ending with a daily intelligence report that can be consumed without opening every source manually.
The implementation is a strong starting point for experimentation and internal reporting. To make it production-ready, improve secret management, replace regular-expression parsing with an XML parser, analyze article content instead of headlines alone, validate structured model output, add retry and monitoring systems, and introduce persistent storage. Those changes preserve the original architecture while making the pipeline more reliable, auditable, and suitable for recurring business use.



Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article