Building an AI Social Media Agent

Building an AI Social Media Agent

Generic AI writing tools produce copy in nobody’s voice, so every draft needs heavy editing before it can go out. A social media agent closes that gap by learning your voice first: it scrapes your best-performing historical posts, analyzes the style, stores that profile permanently, and drafts and publishes in it — so the output stays on-brand without a rewrite each time.

The stack

Four tools, one per phase of the workflow.

Component Tool Role Why it’s here
Language model Nebius AI Analyzes and generates text. Access to several high-performance models at efficient compute cost.
Data ingestion ScrapeGraph (SGAI) AI-powered web scraping. Extracts post history dynamically, avoiding brittle CSS-selector scraping.
Execution Composio API integration and posting. Handles OAuth and rate limits for platforms like Twitter/X.
Memory Memori Stores the style profile. Retains tone and voice across sessions without re-analyzing every time.

The workflow

1. Ingest. The user supplies a target handle. ScrapeGraph navigates to the profile and extracts the text of the most popular posts — around the top ten viral posts is usually enough of a baseline to replicate a style reliably.

2. Analyze and store. Nebius AI examines the posts across tone, formatting, vocabulary, and cadence, producing a voice profile. Memori persists that profile so the agent carries the same voice into every future session.

3. Generate and post. When the operator gives a new topic, the agent pulls the stored profile from Memori, Nebius AI drafts a post matching that voice, and — once approved — Composio publishes it live via API.

Implementation

Keep API keys in a .env file; never hardcode them.

# Nebius AI Configuration
NEBIUS_API_KEY=your_nebius_api_key

# ScrapeGraph Configuration
SGAI_API_KEY=your_scrapegraph_api_key

# Composio Twitter Integration
COMPOSIO_API_KEY=your_composio_api_key
TWITTER_AUTH_CONFIG_ID=your_twitter_auth_config_id
USER_ID=your_unique_user_identifier

Install dependencies via requirements.txt or a modern manager like uv:

  • streamlit — user interface
  • composio — API execution
  • langchain-scrapegraph — data ingestion
  • memorisdk — persistent memory
  • langchain-nebius — LLM orchestration

Split the logic into three modules:

  1. app.py — the Streamlit dashboard the operator drives.
  2. twitter_agents.py — core logic: ScrapeGraph ingestion, Nebius analysis, Memori storage.
  3. create_tweet.py — the execution script that connects Composio to the account and posts.

Why it matters

Delegating the drafting and posting turns the operator’s job from tactical to strategic — you set topics and approve, the agent handles the rest. And because the voice profile lives in Memori, the same profile and Composio integration can be pointed at other text-heavy channels — LinkedIn, Instagram — once the core pipeline is stable, without re-learning the voice from scratch.

This entry was posted in . Bookmark the permalink.