• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
project logo

artivilla

farcaster-autoPostToX

automatically cross-posts your Farcaster casts to X
Public
Like
farcaster-autoPostToX
Home
Code
2
README.md
H
index.ts
Branches
3
Pull requests
Remixes
1
History
Environment variables
4
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
6/11/2025
Viewing readonly version of main branch: v21
View latest version
README.md

Farcaster to Twitter/X Cross-Poster

This Val Town script automatically cross-posts your Farcaster casts to Twitter/X using webhooks. When you create a new cast on Farcaster, it gets automatically posted to your Twitter account.

What This Script Does

  • Receives Farcaster webhooks: Listens for cast.created events from Neynar
  • Filters content: Only processes original casts (skips replies/responses)
  • Handles media: Downloads images from Farcaster and uploads them to Twitter
  • Manages text length: Ensures posts stay within Twitter's 280-character limit
  • Cross-posts: Automatically posts your Farcaster content to Twitter/X

Features

  • ✅ Automatic cross-posting from Farcaster to Twitter
  • ✅ Image support (up to 2 images per post)
  • ✅ URL preservation in posts
  • ✅ Character limit validation
  • ✅ Error handling and logging
  • ✅ Skips replies to avoid spam

Setup Instructions

Step 1: Fork This Val

  1. Fork this Val Town script to your account
  2. Note your Val's URL (you'll need this for the webhook setup)

Step 2: Create Twitter Developer Account & API Keys

  1. Go to Twitter Developer Portal
  2. Create a developer account if you don't have one
  3. Create a new app/project

Important: Set Up User Authentication Settings FIRST

Before generating your access tokens, you must configure user authentication:

  1. In your Twitter app settings, go to "User authentication settings"
  2. Set up OAuth 1.0a with Read and Write permissions
  3. Add your website URL and callback URL (can be placeholder URLs)
  4. Save the settings

Generate API Keys

After setting up authentication with read/write permissions:

  1. Go to "Keys and Tokens" tab
  2. 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)

Note: Free plan limits: 100 posts read + 500 writes per month

Step 3: Set Environment Variables

In your Val Town script, add these environment variables:

  • TWITTER_API_KEY
  • TWITTER_API_SECRET
  • TWITTER_ACCESS_TOKEN
  • TWITTER_ACCESS_TOKEN_SECRET

Step 4: Create Neynar Webhook (Paid Plan Required)

  1. Go to Neynar Webhook Setup
  2. 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 FID)

Note: Neynar webhooks require a paid plan

How It Works

  1. You create a cast on Farcaster
  2. Neynar sends a webhook to your Val Town script
  3. The script processes the cast:
    • Skips if it's a reply
    • Downloads any images and uploads them to Twitter
    • Appends non-image URLs to the text
    • Validates character count
  4. Posts the content to Twitter/X automatically

Limitations

  • Twitter Free Plan: 100 reads + 500 writes per month
  • Neynar webhooks require paid subscription
  • Maximum 2 images per post (Farcaster limit)
  • 280 character limit for Twitter posts
  • Only processes original casts (not replies)

Troubleshooting

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

Support

For issues with:

  • Twitter API: Check Twitter Developer Documentation
  • Neynar Webhooks: Check Neynar Documentation
  • Val Town: Check Val Town Documentation
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.