Gemini Twitter Bot is an automated solution for posting tweets every hour using dynamic content generated by Google Gemini. This project is built with Encore and integrates seamlessly with the Twitter API using Access Token and Access Token Secret for authentication.
- Automated Tweets: Post tweets at regular intervals without lifting a finger. Gemini generates tweet content based on trending topics and tailored contexts.
- Encore-Powered Efficiency: Leveraging Encore’s microservices framework to streamline the development and deployment of the bot.
- Twitter API Integration: Securely interact with the Twitter API using Access Token and Access Secret for authentication.
- Dynamic Content Generation: Powered by Google Gemini, ensuring every tweet is fresh, funny, and engaging.
- Encore: Make sure Encore is installed by following the instructions at https://encore.dev/docs/install.
- Twitter Developer Account: You’ll need API keys from Twitter. Register for access at https://developer.twitter.com/.
- Gemini API Key: Sign up for Google Gemini and obtain an API key from the Google Cloud Console.
- Create Your Encore App:
encore app create my-twitter-bot --example=gemini-twitter-bot
(Change my-twitter-bot
to whatever name suits your project.)
- Set Your Gemini API Key:
cd my-twitter-bot
encore secret set GeminiAPIKey --type dev,local,pr,prod
When prompted, paste your Gemini API key.
- Add Your Twitter API Credentials:
encore secret set TwitterAPIKey --type dev,local,pr,prod
encore secret set TwitterAPISecret --type dev,local,pr,prod
encore secret set TwitterAccessToken --type dev,local,pr,prod
encore secret set TwitterAccessSecret --type dev,local,pr,prod
Set your Twitter API key, secret, access token, and access token secret.
- Run Your Bot:
encore run
Encore will build and start your app, and you can track its local performance via http://localhost:4000
.
Want to make your bot public? Deploying is simple with Encore:
git push
Encore handles the entire deployment, providing a link to your live app where tweets are posted automatically.
This bot is a microservices-based application designed with multiple services working in sync:
- Twitter Service: Handles Twitter API integration, including posting tweets and retrieving user timelines.
- Gemini Service: Integrates with Google Gemini to generate creative and contextual content.
- Scheduler Service: Ensures the bot posts tweets at regular intervals.
- Tweet Generation: Every hour, the Scheduler Service triggers the Gemini Service to generate a tweet.
- Twitter Authentication: The Twitter Service authenticates using Access Token and Access Token Secret to post tweets.
- Post Tweets: Tweets generated by the Gemini Service are published on Twitter via the Twitter Service.
- Monitor Success: Check the bot's activity and performance via the Encore Dashboard.