This commit is contained in:
nusquama
2025-11-12 16:10:32 +01:00
parent 0e4df79cfd
commit 24109e3bee
@@ -0,0 +1,285 @@
WordPress Article Summarization with GPT-4 and Email Broadcasting via Google Sheets
https://n8nworkflows.xyz/workflows/wordpress-article-summarization-with-gpt-4-and-email-broadcasting-via-google-sheets-6059
# WordPress Article Summarization with GPT-4 and Email Broadcasting via Google Sheets
### 1. Workflow Overview
This workflow automates the process of fetching the latest WordPress blog post, summarizing it using GPT-4, and broadcasting the summary via email to a list of subscribers stored in a Google Sheet. It is designed to run daily at a scheduled time, ensuring subscribers receive concise updates without manual intervention.
The workflow is logically divided into the following blocks:
- **1.1 Scheduled Trigger:** Initiates the workflow daily.
- **1.2 WordPress Content Retrieval:** Fetches the most recent blog post from a WordPress site.
- **1.3 Article Data Preparation:** Extracts and formats key article details.
- **1.4 AI Summarization:** Uses OpenAI's GPT-4 to generate a concise summary.
- **1.5 Subscriber Retrieval:** Reads subscriber emails from Google Sheets.
- **1.6 Batch Processing:** Handles subscriber emails one at a time.
- **1.7 Email Broadcasting:** Sends the summarized article to each subscriber.
---
### 2. Block-by-Block Analysis
#### 2.1 Scheduled Trigger
- **Overview:**
Starts the workflow automatically every day at 9:00 AM.
- **Nodes Involved:**
- Schedule Trigger
- **Node Details:**
- **Schedule Trigger**
- Type: Cron Trigger
- Configuration: Runs daily at 09:00 (cron expression `0 9 * * *`)
- Input: None (trigger node)
- Output: Triggers downstream nodes
- Edge Cases: Cron misconfiguration could prevent workflow start; time zone considerations apply.
- Version: 1
---
#### 2.2 WordPress Content Retrieval
- **Overview:**
Fetches the latest blog post data (title, content, link) from the WordPress REST API.
- **Nodes Involved:**
- Fetch Latest Post
- **Node Details:**
- **Fetch Latest Post**
- Type: HTTP Request
- Configuration:
- URL: `https://yourwordpresssite.com/wp-json/wp/v2/posts?per_page=1`
- Method: GET (default)
- Response Format: JSON
- Input: Trigger from Schedule Trigger
- Output: JSON array containing the latest post data
- Edge Cases:
- API downtime or incorrect URL leads to request failure.
- API rate limiting or authentication issues (if required by WP site).
- Empty response if no posts available.
- Version: 1
---
#### 2.3 Article Data Preparation
- **Overview:**
Extracts and formats key information from the fetched post for further processing.
- **Nodes Involved:**
- Set Article Details
- **Node Details:**
- **Set Article Details**
- Type: Set node
- Configuration:
- Sets three fields:
- `title` from `$json[0].title.rendered` (post title)
- `content` from `$json[0].content.rendered` (post content)
- `link` from `$json[0].link` (post URL)
- Keeps only these fields in output
- Input: JSON array from Fetch Latest Post
- Output: Object with simplified article details
- Edge Cases:
- If any field is missing or malformed, expressions may fail or produce empty strings.
- Version: 2
---
#### 2.4 AI Summarization
- **Overview:**
Uses GPT-4 to summarize the blog post content into three key points.
- **Nodes Involved:**
- Summarize with OpenAI
- **Node Details:**
- **Summarize with OpenAI**
- Type: OpenAI node
- Configuration:
- Model: GPT-4
- Prompt: `"Summarize this blog post in 3 key points:\n\n{{$json["content"]}}"`
- Input: Article content from Set Article Details
- Output: Text summary generated by GPT-4
- Credentials: Requires valid OpenAI API key configured under `openAiApi`
- Edge Cases:
- API rate limits or quota exceeded errors
- Network timeout or API unavailability
- Malformed content causing unexpected responses
- Version: 1
---
#### 2.5 Subscriber Retrieval
- **Overview:**
Reads the list of subscriber email addresses from a Google Sheet.
- **Nodes Involved:**
- Get Subscribers
- **Node Details:**
- **Get Subscribers**
- Type: Google Sheets node
- Configuration:
- Range: `Sheet1!A:A` (assumes emails are in column A)
- Sheet ID: `YOUR_SHEET_ID` (to be replaced)
- Input: Parallel output from Set Article Details (runs after article is ready)
- Output: List of subscriber emails in JSON format, with each row as a separate item
- Credentials: Requires OAuth2 credentials for Google Sheets (`googleSheetsOAuth2Api`)
- Edge Cases:
- Invalid or missing Sheet ID causes failure
- OAuth token expiration or permission errors
- Empty subscriber list results in no emails sent
- Version: 3
---
#### 2.6 Batch Processing
- **Overview:**
Processes subscribers one by one to send individualized emails.
- **Nodes Involved:**
- SplitInBatches
- **Node Details:**
- **SplitInBatches**
- Type: SplitInBatches node
- Configuration:
- Batch Size: 1 (processes one email at a time)
- Input: List of subscribers from Get Subscribers
- Output: Individual subscriber email per execution cycle
- Edge Cases:
- Large subscriber lists can increase total execution time
- If input is empty, no batches executed
- Version: 1
---
#### 2.7 Email Broadcasting
- **Overview:**
Sends an email to each subscriber with the article summary and a link to the full post.
- **Nodes Involved:**
- Send Email
- **Node Details:**
- **Send Email**
- Type: Email Send node
- Configuration:
- From: `you@example.com` (replace with sender email)
- To: `={{$json["Email"]}}` (reads current subscriber email from batch)
- Subject: `New Summary: {{$node["Set Article Details"].json["title"]}}` (article title)
- Text Body: Includes the summary from GPT-4 and the article link
- Credentials: Requires SMTP credentials configured under `smtp`
- Input: One subscriber email from SplitInBatches; article summary and details available via expressions from prior nodes
- Edge Cases:
- Invalid email addresses causing send failure
- SMTP authentication or connection issues
- Email throttling by SMTP provider
- Version: 1
---
### 3. Summary Table
| Node Name | Node Type | Functional Role | Input Node(s) | Output Node(s) | Sticky Note |
|---------------------|--------------------|--------------------------------|-----------------------|-------------------------|------------------------------------------------|
| Schedule Trigger | Cron Trigger | Initiates workflow daily | — | Fetch Latest Post | |
| Fetch Latest Post | HTTP Request | Fetches latest WordPress post | Schedule Trigger | Set Article Details | |
| Set Article Details | Set | Extracts title, content, link | Fetch Latest Post | Summarize with OpenAI, Get Subscribers | |
| Summarize with OpenAI | OpenAI | Generates summary with GPT-4 | Set Article Details | — | |
| Get Subscribers | Google Sheets | Retrieves subscriber emails | Set Article Details | SplitInBatches | |
| SplitInBatches | SplitInBatches | Processes subscribers one-by-one | Get Subscribers | Send Email | |
| Send Email | Email Send | Sends summary email to subscriber | SplitInBatches | — | |
---
### 4. Reproducing the Workflow from Scratch
1. **Create a new workflow** in n8n named "Smart Article Summarizer & Email Broadcaster".
2. **Add a "Schedule Trigger" node**:
- Type: Cron Trigger
- Set cron expression to `0 9 * * *` (runs daily at 9:00 AM).
3. **Add a "HTTP Request" node** named "Fetch Latest Post":
- Connect Schedule Trigger output to this node input.
- Set HTTP Method to GET.
- Set URL to `https://yourwordpresssite.com/wp-json/wp/v2/posts?per_page=1` (replace with your WordPress site URL).
- Set Response Format to JSON.
4. **Add a "Set" node** named "Set Article Details":
- Connect from "Fetch Latest Post".
- Configure to set 3 string fields:
- `title` = `{{$json[0].title.rendered}}`
- `content` = `{{$json[0].content.rendered}}`
- `link` = `{{$json[0].link}}`
- Enable "Keep Only Set" to remove other fields.
5. **Add an "OpenAI" node** named "Summarize with OpenAI":
- Connect from "Set Article Details".
- Configure:
- Model: GPT-4
- Prompt:
```
Summarize this blog post in 3 key points:
{{$json["content"]}}
```
- Under Credentials, select or create your OpenAI API credential.
6. **Add a "Google Sheets" node** named "Get Subscribers":
- Connect from "Set Article Details" (parallel connection).
- Set Sheet ID to your Google Sheet's ID containing subscriber emails.
- Set Range to `Sheet1!A:A` (adjust if your emails are in another sheet or column).
- Authenticate using Google OAuth2 credentials.
7. **Add a "SplitInBatches" node**:
- Connect from "Get Subscribers".
- Set Batch Size to 1 to process emails individually.
8. **Add an "Email Send" node** named "Send Email":
- Connect from "SplitInBatches".
- Configure:
- From Email: Your sender email address (e.g. `you@example.com`).
- To Email: Expression `={{$json["Email"]}}` (assumes Google Sheet column header is "Email").
- Subject: Expression `New Summary: {{$node["Set Article Details"].json["title"]}}`.
- Text:
```
Heres a summary of the latest article:
{{$node["Summarize with OpenAI"].json["text"]}}
Read full post: {{$node["Set Article Details"].json["link"]}}
```
- Setup SMTP credentials under "smtp" for sending emails.
9. **Verify all connections and credentials** are properly set.
10. **Save and activate** the workflow.
---
### 5. General Notes & Resources
| Note Content | Context or Link |
|------------------------------------------------------------------------------|-------------------------------------------------|
| This workflow depends on valid OpenAI and Google Sheets OAuth2 credentials. | Ensure you create and configure these in n8n. |
| Replace placeholder URLs and email addresses with your actual data. | Workflow wont function properly without this. |
| WordPress REST API endpoint used: `/wp-json/wp/v2/posts?per_page=1` fetches latest post. | WordPress REST API docs: https://developer.wordpress.org/rest-api/ |
| For improved efficiency with large subscriber lists, consider increasing batch size or adding delays. | n8n SplitInBatches docs: https://docs.n8n.io/nodes/n8n-nodes-base.splitInBatches/ |
| Use SMTP providers that support bulk emailing and avoid spam filters. | Recommended providers: SendGrid, Mailgun, etc. |
---
**Disclaimer:** The provided text originates exclusively from an automated workflow created with n8n, an integration and automation tool. This processing strictly respects applicable content policies and contains no illegal, offensive, or protected material. All handled data is legal and publicly accessible.