This Twitter bot project posts daily dad jokes on Twitter using Node.js and the Twitter API v2. It retrieves jokes from the Dad Jokes API through RapidAPI and schedules the daily posting using Firebase Cloud Functions with Pub/Sub.
- Daily posting: The bot automatically tweets a new dad joke every day.
- Dad Jokes API integration: Jokes are fetched from the Dad Jokes API via RapidAPI.
- Firebase Cloud Functions: The bot uses Firebase Cloud Functions to handle the scheduling and execution of the daily tweet.
- Pub/Sub: The bot leverages Pub/Sub functionality to trigger the daily tweet at the scheduled time.
Before running the bot, make sure you have the following:
- Node.js installed on your machine.
- A RapidAPI account and an API key for the Dad Jokes API.
- A Twitter Developer account with API keys and access tokens.
- A Firebase project set up with Cloud Functions and Pub/Sub enabled.
- The necessary dependencies installed (listed in the project's
package.json
file).
- Clone the repository and navigate to the project directory.
- Install the project dependencies by running
npm install
. - Set up your environment variables. Create a
.env
file and populate it with the necessary API keys, access tokens, and other configuration variables. Refer to the.env.example
file for the required variables. - Configure the Firebase project. Ensure that you have the Firebase CLI installed, and use the CLI to set up your project and deploy the Cloud Functions.
- Set up the Pub/Sub schedule. Use the Firebase CLI or the Firebase console to configure the Pub/Sub schedule to trigger the daily tweet function at the desired time.
- Run the bot locally: Use the command
firebase serve
to start the local development server. This will allow you to test and verify the bot's functionality. - Deploy the bot: Use the command
firebase deploy
to deploy the bot to Firebase and make it accessible online. - Monitor the bot: Check the Firebase logs and console for any errors or information related to the bot's execution and scheduling.