Building a Social AI Agent in 15 Minutes
In this tutorial, you'll learn how to quickly build your own social media AI agent that can autonomously post tweets, respond to interactions, and maintain its own unique personality. We'll be using the Eliza framework by a16z and TypeScript.
Video: https://youtu.be/6PZVwNTl5hI?si=0zB3OvYU4KiRQTxI
Prerequisites​
- Basic TypeScript knowledge
- Twitter Developer account
- (Optional) Anthropic API key
Project Setup​
-
Clone the Eliza repo and check out the latest version:
git clone https://github.com/elizaOS/eliza.git
cd eliza
git checkout <latest-tag> -
Install dependencies:
pnpm install
pnpm build
Environment Variables​
-
Copy
.env.exampleto.env:cp .env.example .env -
Open
.envand set your Twitter credentials. You can use username/password or cookies. -
(Optional) Set your Anthropic API key for the Claude model.
-
For Gaia, set:
MODEL_LLM_API_URL=https://modelserverurl/
MODEL_EMBEDDING_MODEL=embeddingmodel
MODEL_EMBEDDING_ENABLED=true
Customizing Your Character​
-
Create
agent/mainCharacter.ts:import { DefaultCharacter } from "./defaultCharacter";
import { clients } from "../globalClients";
export const mainCharacter = {
...DefaultCharacter,
clients: { twitter: clients.twitter },
modelProvider: modelProviders.anthropic
}; -
Extend the character by overriding properties like
name,bio,systemPromptetc. -
In
src/index.ts, importmainCharacterand replace instances ofDefaultCharacterwith it.
Running the Agent​
-
Run
pnpm start -
The agent will post a tweet and start listening for replies. Test it out by replying to the tweet.
Gaia Model Setup​
-
In
mainCharacter.ts, change the model provider:modelProvider: modelProviders.gaiaNet -
Customize the
systemPromptandbiofor the new personality. -
Delete the SQLite DB at
data/sqlite.dbto reset tweet history. -
Run
pnpm startagain to see the updated agent in action!
Next Steps​
- Try integrating other extensions like databases, Discord, Telegram
- Add on-chain capabilities with EVM, Solana, StarkNet adapters
- Chat with your agent directly in the terminal