Ultimate Guide to Automating Twitter/X Posts with AI
How to Use AI for Automating Your Twitter/X Posts
Everyone wants to become an influencer or at least be active on social media nowadays, but we know it's not easy to plan, create, schedule, and post content every day. It's a headache for most people, and many don't even start their journey to becoming an influencer because of these hurdles. But don't worry, in this blog, I will explain how you can automate your Twitter/X account so that you only need to set it up once, and it will work every day without any intervention. You won't even need to think about content or scheduling. I have tried to make this blog beginner-friendly and easy to understand, and I hope it will help you.
Getting X / Twitter API Keys
Step 1: Visit Twitter Developer.
Step 2: Click on the "Developer Portal".
Step 3: You will need to sign in to your X account using credentials (if not already signed in to X), If you have never used Twitter Developer Portal then you will need to fill out a form mentioning basic details such as your country, name, how will you use Twitter API (this is important, fill it carefully), etc and it will get approved in 24 hours.
Step 4: Once youโve set up the account, you can create the app. Navigate to "Projects and Apps" and under Overview apps click on "Create App".
Step 5: Next name your app. Then click Next. Through this tab, you will find the API Key and the API Secret Key but you don't need to copy it now.
Step 6: Go to the Project you just created (you can see the project name in the left side drawer) and click on the "Edit" option.
Step 7: Make changes as shown in the screenshot below and click on "save".
Step 8: Go to "Keys and Tokens" and click on Regenerate in "API Key and Secret" section then copy and save the shown key and secret, and repeat the same with the "Access Token and Secret" section. (we will use it later)
Getting Gemini AI API Key
Getting Gemini AI API is pretty simple.
Step 1: Log in to the Google AI Studio for the Gemini AI and click "Get API Key".
Step 2: Click "Create API key in new project".
Step 3: Copy your key to your clipboard and save it somewhere. (we"ll need this later)
Setting up the code
You need to have a GitHub account to automate it.
Step 1: Visit this Repository. (https://github.com/VishwaGauravIn/twitter-auto-poster-bot-ai) and click on "Fork".
Step 2: Click on "Create fork".
Step 3: Click on the "SECRETS.js" file and then click on the pencil icon.
Step 4: Click on "Commit changes..." and then a dialogue will open, again click on "Commit Changes"
Step 5: Click on the repository name as shown in the screenshot below, select "I understand my workflows, go ahead and enable them". Click on "Auto Tweet using AI".
Final Step: Click "Enable workflow" and then "Run Workflow".
Bonus: You can customize the prompt in the "index.js" file to generate different types of tweets. (by default it generates tips and tricks for web development)
Congratulations ๐, now you have completely automated your Twitter account using AI, now sit back and enjoy!
Thanks for reading this long blog ๐
You can follow me on Twitter / X | LinkedIn | GitHub
Note: I have tested this with multiple accounts for more than 3 months and none of my accounts faced any issue or ban, but I highly reccommend you to first try it on your secondary or dummy acccount as no one knows what elon will change next. ๐
It is advisable to use environment variables instead of directly putting secrets in repository file but I have skipped this part as it would become complicated for many. Alternatively you can download the repository instead or forking and upload it from your account and keep it private, in that way, your secrets will not be exposed to the public.