CasterAgents.ps1 is a PowerShell script that creates an AI-driven agent for Farcaster. It automates interactions like replying to mentions, liking posts, recasting, quote casting, following users, and posting to channels—all powered by the Neynar API v2 and OpenAI. This README makes it easy to get started and customize your agent.
Your agent will:
- Reply to mentions with smart, AI-generated responses.
- Like, recast, and quote cast posts.
- Follow users who interact with it (won’t follow itself).
- Post to your chosen channel every 20 minutes.
- Engage with trending posts, keyword-specific posts, and random channels.
- Promote your custom ticker (e.g.,
$yourticker) subtly in replies and posts.
- PowerShell: Installed on your computer (comes with Windows; available for macOS/Linux).
- Internet: Needed for API calls.
- Credentials: You’ll need a Signer UUID, Neynar API Key, OpenAI API Key, and your Farcaster FID.
Download CasterAgents.ps1 and save it in a folder (e.g., C:\FarcasterAgent).
The script has hardcoded placeholders that you must replace with your real credentials. Open CasterAgents.ps1 in a text editor (like Notepad) and find this section near the top:
# Credentials (hardcoded; move to .env for production)
$farcasterSignerUuid = "your_signer_uuid" # @your signer UUID
$neynarApiKey = "your_neynar_api_key" # Neynar API Key
$openaiApiKey = "your-openai-key" # OpenAI API Key
$channel = [System.Environment]::GetEnvironmentVariable("CHANNEL")
if (-not $channel) {
$channel = "/yourchannel" # Default primary channel
}
$fid = "yourFID" # Your FID (avoid self-interaction)Replace the placeholders:
your_signer_uuid→ Your Farcaster Signer UUID.your_neynar_api_key→ Your Neynar API Key.your-openai-key→ Your OpenAI API Key.yourFID→ Your Farcaster FID (a number identifying your account)./yourchannel→ Your preferred channel (e.g.,/myagentchannel), or leave it as is.
Example:
$farcasterSignerUuid = "123e4567-e89b-12d3-a456-426614174000"
$neynarApiKey = "NEYNAR_API_abc123"
$openaiApiKey = "sk-xyz789"
$channel = [System.Environment]::GetEnvironmentVariable("CHANNEL")
if (-not $channel) {
$channel = "/myagentchannel"
}
$fid = "12345"Save the file after updating.
Optional: Use a .env File
For better security (especially in production), create a .env file in the same folder as the script and add:
SIGNER_UUID=your_signer_uuid
NEYNAR_API_KEY=your_neynar_api_key
OPENAI_API_KEY=your_openai_key
FID=yourFID
CHANNEL=/yourchannel
The script will load these automatically if present. Update the script to remove hardcoded values if you use this method.
You have two options:
- Right-click
CasterAgents.ps1. - Select "Run with PowerShell".
- A terminal window will open, and your agent will start working!
- Open PowerShell:
- Windows: Press
Win + R, typepowershell, and hit Enter. - macOS/Linux: Open your terminal and type
pwsh.
- Windows: Press
- Navigate to the script’s folder:
(Replace
cd C:\FarcasterAgent
C:\FarcasterAgentwith your folder path.) - Run the script:
.\CasterAgents.ps1
- Watch your agent come to life!
The script runs continuously, checking for new interactions every 5 minutes and posting every 20 minutes if there’s no urgent task.
Want to tweak your agent? Here’s how:
Your agent posts about random topics every 20 minutes. Edit this section in the script:
# Topics for regular posts every 20 minutes
$topics = @(
"Decentralized Science", "World Statistics", "AGI and ASI advancements", "Quantum Engineering",
"Human Milestones and Guinness World Records", "Facts about World Wars",
"Philosophy and its modern interpretations", "Plasmoids and Non-Carbon Lifeforms",
"Carbon-Based Lifeforms", "Psychedelics and Cognitive Expansion",
"Advanced Cryptography and Blockchain Security", "BRICS Economic Strategies",
"Geographic Data Insights", "Global Myths and Ancient Technologies",
"Underwater Discoveries and Unknown Ecosystems", "Mathematical Algorithms and Pure Math Breakthroughs",
"Cutting-Edge News from Global Networks", "Quantum Mechanics and its Applications",
"Philosophy of Artificial Intelligence", "American Innovations in Technology and Science"
)Add or remove topics to match your interests. For example:
$topics = @("Gaming", "AI Art", "Crypto News")Search the script for these terms and replace them:
your_agent_name→ Your agent’s name (e.g., "TechBot") in the OpenAI prompt:content = "You are TechBot, an expert Farcaster AI Agent..."
yourticker→ Your ticker to promote (e.g., "$MYCOIN"):content = "...promote '$MYCOIN' subtly."
yourchannel→ Your primary channel (already set in credentials).
Use Ctrl+F in your text editor to find all instances (there may be multiple!).
The script automatically likes, recasts, and follows users based on probabilities (e.g., 50% chance to like). To adjust these, find sections like:
if ((Get-Random -Maximum 100) -lt 50) { Add-CastLike ... }Change 50 to 80 for more likes, or 20 for fewer.
processed_ids.txt: Tracks processed post IDs to avoid repeats.followed_fids.txt: Lists followed user FIDs.
These files grow over time—check them occasionally to ensure they’re working.
- API Costs: OpenAI charges per use. Monitor activity to avoid surprises.
- Rate Limits: The script pauses if it hits API limits (100 calls, then a 5-minute break).
- Errors: If it stops, check the terminal for messages like “Error: FID not set.”
This is open-source! Ask the community or check for updates online.