This Val Town script automatically cross-posts your Farcaster casts to Twitter/X using webhooks.
- ✅ Automatic cross-posting from Farcaster to Twitter
- ✅ Image support (farcaster has 2 media limit per post)
- ✅ 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_KEYTWITTER_API_SECRETTWITTER_ACCESS_TOKENTWITTER_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
Currently, this script does not support video uploads to Twitter. Only images are supported for media cross-posting. If your Farcaster cast contains videos, they will be skipped and only the text content will be posted to Twitter.
The script includes comprehensive error handling and logging:
- Failed image downloads: Logged with error details, post continues with text only
- Twitter API errors: Full error response logged for debugging
- Character limit exceeded: Cast is skipped and logged as too long
- Invalid webhook data: Malformed requests are logged and ignored
- Authentication failures: API key issues are logged with specific error messages
All errors are logged to Val Town's console for easy debugging. Check your Val's execution logs if casts aren't appearing on Twitter.
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