Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Twitter Post Action Implementation #1422

Merged
merged 6 commits into from
Dec 27, 2024

Conversation

0xPBIT
Copy link
Contributor

@0xPBIT 0xPBIT commented Dec 24, 2024

Relates to:

N/A - Plugin implementation for Twitter posting functionality via action

Risks

Low - This is a new plugin that adds Twitter posting capability. The main risks are:

  • Failed tweets due to rate limiting or authentication issues
  • Potential for tweets that are too long (mitigated by automatic truncation)
  • No risk to existing functionality as this is an isolated plugin

Background

What does this PR do?

Adds a Twitter plugin that enables posting tweets through the agent-twitter-client package. Key features:

  • Implements POST_TWEET action for sending tweets
  • Handles Twitter authentication via environment variables
  • Automatically truncates tweets that exceed character limits
  • Provides detailed error handling and logging
  • Supports dry run mode for testing

What kind of change is this?

Features (non-breaking change which adds functionality)

  • Adds new Twitter posting capability
  • Uses the standalone agent-twitter-client package
  • Implements proper error handling and character limit enforcement

Documentation changes needed?

My changes require a change to the project documentation:

  • Add Twitter plugin setup instructions
  • Document required environment variables:
    • TWITTER_USERNAME
    • TWITTER_PASSWORD
    • TWITTER_EMAIL
    • TWITTER_DRY_RUN (optional)
    • TWITTER_2FA_SECRET (optional)

Testing

Where should a reviewer start?

  1. Review packages/plugin-twitter/src/actions/post.ts for the main implementation
  2. Check error handling in postTweet function
  3. Review tweet composition logic in composeTweet function
  4. Verify environment variable handling

Detailed testing steps

  1. Set up environment variables in .env:
TWITTER_USERNAME=your_username
TWITTER_PASSWORD=your_password
TWITTER_EMAIL=your_email
TWITTER_DRY_RUN=false
  1. Test tweet posting:
# Start with dry run mode
TWITTER_DRY_RUN=true pnpm dev

# Test actual posting
TWITTER_DRY_RUN=false pnpm dev
  1. Verify error handling:
  • Try posting a tweet > 180 characters (should truncate)
  • Try posting with invalid credentials (should show error)
  • Try posting with missing credentials (should validate)
  1. Check logging:
  • Verify credential validation logs
  • Check tweet content generation logs
  • Verify error messages are descriptive

Deploy Notes

  • Requires agent-twitter-client package
  • Environment variables must be set for Twitter authentication
  • No database changes required

@0xPBIT
Copy link
Contributor Author

0xPBIT commented Dec 24, 2024

Several people have commented in the discord coders chat about twitter functionality from an action instead of the hard coded client loop. I've opened this PR just to show an example of how this can be done.

This is a small demo where I workshop a tweet with c3po agent to come up with a tweet. Then I can say "go tweet that" and the agent will put it on their twitter profile -- without using the client-twitter package.

Screenshot 2024-12-23 at 9 50 22 PM Screenshot 2024-12-23 at 9 51 14 PM

@shakkernerd shakkernerd changed the title Twitter Post Action Implementation feat: Twitter Post Action Implementation Dec 24, 2024
Copy link
Collaborator

@monilpat monilpat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work thanks for doing this please address comments

packages/plugin-twitter/src/actions/post.ts Outdated Show resolved Hide resolved
packages/plugin-twitter/src/actions/post.ts Outdated Show resolved Hide resolved
packages/plugin-twitter/src/actions/post.ts Outdated Show resolved Hide resolved
packages/plugin-twitter/src/actions/post.ts Outdated Show resolved Hide resolved
packages/plugin-twitter/src/actions/post.ts Outdated Show resolved Hide resolved
packages/plugin-twitter/src/actions/post.ts Show resolved Hide resolved
@odilitime odilitime added the Plugin_new Mark PRs that are a new plugin label Dec 25, 2024
@0xPBIT
Copy link
Contributor Author

0xPBIT commented Dec 25, 2024

thanks for the review @monilpat this is my first time opening a PR so I'll address the changes.

@0xPBIT 0xPBIT requested a review from monilpat December 25, 2024 23:06
@shakkernerd shakkernerd merged commit cb1f21b into elizaOS:develop Dec 27, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Plugin_new Mark PRs that are a new plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants