This is a Instagram/Twitter bot that generates and posts/tweets developer quotes along with an image based on the description provided by the quote.
- OpenAI API
- Google Cloud Functions
- Google Cloud Scheduler
- Google Cloud Pub/Sub
- Google Cloud Storage
- MongoDB
- Python
- Python 3.6 or higher
- A Instagram business account
- A Meta account
- A Meta page linked to Instagram business account
- A Twitter Developer account with API keys and access tokens
- An OpenAI API key
- A MongoDB database
To set up this project locally, you will need to:
-
Clone this repository:
git clone https://github.com/monproweb/dev-wisdom-daily.git
-
Install the required packages using pip:
pip install -r requirements.txt
-
Set the necessary environment variables:
TWITTER_API_KEY
(Follow the official documentation to create a Twitter Developer account and obtain API keys and access tokens)TWITTER_API_SECRET
TWITTER_ACCESS_TOKEN
TWITTER_ACCESS_TOKEN_SECRET
BEARER_TOKEN
OPENAI_API_KEY
(Follow the official documentation to obtain an OpenAI API key)TWITTER_ACCOUNT
(Set this to the username of the Twitter account you want to use for posting the tweets, e.g., "@DevWisdomDaily")MONGODB_USERNAME
MONGODB_PASSWORD
FACEBOOK_ACCESS_TOKEN
INSTAGRAM_USER_ID
GOOGLE_APPLICATION_CREDENTIALS
-
Deploy the function to Google Cloud Functions using the following command:
gcloud functions deploy trigger_tweet \ --runtime python311 \ --trigger-resource devwisdomdaily_tweet \ --trigger-event google.pubsub.topic.publish \ --entry-point trigger_tweet \ --env-vars-file .env.json
-
Create a topic in Google Cloud Pub/Sub
-
Create a subscription for the topic
-
Create a Cloud Scheduler job to trigger the function with a Pub/Sub target
Once the project is set up, the bot will automatically tweet/post a new developer quote with an image at the specified intervals set up in the Cloud Scheduler job.
Contributions are welcome! If you find a bug or have a feature request, please open an issue. If you want to contribute code, please fork the repository and create a pull request.
Threads with official Graph API
This project is licensed under the GNU General Public License v3.0.