Social Media Automation workflow using Motia
A streamlined content generation agent built with Motia that transforms articles into engaging Twitter threads and LinkedIn posts using AI.
We use the following tech stack:
- Motia as the unified backend framework
- Firecrawl to scrape web content
- Ollama for serving Deepseek-R1 locally
🎯Overview
Workflow
Our workflow consists of 4 main steps:-
API → Scrape → Generate → Schedule- API: Receives article URL via POST request
- Scrape: Extracts content using Firecrawl in markdown format
- Generate: Creates Twitter & LinkedIn content using Deepseek-R1
- Schedule: Saves content as drafts in Typefully for review
🛠️ Setup
Prerequisites
- Node.js 18+
- Python 3.x
- API keys for:
- Firecrawl
- Typefully
Installation
Install Ollama:
bash# Setting up Ollama on linux curl -fsSL https://ollama.com/install.sh | sh # Pull the Deepseek-R1 model ollama pull deepseek-r1Install project dependencies:
bashnpm install or pnpm installConfigure environment:
bashcp .env.example .env # Edit .env with your API keysor Create a
.envfile in the root directory with the following variables:bashFIRECRAWL_API_KEY=your_firecrawl_api_key TYPEFULLY_API_KEY=your_typefully_api_keyStart the development server:
bashnpm run dev
🚀 Usage
Generate Content
Send a POST request to trigger content generation:
curl -X POST http://localhost:3000/generate-content \\
-H "Content-Type: application/json" \\
-d '{"url": "https://example.com/article"}'Response:
{
"message": "Content generation started",
"requestId": "req_123456",
"url": "https://example.com/article",
"status": "processing"
}View Results
After processing completes:
- Visit Typefully
- Review your generated Twitter thread and LinkedIn post
- Edit if needed and publish!
📁 Project Structure
social-media-automation/
├── steps/
│ ├── api.step.py # API endpoint handler
│ ├── scrape.step.py # Firecrawl integration
│ ├── generate-linkedin.step.py # Ollama Linkedin generation
│ ├── generate-twitter.step.py # Ollama Twitter generation
│ ├── schedule-twitter.step.ts # Twitter Typefully scheduling
│ └── schedule-linkedin.step.ts # LinkedIn Typefully scheduling
├── prompts/
│ ├── twitter-prompt.txt # Twitter generation prompt
│ └── linkedin-prompt.txt # LinkedIn generation prompt
├── config/
│ └── index.js # Configuration management
├── package.json
├── motia-workbench.json
├── requirements.txt
└── README.md🔍 Monitoring
The Motia workbench provides an interactive UI where you can easily deb ug and monitor your flows as interactive diagrams. It runs automatically with the development server.
📬 Stay Updated with Our Newsletter!
Get a FREE Data Science eBook 📖 with 150+ essential lessons in Data Science when you subscribe to our newsletter! Stay in the loop with the latest tutorials, insights, and exclusive resources. Subscribe now!
