Skip to content

Latest commit

 

History

History
61 lines (49 loc) · 1.4 KB

README-AL.md

File metadata and controls

61 lines (49 loc) · 1.4 KB

Twitter Chatbot Example

Setup

  1. Clone and Navigate
git clone <repository-url>
cd cdp-agentkit/twitter-langchain/examples/chatbot/
  1. Configure Poetry Environment
# Clear poetry cache
poetry cache clear . --all

# Configure poetry to create virtualenv in project
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true

# Install dependencies
poetry install --no-root

# Add required packages
poetry add tweepy python-dotenv langchain-core langgraph langchain-xai
  1. Configure Twitter API
  • Go to Twitter Developer Portal
  • Create a new app or select existing app
  • Enable OAuth 1.0a and OAuth 2.0
  • Set App permissions to "Read and Write"
  • Select "Web App, Automated App or Bot"
  • Generate/Regenerate all tokens
  1. Set Environment Variables
# Create .env file
cp .env.example .env

# Add your Twitter API credentials to .env
TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET=your_api_secret
TWITTER_ACCESS_TOKEN=your_access_token
TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret
TWITTER_BEARER_TOKEN=your_bearer_token
XAI_API_KEY=your_xai_api_key
  1. Run the Chatbot
poetry run python chatbot.py

modes

  • chat: say anything, and also can support actions such as posting a tweet.
  • auto: ...

Notes

  • Uses Twitter API v2
  • Requires appropriate Twitter Developer Account permissions
  • Built with LangChain and XAI integration