Loading...
Loading...
Loading...
Generate social media-ready content from multiple blog sources on a specific topic, exported to spreadsheet format!
# Topic Aggregation for Social Media Content
Generate social media-ready content from multiple blog sources on a specific topic, exported to spreadsheet format!
## Features
✨ **Batch Summarization** - Process multiple URLs concurrently for a specific topic
📱 **Multi-Platform Posts** - Generate optimized posts for Twitter, LinkedIn, Facebook, and Instagram
📊 **Spreadsheet Export** - Export to CSV or Excel with all content organized
🎯 **Character-Optimized** - Each platform's post respects character limits
#️⃣ **Smart Hashtags** - Auto-generated hashtags from topic and content
⚡ **Concurrent Processing** - Fast batch processing with configurable workers
## Use Case
Perfect for:
- Social media managers creating content calendars
- Marketing teams tracking industry trends
- Content creators aggregating research
- Brand managers monitoring competitor content
- Digital agencies managing multiple clients
## Quick Start
### 1. API Usage
#### Aggregate and Get JSON
```bash
curl -X POST "http://localhost:8000/aggregate-topic" \
-H "Content-Type: application/json" \
-d '{
"topic": "AI-Trends-2025",
"urls": [
"https://blog.google/technology/ai/",
"https://openai.com/blog/",
"https://www.anthropic.com/news"
],
"platforms": ["twitter", "linkedin", "facebook", "instagram"],
"max_workers": 3
}'
```
#### Export to Spreadsheet
```bash
curl -X POST "http://localhost:8000/aggregate-topic/export" \
-H "Content-Type: application/json" \
-d '{
"topic": "AI-Trends-2025",
"urls": [
"https://blog.google/technology/ai/",
"https://openai.com/blog/"
],
"platforms": ["twitter", "linkedin", "facebook"],
"export_format": "excel"
}' \
--output AI-Trends-2025_social_media.xlsx
```
### 2. Python SDK
```python
from web_summarizer import WebSummarizerAgent
from web_summarizer.topic_aggregator import TopicAggregator
from web_summarizer.spreadsheet_generator import SpreadsheetGenerator
# Initialize
agent = WebSummarizerAgent(gemini_api_key="your_key")
aggregator = TopicAggregator(agent)
spreadsheet_gen = SpreadsheetGenerator()
# Define topic and sources
topic = "AI-Trends-2025"
urls = [
"https://blog.google/technology/ai/",
"https://openai.com/blog/",
"https://www.anthropic.com/news"
]
# Aggregate summaries
result = aggregator.aggregate_topic(
topic=topic,
urls=urls,
platforms=["twitter", "linkedin", "facebook", "instagram"],
max_workers=3
)
# Export to Excel
spreadsheet_gen.generate_excel(
result,
output_path=f"{topic}_social_media.xlsx"
)
```
### 3. JavaScript/Browser
```javascript
const response = await fetch('http://localhost:8000/aggregate-topic/export', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
topic: 'AI-Trends-2025',
urls: [
'https://blog.google/technology/ai/',
'https://openai.com/blog/'
],
platforms: ['twitter', 'linkedin', 'facebook'],
export_format: 'csv'
})
});
// Download the file
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'AI-Trends-2025_social_media.csv';
a.click();
```
## API Endpoints
### POST /aggregate-topic
Aggregate summaries and generate social media posts.
**Request:**
```json
{
"topic": "string",
"urls": ["string"],
"platforms": ["twitter", "linkedin", "facebook", "instagram"],
"max_workers": 5
}
```
**Response:**
```json
{
"success": true,
"data": {
"topic": "AI-Trends-2025",
"total_sources": 3,
"successful_summaries": 3,
"failed_summaries": 0,
"platforms": ["twitter", "linkedin", "facebook", "instagram"],
"generated_at": "2025-11-08T10:00:00Z",
"data": [
{
"source_url": "https://example.com",
"title": "Article Title",
"category": "Technology",
"summary": "Summary text...",
"key_points": "Point 1; Point 2; Point 3",
"twitter_post": "Tweet content...",
"twitter_hashtags": "#AI #Tech",
"twitter_chars": 280,
"linkedin_post": "LinkedIn post...",
"linkedin_hashtags": "#AI #Technology",
"linkedin_chars": 500,
...
}
]
}
}
```
### POST /aggregate-topic/export
Aggregate and export to downloadable spreadsheet.
**Request:**
```json
{
"topic": "string",
"urls": ["string"],
"platforms": ["twitter", "linkedin", "facebook"],
"export_format": "csv" // or "excel"
}
```
**Response:**
Downloadable CSV or Excel file
## Spreadsheet Output
The generated spreadsheet includes:
### Columns
- **source_url** - Original article URL
- **title** - Article title
- **category** - Content category
- **summary** - AI-generated summary
- **key_points** - Semicolon-separated key insights
- **{platform}_post** - Social media post content
- **{platform}_hashtags** - Platform-specific hashtags
- **{platform}_chars** - Character count
- **word_count** - Summary word count
- **tokens_used** - AI tokens consumed
- **processing_time_ms** - Processing duration
- **timestamp** - When processed
### Excel Features
- Color-coded headers
- Auto-adjusted column widths
- Text wrapping for posts
- Separate metadata sheet
- Frozen header row
- Professional formatting
## Platform-Specific Posts
### Twitter/X (280 chars)
```
{First key point or concise summary}
https://example.com/article
#AI #Tech #Innovation
```
### LinkedIn (3000 chars)
```
📊 AI Trends 2025: Article Title
{Full summary paragraph}
Key Insights:
1. First key point
2. Second key point
3. Third key point
Read more: https://example.com
#AI #Technology #Innovation #Business #DigitalTransformation
```
### Facebook (~500 chars)
```
💡 Article Title
{Summary paragraph}
✨ Highlights:
• First key point
• Second key point
• Third key point
🔗 https://example.com
#AI #Tech #Innovation
```
### Instagram (2200 chars)
```
{Summary paragraph}
✨ Key takeaways:
📌 First key point
💡 Second key point
🎯 Third key point
#AI #Tech #Innovation #Technology #DigitalTransformation #MachineLearning
... (up to 30 hashtags)
```
## Configuration
### Platforms
Available platforms:
- `twitter` - Twitter/X (280 char limit)
- `linkedin` - LinkedIn (3000 char limit, professional tone)
- `facebook` - Facebook (optimized for ~500 chars)
- `instagram` - Instagram (2200 char limit, up to 30 hashtags)
### Concurrent Workers
- `max_workers`: 1-10 (default: 5)
- Higher values = faster processing
- Limited by API rate limits
### Export Formats
- `csv` - Comma-separated values (universal compatibility)
- `excel` - Microsoft Excel with formatting (.xlsx)
## Examples
### Example 1: Tech News Roundup
```python
topic = "Weekly-Tech-News"
urls = [
"https://techcrunch.com/latest/",
"https://www.theverge.com/tech",
"https://arstechnica.com/"
]
result = aggregator.aggregate_topic(topic, urls, platforms=["twitter", "linkedin"])
spreadsheet_gen.generate_excel(result, "tech_news_week.xlsx")
```
### Example 2: Competitor Analysis
```python
topic = "Competitor-Product-Launches"
urls = [
"https://competitor1.com/blog/new-product",
"https://competitor2.com/news/launch",
"https://competitor3.com/updates"
]
result = aggregator.aggregate_topic(topic, urls, platforms=["linkedin", "facebook"])
spreadsheet_gen.generate_csv(result, "competitor_analysis.csv")
```
### Example 3: Industry Research
```python
topic = "Climate-Tech-Innovations"
urls = [
"https://example.com/climate-article-1",
"https://example.com/climate-article-2",
"https://example.com/climate-article-3"
]
result = aggregator.aggregate_topic(
topic,
urls,
platforms=["twitter", "linkedin", "facebook", "instagram"],
max_workers=2
)
# Export both formats
spreadsheet_gen.generate_csv(result, "climate_tech.csv")
spreadsheet_gen.generate_excel(result, "climate_tech.xlsx")
```
## Workflow Example
1. **Research Phase**: Find relevant blog posts/articles on your topic
2. **Aggregate**: Run topic aggregation with all URLs
3. **Review**: Open Excel file, review summaries and posts
4. **Edit**: Fine-tune posts if needed directly in spreadsheet
5. **Schedule**: Use spreadsheet to schedule posts on social media platforms
6. **Track**: Keep spreadsheet for content calendar tracking
## Performance
- **Speed**: 3-5 seconds per URL (with Gemini Flash)
- **Concurrent**: Processes multiple URLs in parallel
- **Cost**: ~$0.01 per 1000 URLs (with Gemini Flash)
- **Success Rate**: 95%+ on standard blog posts
## Error Handling
Failed URLs are tracked separately:
```json
{
"total_sources": 5,
"successful_summaries": 4,
"failed_summaries": 1
}
```
Spreadsheet only includes successful summaries. Check response for failure details.
## Dependencies
```bash
pip install openpyxl>=3.1.0 # For Excel export
```
(CSV export has no additional dependencies)
## Tips
1. **Topic Naming**: Use descriptive, kebab-case names (e.g., `AI-Trends-2025`)
2. **URL Selection**: Choose authoritative, well-structured sources
3. **Platform Mix**: Start with 2-3 platforms, expand as needed
4. **Batch Size**: Keep to 5-10 URLs per batch for best performance
5. **Review Posts**: Always review generated posts before publishing
6. **Custom Hashtags**: Edit hashtags in spreadsheet for brand consistency
7. **Content Calendar**: Use timestamp column for scheduling
8. **A/B Testing**: Generate multiple versions with different platforms
## Advanced Usage
### Custom Post Templates
Extend `TopicAggregator` to customize post formats:
```python
class CustomAggregator(TopicAggregator):
def _generate_twitter_post(self, summary, key_points, url, hashtags):
# Your custom template
return f"🔥 {key_points[0]}\n\n{url}\n\n{' '.join(hashtags[:2])}"
```
### Filter by Category
Post-process results to filter by category:
```python
result = aggregator.aggregate_topic(topic, urls, platforms=["twitter"])
# Filter only "Technology" category
tech_only = {
**result,
"data": [r for r in result["data"] if r["category"] == "Technology"]
}
spreadsheet_gen.generate_excel(tech_only, "tech_only.xlsx")
```
### Merge Multiple Topics
Combine results from multiple topics:
```python
topic1_result = aggregator.aggregate_topic("AI", urls1, platforms=["twitter"])
topic2_result = aggregator.aggregate_topic("ML", urls2, platforms=["twitter"])
combined = {
"topic": "AI-and-ML",
"data": topic1_result["data"] + topic2_result["data"],
...
}
spreadsheet_gen.generate_excel(combined, "combined.xlsx")
```
## Troubleshooting
**Excel file won't open**
- Ensure openpyxl is installed: `pip install openpyxl`
- Check file permissions
**Posts too long**
- Platform limits are automatically enforced
- Content is truncated with "..."
**Missing hashtags**
- Hashtags are auto-generated from topic keywords
- Customize in spreadsheet after export
**Slow processing**
- Reduce `max_workers` if hitting rate limits
- Process in smaller batches
## Swagger Docs
Interactive API documentation: **http://localhost:8000/docs**
Test the endpoints directly in your browser!
---
**Ready to create amazing social media content from any topic!** 🚀
Comprehensive list of features and capabilities in TakeMachine.
**Last Updated:** December 2025
You will be responsible to make the
agent_type: social-media