Welcome to this guide where we will delve into the intersection of automation and artificial intelligence. The objective is to create a self-sustaining blog, powered by AI, that can autonomously generate and publish content.
In this guide, we will outline the process of creating a blog that fetches content from Reddit, uses it as input for ChatGPT, an advanced AI model developed by OpenAI, and then has the AI generate a blog post based on this content. The system will also autonomously create a thumbnail for each post. This entire process will repeat every four hours.
The key feature of this system is its self-sustainability. Once the code is deployed, the system requires no further human intervention. It's a practical application of AI and automation in content creation and blogging.
Are you ready to explore this innovative approach to blogging? Let's get started.
Find a niche or the subject of your website
The first step in creating an AI-powered autonomous blog is to identify a niche or subject that you are passionate about and that has a substantial audience. This could be anything from technology, health, finance, to travel, or any other topic that interests you. The key is to choose a subject that you believe will engage and attract readers.
Once you've identified your niche, the next step is to find a related subreddit with high activity. Reddit is a vast platform with communities, known as subreddits, dedicated to virtually every topic under the sun. These subreddits are a goldmine of content and discussions that can be leveraged for your blog.
To find the most active subreddit related to your chosen subject, you can use Reddit's search function. Type in keywords related to your niche and look at the number of members and the frequency of posts in each subreddit that comes up. You can also use websites like subredditstats.com to get detailed statistics about the activity level of different subreddits.
Remember, the goal is to find a subreddit with a high level of activity and engagement, as this will provide a steady stream of content for your AI to work with. Once you've identified the right subreddit, you're ready to move on to the next step of setting up your AI-powered blog.
Once you found it, save the subreddit URL for later.
Choosing a Brand Name and Securing Your Domain
The next crucial step in setting up your AI-powered blog is to choose a brand name and secure your domain. Your brand name should be unique, memorable, and reflective of the niche or subject you've chosen. It's the identity by which your blog will be known, so take some time to brainstorm ideas that resonate with your chosen topic and audience.
Once you've come up with a potential brand name, you'll need to secure your domain. Name.com is a reliable platform where you can purchase your domain. Simply type in your chosen brand name and see if the domain is available. If it is, you can proceed to purchase it.
If you're having trouble coming up with a brandable domain name, don't worry. DomainsGPT is an AI tool that can help you generate unique and brandable domain names. You can access it at DomainsGPT. Simply input keywords related to your niche, and the AI will generate a list of potential domain names for you to choose from.
Remember, your domain name is an integral part of your brand identity. It should be easy to remember, easy to type, and give your audience a clear idea of what your blog is about. Once you've secured your domain name, you're one step closer to launching your AI-powered blog.
Installing Ghost on Digital Ocean
Before we dive into the installation process, let's take a moment to understand what Ghost CMS is and why it's an excellent choice for your AI-powered blog.
Ghost is a powerful open-source Content Management System (CMS) designed for modern publishing. It's built on a robust Node.js framework, making it incredibly fast and efficient. Ghost is known for its clean, user-friendly interface that makes it easy to create and manage content. It's a favorite among bloggers, publishers, and businesses alike for its simplicity and focus on content creation.
One of the key features of Ghost is its built-in SEO (Search Engine Optimization) capabilities. This means that your blog will be optimized for search engines right out of the box, helping you reach a larger audience without extra effort.
Moreover, Ghost is a headless CMS. This means it can be decoupled from the front-end, making it an excellent choice for our project. We can use Ghost to manage and store our content, while the AI handles the creation and publishing of the content.
For this install there are three things which you need to have ready up-front:
- A DigitalOcean account (This signup link will give you $200 free credit)
- A domain name to point at your new site (Mandatory for SSL configuration during install)
Setting up the marketplace app
Head over to the official Ghost app in the Digital Ocean marketplace, and click on the “Create Ghost Droplet” button.
For most Ghost installs, the $6 base option is sufficient to run the app. If you’re running a high traffic site or one with lots of members, then you may want to choose an option with more resources.
The rest of the options for the Droplet can be selected based on what you prefer. Make sure you only create one Droplet, Ghost runs on a single process and cannot be sharded across multiple machines.
When you’re done, click the “Create Droplet” button at the bottom of the screen.
Once the Droplet has been created you will have an IP address to log into. Open your terminal and login to your new server as the root user, with SSH:
# Login via SSH ssh root@your_server_ip
At the first login Ghost-CLI will automatically perform an update check for all available packages, and make sure that the environment is ready for use. When finished, you’ll see a prompt to let you know what’s next:
Ghost will prompt you for two details: 1. Your domain - Add an A Record -> xxx.xxx.xxx.xxx & ensure the DNS has fully propagated - Or alternatively enter http://xxx.xxx.xxx.xxx 2. Your email address (only used for SSL) Press enter when you're ready to get started!
Configuring your domain
It’s best to set up your domain and DNS at this point so that SSL certificates can be automatically provisioned during the install process. Create an A-Record from your domain, pointing at your server’s IP address, then press Enter in terminal when you’re ready.
Go to Name.com and click on the three dots then "Manage domain". Click on Manage DNS Records.
Create an "A" record type, let host empty, in response you will enter the IP you got from Digital Ocean, let TTL by default and validate.
Wait a bit and you can now go back to the terminal and press "Enter".
Setting up Ghost
Ghost-CLI will now install and configure Ghost for you, and along the way it will prompt you with some questions about how you’d like things to be set up:
Enter the exact URL (the domain you pointed at your droplet’s IP address) that your publication will use, and include the protocol for HTTP or HTTPS. For example,
https://example.com. If you use HTTPS, Ghost-CLI will offer to set up SSL for you.
Your new site
Once the install is finished you’ll be able to access your new site on
https://yourdomain.com/ghost to access Ghost Admin ✨
That’s it! You’re done.
Once Ghost is properly set up it’s important to keep it properly maintained and up to date. Fortunately, this is relatively easy to do using Ghost-CLI. Run
ghost help for a list of available commands, or explore the full Ghost-CLI documentation.
What to do if the install fails
If an install goes horribly wrong, use
ghost uninstall to remove it and try again. This is preferable to deleting the folder to ensure no artifacts are left behind.
If an install is interrupted or the connection lost, use
ghost setup to restart the configuration process. If the install succeeds, but starting Ghost fails, you can try starting ghost manually with
For troubleshooting and errors, use the site search and FAQ section to find information about common error messages.
Configure your website
Once you've successfully installed Ghost CMS on Digital Ocean, the next step is to configure your website to reflect your brand. Ghost's intuitive dashboard makes this process straightforward and easy.
Logo and Brand Name: Start by setting your brand's logo and name. Navigate to the "Design" settings in your Ghost dashboard. Here, you'll find options to upload your logo and set your publication title. Your publication title will be your brand name, so make sure it's something that represents your niche well.
Description: Under the same "Design" settings, you'll find an option to set a description for your website. This is a short text that describes what your website is about. It's often displayed in search results, so make it compelling and relevant to your niche.
Theme Color: Ghost allows you to set a theme color that matches your brand. This color will be used in various places like link hover color, the color of your AMP site, and more. To set this, navigate to the "Branding" tab in the "Design" settings. Here, you can choose a color that matches your brand identity.
Favicon: A favicon is the small icon that appears on the tab of your browser when someone visits your website. It's a small but significant part of your brand identity. You can set this under the "Publication Icon" section in the "Design" settings.
Remember, consistency is key in branding. Make sure all these elements align with your brand identity and complement each other well. This will help establish a strong brand presence and make your website more memorable for your visitors.
Don't forget to hit the Save button and go back to settings, click on "General" and take the time to check all the settings and update them if needed.
You can disable membership by selecting "Nobody" if you don't want people to be able to create an account on your website.
Setting up the script to automate the website
Creating an Heroku Account:
- Visit the Heroku website at https://www.heroku.com/
- Click on the "Sign Up" button on the top right corner of the page.
- Fill in your details in the sign-up form. This includes your first name, last name, email, and role. You will also need to indicate the primary development language you use.
- Click on the "Create Free Account" button.
- You will receive an email from Heroku to verify your account. Click on the link in the email to verify your account.
You will also need to set-up the Heroku CLI on your computer.
Setting up Heroku CLI on Mac:
- If you have Homebrew installed, you can simply run the command
brew install heroku/brew/herokuin your terminal.
- If you don't have Homebrew, you can download the installer from the Heroku website at https://devcenter.heroku.com/articles/heroku-cli#download-and-install
- Once the installation is complete, you can verify your installation by running the command
heroku --versionin your terminal.
Setting up Heroku CLI on Windows:
- Download the appropriate installer for your Windows system (32-bit or 64-bit) from the Heroku website at https://devcenter.heroku.com/articles/heroku-cli#download-and-install
- Run the installer and follow the on-screen instructions.
- Once the installation is complete, you can verify your installation by opening the Command Prompt and running the command
Login to heroku CLI
Remember to log in to your Heroku account via the CLI using the command
heroku login and follow the prompts.
Download the code
Click here to download the script :
Extract the code
Create an "heroku" folder somewhere you will not rename or remove it. Extract the zip, inside it there is a folder, rename it as you want, but dont write spaces or special characters. Then place this folder inside the heroku one. All the code is inside this folder.
Download GitHub app
You can use whatever tool you want to manage the git pull/push, but I recommend using GitHub Desktop. Download it and login to your account.
Click on the top left corner, then click on "Add" and "Create New Repository".
Write a name and select the folder you just extracted and renamed inside heroku, and click on create the repo. Once created click on "Publish repository".
Get a code editor like Visual Studio Code or the one you like. And add him to your preferences in GitHub Desktop.
You will then be able to open your code in your editor. But we will do this later, now let's go back to Heroku.
Create an heroku app
Go to Heroku dashboard, and create a new app.
You should use the same name you are using for the GitHub repository to avoid doing something wrong later. Select your region and create the app.
Inside the "Deploy" tab, click on "GitHub" and connect your account. Search your repository name and click on "Connect" when you found it.
Scroll down a bit and enable automatic deploys.
Add all the secrets
Now we will add all our API keys and secrets to our heroku app. Go to the settings tab, and look for "Config Vars", click on "Reveal config vars".
Now here is what you will need to get :
- OpenAI API Key : Go to OpenAI website and create an API key, you will need to add a payment method, the bot will cost around 0.008$ per article. Copy the key, create a
OPENAI_API_KEYin the config vars, and paste the key next to it.
- Ghost Admin Key : Go to
https://yourdomain.com/ghost, go to settings, then integrations. Click "Add custom integration", name it how you want. Copy the Admin API Key, on Heroku create
GHOST_API_TOKENand paste the key.
- Ghost Content Key : On the same Ghost page you already are, copy the Content API Key, on heroku create
CONTENT_API_KEYand paste the key.
- Unsplash API Key : Create an account on Unsplash. Open the top right menu, and click on "Developers/API". Click on "Your Apps". Create a new app and scroll down to "Keys". Copy the Access Key, on heroku create
UNSPLASH_ACCESS_KEYand paste the key.
This is how it should looks like at the end :
If you want to ensure your Heroku app is using the Free Dyno tier, you can use the
heroku ps:resize command:
heroku ps:resize web=free
This command resizes your
web dynos to the
free tier. Please make sure to replace
web with the name of your process if it's different.
Before running the command, ensure that you're in the correct directory for your Heroku app or specify the app name using
-a option like
heroku ps:resize web=free -a your-app-name.
To know the process name of your Heroku app, you can use the command
heroku ps. This will show you the currently running processes (also called dynos) for your Heroku app. The first column in the output will give you the process name.
In a typical web application, you will see a
web process. This is the default process type for Heroku apps and is the one that receives HTTP traffic when deployed.
Here is an example of the command:
heroku ps -a your-app-name
In this command, replace
your-app-name with the actual name of your Heroku app.
The output might look something like this:
=== web (Free): your-command (1)web.1: up 2019/01/28 12:00:00 +0000 (~ 1h ago)
In this case, the process type is
Update the script
Go back to your GitHub Desktop app, and click on "Open in..." to open the code with your code editor. On VS Code you can click on the explorer on the top left corner and you should see your app like this :
Select "config.json", it's the only file we will need to modify.
config.json file is used to configure the behavior of the script. Here's what each key in the configuration file means:
subreddit: The name of the subreddit you want to fetch posts from. For example, if you want to fetch posts from https://www.reddit.com/r/passive_income, the value should be 'passive_income'.
keywords: A list of keywords related to your blog's topic. These keywords will be used to generate the article thumbnail. Only replace the text inside the "" to not break the script.
website_url: The URL of your website. Make sure to include 'https://' at the beginning and a trailing slash at the end.
openai_prompts: Contains prompts for the OpenAI model. The 'system' key is used to set the model's role, and the 'user' key is used to instruct the model on what to write.
When you are done, save the file, and go back to GitHub Desktop. Click on "Commit to main" and then "Push Origin"
Preventing our script from sleeping
Go to UptimeRobot and create an account. On the dashboard add a new monitor. Select the HTTP monitor type. Give him the same name you are using on heroku and github. For the URL, you will need to go to your heroku dashboard and right click on "Open App", copy the link of the button. Paste it on UptimeRobot and add
/uptime-check at the end of the URL.
So it should look like this :
Scroll down and create monitor. You will need to click a second time.
Automate the script
Go to EasyCron and create an account. On your dashboard create a new cron job. The URL will be the one you copied from heroku button, but this time we will add /generate at the end of the URL like so :
Select a frequency to generate new posts in "When to execute", I use every 4 hours. In the identifiers tab you can add a name, then click on Create Cron Job.
You can force your script to run by clicking on the chemistry icon.
Click on it and wait a few seconds.
If you followed this guide, it should display "Succeeded". Go back to your Ghost dashboard :
https://yourdomain.com/ghost and click on "Posts".
Your first article is now generated and published. You can delete the "Coming Soon" post. Now everything is running, you don't need to do anything else, you can link the search console to your website, add analytics, or do whatever you want. The script will publish a new article every four hours without you having to do anything.
Feel free to adjust the prompt inside the config.json file, but don't forget to commit and push the code with the GitHub Desktop app every time you change the config file.