Social Media Multi-Posting
Intermediate
ai social-media twitter linkedin automation scheduling frontend

Click to zoom
Social Media Multi-Posting
Generate tailored social media posts with AI, schedule them, and automatically publish to Twitter/X and LinkedIn all from a single workflow.
Social Media Multi-Posting is a full-stack automation that combines AI content generation with a cron-driven scheduler to publish posts to multiple social platforms with minimal effort.
What it does
- AI content generation : Uses OpenAI to craft platform-specific posts for Twitter/X and LinkedIn from a single topic, brand, tone, and audience prompt via
generate-social-content - Scheduling queue : Saves generated posts to a database with a
scheduledAttime andpendingstatus; browse the queue withget-queue - Automated publishing : A cron habit (
check-pending-posts) polls every minute, picks up due posts, and publishes each one in parallel to Twitter/X and LinkedIn viapublish-social-post - Queue management : Instantly publish a post with
publish-post-nowor remove it withdelete-post
Environment variables (.env / keyring on apps)
| Variable | Purpose |
|---|---|
HABITS_OPENAI_API_KEY | OpenAI API key for AI-powered content generation |
HABITS_TWITTER_CLIENT_ID | Twitter/X OAuth 2.0 Client ID |
HABITS_LINKEDIN_CLIENT_ID | LinkedIn OAuth 2.0 Client ID |
HABITS_LINKEDIN_CLIENT_SECRET | LinkedIn OAuth 2.0 Client Secret |
HABITS_LINKEDIN_ORGANIZATION_ID | LinkedIn Company Page / Organization ID |
How to set up
- Copy
.env.exampleto.envand fill in your credentials. - Create a Twitter Developer App with Read and Write permissions and add
http://localhost:13000/oauth/bit-twitter/callbackas the callback URL. - Create a LinkedIn Developer App linked to your Company Page and enable the
w_member_socialandr_basicprofilescopes. - Run
generate-social-contentto create and schedule your first post. check-pending-postsruns automatically on a 1-minute cron and publishes posts when their scheduled time arrives.
Tech stack
- habits framework for workflow orchestration and cron scheduling
- OpenAI for platform-tailored social content generation
- Twitter/X (
@ha-bits/bit-twitter) for tweet publishing via OAuth 2.0 - LinkedIn (
@ha-bits/bit-linkedin) for LinkedIn post publishing via OAuth 2.0 - SQL database (
@ha-bits/bit-database-sql) for post queue storage - Frontend habit for interactive content creation and queue management UI
Run Your .habit File
Run on Mobile
- [ ] Download the Cortex App from store or the downloads page
- [ ] Open the Cortex App on your device
- [ ] Tap "Open Habit" or "+" button
- [ ] Select your
.habitfile from your device storage - [ ] The habit will be loaded and ready to run
Run on Desktop
- [ ] Download the Cortex App for your platform from the downloads page
- [ ] Install and open the Cortex App
- [ ] Click "Open Habit" or drag & drop your
.habitfile - [ ] The habit will be loaded and ready to run
- [ ] Optional: Place a
.envfile in the same directory as your.habitfile to override environment variables
Run on Server
Run your .habit file as a server using the Cortex CLI:
bash
# Install and run in one command
npx @ha-bits/cortex --config ./your-app.habit- [ ] Make sure Node.js 20+ is installed
- [ ] Run the command above with your
.habitfile path - [ ] Server will start on the specified port (default: 3000)
- [ ] Access the app at
http://localhost:3000 - [ ] Optional: Place a
.envfile next to your.habitfile - it will automatically override any embedded environment variables
Run Serverless
For serverless or containerized deployments, we recommend using Docker:
bash
# Using Docker (recommended for serverless)
docker run -p 3000:3000 -v $(pwd)/your-app.habit:/app/habit.habit \
node:20-alpine npx @ha-bits/cortex --config /app/habit.habit --host 0.0.0.0Or create a Dockerfile:
dockerfile
FROM node:20-alpine
WORKDIR /app
COPY your-app.habit ./
COPY .env ./ # Optional: include environment variables
RUN npm install -g @ha-bits/cortex
EXPOSE 3000
CMD ["cortex", "--config", "./your-app.habit", "--host", "0.0.0.0"]- [ ] Create a Dockerfile or use the Docker run command above
- [ ] Deploy to your preferred cloud provider (AWS, GCP, Azure, etc.)
- [ ] Configure environment variables via your cloud provider's secrets management
- [ ] Set up health checks at
/habits/base/apiendpoint
Workflow Visualization
Requirements
- OPENAI_API_KEY (OpenAI API key)
- TWITTER_CLIENT_ID (Twitter/X OAuth 2.0 Client ID)
- LINKEDIN_CLIENT_ID (LinkedIn OAuth 2.0 Client ID)
- LINKEDIN_CLIENT_SECRET (LinkedIn OAuth 2.0 Client Secret)
- LINKEDIN_ORGANIZATION_ID (LinkedIn Company Page / Organization ID)
Quick Start
Run using the Habits CLI wrapper, recommended if you develop local Habits
# First, download the example files
npx habits@latest cortex --config ./social-media-multi-posting/stack.yamlGet in touch
Want this habit running in your environment?
This habit is a starting point. Tell us about your stack and we'll help you get it working exactly the way your team needs.
