TersAI is an AI-powered Twitter bot that automates the process of gathering and sharing news updates in a specific niche. It fetches the latest articles from the web, summarizes them into concise, tweet-sized content using a language model, adapts the writing tone to match a target Twitter profile's style, and then posts the result to Twitter automatically. The goal is to consistently deliver relevant updates in the desired tone to an audience on Twitter.
- Automated Article Fetching: Retrieves the latest news articles via the NewsAPI based on configured topics.
- AI Summarization: Uses a language model to condense each article into a tweetable summary using LangChain and OpenRouter.
- Tone Adaptation: Matches the tweet's tone to a target persona using example tweets or provided tone descriptions.
- Automated Tweet Posting: Posts the generated tweets automatically using Twitter's API.
- Multi-Profile Support: Supports multiple Twitter accounts and configurations using Appwrite as a config store.
-
Clone the Repository & Install Dependencies
git clone https://github.com/iamfaham/TersAI.git cd TersAI pip install -r requirements.txt -
Obtain API Keys
- Twitter API Key, Secret, Access Token, and Access Secret
- NewsAPI Key
- OpenRouter API Key
- Appwrite API Key (if using Appwrite)
-
Configure Environment Variables Create a
.envfile or export variables:APPWRITE_ENDPOINT=<your-appwrite-endpoint> APPWRITE_PROJECT=<your-appwrite-project-id> APPWRITE_API_KEY=<your-appwrite-api-key> APPWRITE_DATABASE_ID=<your-appwrite-database-id> APPWRITE_CONFIG_COLLECTION_ID=<your-config-collection-id> NEWS_API_KEY=<your-newsapi-key> OPENROUTER_API_KEY=<your-openrouter-key>
-
Set Up Appwrite Configuration In Appwrite, create a collection with documents having fields:
X_API_KEYX_API_SECRETX_ACCESS_TOKENX_ACCESS_SECRETTopicsTonePast_tweets(optional)
-
Local
python bot.py
-
GitHub Actions
- Add your secrets to GitHub repository settings.
- Enable the included GitHub Actions workflow in
.github/workflows/run-bot.yml.
TersAI/
├── bot.py # Main script
├── utils.py # Helper functions
├── openrouter_client.py # OpenRouter wrapper for LangChain
├── requirements.txt # Dependencies
└── .github/
└── workflows/
└── run-bot.yml # GitHub Actions workflow
Contributions are welcome! Open an issue to discuss improvements or bugs. Submit pull requests for enhancements.
No license file provided. Use is considered proprietary by default.
Created by Syed Mohammed Faham
GitHub: @iamfaham
Bot live at: @TersXAI on Twitter