Build your Digital Twin using LazAI

Your Digital Twin is an AI persona that speaks in your voice. We generate it from your Twitter/X archive, store it in a portable Characterfile (character.json), and load it into an Alith agent that writes tweets for you (manually or on a schedule).

Why a Digital Twin?

  • Portable persona: Single JSON file that any LLM agent can use

  • Separation of concerns: Keep style/persona in JSON; keep logic in code

  • Composable: Swap personas without touching the app

Prerequisites

  • macOS/WSL/Linux with Node.js 18+

  • An OpenAI or Anthropic (Claude) API key

  • A Twitter/X account + your archive .zip

Step 0 — Clone the starter kit and install the dependencies

git clone https://github.com/0xLazAI/Digital-Twin-Starter-kit.git

cd Digital-Twin-Starter-kit

Step 1 — Generate your Characterfile from Tweets

  1. Request your archive

    Get it from X/Twitter: Settings → Download an archive.

  2. Run the generator

  • Choose openai or claude

  • Paste your API key when prompted

  • Output: a character.json in the current directory

  1. Move it into the Digital-Twin-Starter-kit Directrory

    Place character.json at your root (same level as index.js), e.g.:

Step 2 — Feed character.json to an Alith Agent

We create an Alith agent at runtime and pass your character as a preamble. This keeps persona separate from code and makes it hot‑swappable.

  • Loads character.json

  • Builds an Alith preamble from bio/lore/style

  • Generates a tweet in your voice

  • Provides postTweet (manual) and autoTweet (cron) helpers

Environment

Install deps:

Step 3 — Auto‑Tweet via Cron (uses your Digital Twin)

We schedule the agent to post automatically (e.g., at minute 5 every hour).

services/cronService.js

index.js (ESM)

Route

Manual test

Updating Your Twin

  • Re‑run npx tweets2character any time you want a fresh persona.

  • Replace character.json and restart your server.

  • The agent will immediately pick up the new style/preamble.

Tips & Gotchas

  • CommonJS + ESM: Alith is ESM, your project is CJS → use dynamic import inside functions (shown above).

  • Length control: We trim to 240 chars to be safe with links/quoted tweets.

  • Fallbacks: If the model isn’t reachable, we fall back to postExamples from your character file.

  • Safety: Add your own guardrails (e.g., profanity, duplicates, rate limits) before posting.

Last updated