Public
Like
farcaster-autoPostToX
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
This Val Town script automatically cross-posts your Farcaster casts to Twitter/X using webhooks.
- ✅ Automatic cross-posting from Farcaster to Twitter
- ✅ Image support by uploading natively to Twitter (farcaster has 2 media limit per post)
- ✅ Video support (popular hosting video URLs auto-unfurl on Twitter)
- ✅ URL preservation in posts
- ✅ Character limit validation (280 char limit)
- ✅ Error handling and logging
- ✅ Skips replies to avoid spam
- Fork this Val Town script to your account
- Note your Val's URL (you'll need this for the Neynar webhook setup)
- Go to Twitter Developer Portal
- Create a developer account if you don't have one
- Create a new app/project
Before generating your access tokens, you must configure user authentication:
- In your Twitter app settings, go to "User authentication settings"
- Set up OAuth 1.0a with Read and Write permissions
- Add your website URL and callback URL (can be placeholder URLs)
- Save the settings
After setting up authentication with read/write permissions:
- Go to "Keys and Tokens" tab
- Generate/copy these credentials:
- API Key (
TWITTER_API_KEY
) - API Secret (
TWITTER_API_SECRET
) - Access Token (
TWITTER_ACCESS_TOKEN
) - Access Token Secret (
TWITTER_ACCESS_TOKEN_SECRET
)
- API Key (
Note: Free plan limits: 100 posts read + 500 writes per month
In your Val Town script, add these environment variables:
TWITTER_API_KEY
TWITTER_API_SECRET
TWITTER_ACCESS_TOKEN
TWITTER_ACCESS_TOKEN_SECRET
- Go to Neynar Webhook Setup
- Create a new webhook with these settings:
- Event Type:
cast.created
- Target URL: Your Val Town script URL (e.g.,
https://yourname-scriptname.web.val.run
) - Filter: Configure to only receive your own casts (set your username)
- Event Type:
Note: Neynar webhooks require a paid plan
Check the Val Town logs if posts aren't appearing on Twitter:
- Verify all environment variables are set
- Ensure Twitter API keys have read/write permissions
- Check that webhook URL is correctly configured in Neynar
- Verify your Neynar webhook is active and properly filtered