An automated Twitter bot that generates and posts professional tweets based on trending tech news. The bot uses AI to create content focused on technology, entrepreneurship, and innovation.
- AI-Generated Content: Uses Google's Gemini 2.0 Flash model to create professional tweets
- News Integration: Automatically fetches recent news from trusted sources
- Custom Persona: Tweets can be customized to reflect your professional persona
- Automated Posting: Directly posts to Twitter using the Twitter API
- Content Filtering: Ensures content is relevant and tweet-worthy
- Node.js (v14 or higher)
- Twitter Developer Account with API credentials
- Google API Key for Gemini AI
- Google Custom Search Engine ID
-
Clone the repository:
git clone https://github.com/yourusername/twitter-ai-bot.git cd twitter-ai-bot -
Install dependencies:
npm install -
Create a
.envfile in the root directory with the following variables:# Twitter API Credentials TWITTER_API_KEY=your_twitter_api_key TWITTER_API_SECRET=your_twitter_api_secret TWITTER_ACCESS_TOKEN=your_twitter_access_token TWITTER_ACCESS_TOKEN_SECRET=your_twitter_access_token_secret # Google Custom Search API Credentials GOOGLE_API_KEY=your_google_api_key GOOGLE_CSE_ID=your_google_cse_id # Gemini AI API Key GEMINI_API_KEY=your_gemini_api_key
Run the bot with the following command:
node index.js
The bot will:
- Fetch relevant news about startup funding, AI, tech policy, etc.
- Generate a professional tweet using Gemini AI
- Post the tweet to Twitter
The project includes Docker support for containerized deployment:
-
Build the Docker image:
docker build -t twitter-ai-bot . -
Run the container:
docker run --env-file .env twitter-ai-bot
index.js- Main application entry pointsystem_prompt.js- Contains the AI system prompt configurationtools.js- Contains utility functions for news fetching and tweet posting.env- Environment variables for API keys and configurationDockerfile- Docker configuration for containerization
The bot can be customized by modifying:
- The keywords in
tools.jsto change the news topics - The system prompt in
system_prompt.jsto adjust the tweet style and persona - The trusted domains in
tools.jsto change news sources
- Keep your
.envfile secure and never commit it to version control - Regularly rotate your API keys
- Monitor API usage to avoid hitting rate limits
ISC
This bot is intended for professional use and should adhere to Twitter's terms of service and API usage guidelines.