|
| 1 | +# Social Media Automation workflow using Motia |
| 2 | + |
| 3 | +A streamlined content generation agent built with [Motia](https://motia.dev) that transforms articles into engaging Twitter threads and LinkedIn posts using AI. |
| 4 | + |
| 5 | +We use the following tech stack: |
| 6 | +- Motia as the unified backend framework |
| 7 | +- Firecrawl to scrape web content |
| 8 | +- OpenAI for agentic capabilities |
| 9 | + |
| 10 | +## 🎯Overview |
| 11 | + |
| 12 | +**Workflow** |
| 13 | + |
| 14 | +Our workflow consists of 4 main steps:- |
| 15 | + |
| 16 | +``` |
| 17 | +API → Scrape → Generate → Schedule |
| 18 | +``` |
| 19 | + |
| 20 | +1. **API**: Receives article URL via POST request |
| 21 | +2. **Scrape**: Extracts content using Firecrawl in markdown format |
| 22 | +3. **Generate**: Creates Twitter & LinkedIn content using OpenAI |
| 23 | +4. **Schedule**: Saves content as drafts in Typefully for review |
| 24 | + |
| 25 | +## 🛠️ Setup |
| 26 | + |
| 27 | +### Prerequisites |
| 28 | + |
| 29 | +- Node.js 18+ |
| 30 | +- Python 3.x |
| 31 | +- API keys for: |
| 32 | + - OpenAI |
| 33 | + - Firecrawl |
| 34 | + - Typefully |
| 35 | + |
| 36 | +### Installation |
| 37 | + |
| 38 | +1. **Install dependencies:** |
| 39 | + ```bash |
| 40 | + npm install or pnpm install |
| 41 | + ``` |
| 42 | + |
| 43 | +3. **Configure environment:** |
| 44 | + ```bash |
| 45 | + cp .env.example .env |
| 46 | + # Edit .env with your API keys |
| 47 | + ``` |
| 48 | + or Create a `.env` file in the root directory with the following variables: |
| 49 | + ```bash |
| 50 | + OPENAI_API_KEY=your_openai_api_key |
| 51 | + FIRECRAWL_API_KEY=your_firecrawl_api_key |
| 52 | + TYPEFULLY_API_KEY=your_typefully_api_key |
| 53 | + ``` |
| 54 | + |
| 55 | +4. **Start the development server:** |
| 56 | + ```bash |
| 57 | + npm run dev |
| 58 | + ``` |
| 59 | + |
| 60 | +## 🚀 Usage |
| 61 | + |
| 62 | +### Generate Content |
| 63 | + |
| 64 | +Send a POST request to trigger content generation: |
| 65 | + |
| 66 | +```bash |
| 67 | +curl -X POST http://localhost:3000/generate-content \\ |
| 68 | + -H "Content-Type: application/json" \\ |
| 69 | + -d '{"url": "https://example.com/article"}' |
| 70 | +``` |
| 71 | + |
| 72 | +**Response:** |
| 73 | +```json |
| 74 | +{ |
| 75 | + "message": "Content generation started", |
| 76 | + "requestId": "req_123456", |
| 77 | + "url": "https://example.com/article", |
| 78 | + "status": "processing" |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +### View Results |
| 83 | + |
| 84 | +After processing completes: |
| 85 | +1. Visit [Typefully](https://typefully.com/drafts) |
| 86 | +2. Review your generated Twitter thread and LinkedIn post |
| 87 | +3. Edit if needed and publish! |
| 88 | + |
| 89 | +## 📁 Project Structure |
| 90 | + |
| 91 | +``` |
| 92 | +social-media-automation/ |
| 93 | +├── steps/ |
| 94 | +│ ├── api.step.ts # API endpoint handler |
| 95 | +│ ├── scrape.step.ts # Firecrawl integration |
| 96 | +│ ├── generate.step.ts # Parallel OpenAI calls |
| 97 | +│ └── schedule.step.ts # Typefully scheduling |
| 98 | +├── prompts/ |
| 99 | +│ ├── twitter-prompt.txt # Twitter generation prompt |
| 100 | +│ └── linkedin-prompt.txt # LinkedIn generation prompt |
| 101 | +├── config/ |
| 102 | +│ └── index.js # Configuration management |
| 103 | +├── package.json |
| 104 | +├── tsconfig.json |
| 105 | +└── README.md |
| 106 | +``` |
| 107 | + |
| 108 | +## 🔍 Monitoring |
| 109 | + |
| 110 | +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. |
| 111 | + |
| 112 | +## 📬 Stay Updated with Our Newsletter! |
| 113 | +**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!](https://join.dailydoseofds.com) |
| 114 | + |
| 115 | +[](https://join.dailydoseofds.com) |
| 116 | + |
| 117 | +--- |
| 118 | + |
| 119 | +## Contribution |
| 120 | + |
| 121 | +Contributions are welcome! Please fork the repository and submit a pull request with your improvements. |
0 commit comments