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
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
- Node.js 18+
- Python 3.x
- API keys for:
- Firecrawl
- Typefully
-
Install Ollama:
# Setting up Ollama on linux curl -fsSL https://ollama.com/install.sh | sh # Pull the Deepseek-R1 model ollama pull deepseek-r1
-
Install project dependencies:
npm install or pnpm install
-
Configure environment:
cp .env.example .env # Edit .env with your API keysor Create a
.envfile in the root directory with the following variables:FIRECRAWL_API_KEY=your_firecrawl_api_key TYPEFULLY_API_KEY=your_typefully_api_key
-
Start the development server:
npm run dev
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"
}After processing completes:
- Visit Typefully
- Review your generated Twitter thread and LinkedIn post
- Edit if needed and publish!
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
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.
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!
Contributions are welcome! Please fork the repository and submit a pull request with your improvements.
