How to Create Your Own Twitter AI Agent
Introduction
Recently, I received a freelance offer to create a Twitter AI Agent. It sounded like a cool experience, so I decided to take on the challenge. I used ElizaOS, a framework built by the ai16z community that makes creating AI Agents much easier. After spending some time with it, I can confidently say that it has great potential. It just needs a bit more polish. Its main focus is to make AI Agent creation super user-friendly. I didn’t have to do much "coding," but a non-programmer might run into some challenges.
One major issue I faced was the new update. Just a few days after I started working with ElizaOS, a major update was pushed. There were tons of guides, videos, and documentation on the old version, but I wanted to use the latest one since it had crucial new tooling. Since there were barely any resources on setting up the new version, I had to figure everything out through trial and error.
In this article, I aim to save you time and make the setup process much easier. I won’t explain the entire ElizaOS framework—it’s massive with tons of tools and use cases. Instead, I'll provide a straightforward starting point, from which you can expand your AI Agent as needed.
Project Initialization
Before cloning the ElizaOS project, make sure you have the following installed:
- Node.js 23+: Download and Install
- pnpm 9+: Installation Guide
- Git
- GitHub CLI
Clone the Repository
There are multiple ways to initialize the project. The following worked best for me:
gh repo clone elizaOS/eliza
or
git clone git@github.com:elizaOS/eliza.git
Navigate into the project directory:
cd eliza
Switch to the development branch:
git checkout develop
Install dependencies:
pnpm install
Build the project:
pnpm build
Handling sqlite3
Errors
If you encounter an error related to sqlite3
during the build process, run the following command and retry the build:
pnpm exec npm rebuild better-sqlite3
If any other issues arise during initialization, check the AI documentation, GitHub issues, or ask for help on their Discord server.
Setup the Environment File
Copy .env.example
to .env
:
cp .env.example .env
Start the Agent (Test Run)
To ensure everything is set up properly, let's run a sample chatbot. There’s already a built-in character sample we can use.
Start the AI Agent:
pnpm start
In a new terminal, start the built-in chat UI:
pnpm start:client
Now navigate to:
http://localhost:5173/
You should see a chatbot interface where you can interact with the default AI Agent.
Create Your Own Character
Creating a character personality file (.json
) hasn't changed much in the new version, so the existing documentation is helpful. The best way to refine your AI Agent’s personality is through trial and error.
Here’s a tool to assist with character creation:
Character examples for reference:
Save your character files in the /characters
folder.
To use your custom AI Agent, start the program with a character flag:
pnpm start --character="characters/myai.character.json"
Download the Twitter Plugin
Adding plugins in ElizaOS is straightforward. Simply run one command and configure your character file.
Here’s the list of official ElizaOS plugins:
- Plugin Registry
- Or run:
npx elizaos plugins list
To install the Twitter plugin:
npx elizaos plugins add @elizaos-plugins/client-twitter
Then, modify your character’s JSON file to enable the plugin:
{
"clients": ["twitter"],
"plugins": ["@elizaos-plugins/client-twitter"]
}
Set Up Your AI Provider
Running your own AI model locally (e.g., DeepSeek) would be great, but AI models require significant resources. Using an external AI provider is usually more practical.
I found Heurist to be the best provider:
- Simple setup
- Affordable
- Accepts crypto payments
- Offers various AI models, including uncensored ones
Steps to Set Up Heurist:
- Sign in to Heurist
- Deposit some credits (even a few cents are enough for testing)
- Generate and copy your API Key
- Add the API Key to your
.env
file:
HEURIST_API_KEY=YourApiKey
Set your preferred AI models:
SMALL_HEURIST_MODEL=deepseek/deepseek-v3
MEDIUM_HEURIST_MODEL=deepseek/deepseek-v3
LARGE_HEURIST_MODEL=deepseek/deepseek-v3
USE_HEURIST_EMBEDDING=true
For custom models, check:
Heurist's Model List
Configure the Twitter Plugin
To enable Twitter integration, set up the required credentials in .env
:
TWITTER_USERNAME=
TWITTER_PASSWORD=
TWITTER_EMAIL=
TWITTER_2FA_SECRET=
Important Tip: Set the Twitter account to "Automated" in the account settings. This informs Twitter that the account is run by code, reducing the risk of being banned.
Optional Twitter Configurations
TWITTER_DRY_RUN=false
TWITTER_POLL_INTERVAL=600
TWITTER_TARGET_USERS=
TWITTER_RETRY_LIMIT=
TWITTER_SEARCH_ENABLE=false
ENABLE_TWITTER_POST_GENERATION=true
POST_INTERVAL_MIN=150
POST_INTERVAL_MAX=300
POST_IMMEDIATELY=false
ENABLE_ACTION_PROCESSING=true
To add a Discord approval system (so the bot doesn’t post anything dumb), create a bot in Discord Developer Portal and add these values:
TWITTER_APPROVAL_DISCORD_CHANNEL_ID=
TWITTER_APPROVAL_DISCORD_BOT_TOKEN=
TWITTER_APPROVAL_ENABLED=true
TWITTER_APPROVAL_CHECK_INTERVAL=1000000
Final Step: Run Your AI Agent
Run your bot with:
pnpm start --character="characters/myai.character.json"
Thanks for reading! I hope this guide was helpful. If you need any assistance, feel free to ask in the comments or DM me!
Top comments (0)