Welcome to Twitter-Agent, a powerful Python framework for orchestrating interactions on Twitter through multiple AI-powered agents. This innovative tool harnesses facilitates meaningful engagements with the Twitter timeline, posting AI-generated tweets, and fostering dynamic interactions with other users.
Twitter-Agent provides a range of capabilities to interact with Twitter. Its features include:
- Tweeting: Post original content, generated from relevant timeline tweets. ✅ 🤖
- Retweeting: Share tweets that align with your agent's strategy. ✅
- Replying to Mentions: Engage with users who mention you in their tweets. ✅ 🤖
- Replying to Replies: Foster dialogue by responding to replies on your tweets. ✅ 🤖
- Liking Tweets: Agents show appreciation or acknowledgement by liking tweets. ✅
Follow the steps below to embark on your AI-powered Twitter journey with Twitter-Agent!
This guide provides step-by-step instructions on how to install and run the twitter-agent
application.
Ensure that you have python
, pip
, git
, and docker
installed on your machine. The application requires a Python virtual environment and Docker for running Weaviate.
Clone the repository into your local machine by running the following command:
git clone https://github.com/bigsky77/twitter-agent.git && cd twitter-agent
This step is optional, but highly recommended to avoid package conflicts. Run the following command to create a virtual environment named venv
:
python -m venv venv
To activate the virtual environment, run the following command:
source venv/bin/activate
The application dependencies are listed in the requirements.txt file. Install them by running the following command:
pip install -r requirements.txt
Run the following command to copy the contents of .env.example to a new file named .env:
cp .env.example .env
Set your OpenAI and Twitter API keys in your new .env file. Make sure the keys are kept secure and not exposed publicly.
When running multiple Twitter-Agents, the engine reads the access tokens from tokens.yml in order to create multiple Tweepy client instances.
Run the following command to copy the contents of example_tokens.yml to a new file named tokens.yml:
cp example_tokens.yml tokens.yml
Run the following script to get your Access Token and Access Token Secret:
python src/utils/auth.py
This will output an authorization URL in the terminal. Paste this URL into your browser to authorize the application. If the redirect does not provide a pin number, and you encounter a "no connection" error, paste the last string from the new URL into the PIN area. You should see oauth_verifier=dlkProCaCO7x9VFG1E1Yxxxxxxxxxxxxxxx
at the end of the url. Copy and paste everyting after oauth_verifier=
.
Paste the Access Token and Access Token Secret in the tokens.yml file alongside the agent name and strategy.
Weaviate is used to cache tweets. Before running the main script, ensure Weaviate is up and running. This can be achieved by starting a Docker container for Weaviate in the project directory:
sudo docker-compose up -d
Now that your .env file is fully configured, run the agent with the following command:
python src/main.py --run-engine
You can test your agent configuration by running. This will run a strategy but not actually collect any tweets or make any posts. Note: You will have had to run the engine at least once for this to work.
python src/main.py --run-engine --test
Note: You will need to be a subscriber to the Twitter Basic API for the agent to fully function. If you are using the free tier, the agent will only be able to post Tweets and will not interact with the timeline.
That's it! You have now successfully installed and set up the twitter-agent. Happy tweeting!
We love contributions and seek to make contribution as easy as possible. Our goal with this project is to make the worlds-best AGI Twitter agent. If that sounds interesting to you, please reach out!
If you deploy a custom agent using this framework please create a pull-request to add it to the leaderboard!
Note these are all initial prototypes!