Artificial intelligence is changing the world of content and there are many people who want to jump on the bandwagon of AI-generated content, but the complexity of the process of creating content with artificial intelligence or lack of knowledge can be an obstacle to this.
That is why, from iSocialWeb, we want to help you with a small script that we have programmed to simplify the process. And don’t worry, we will explain everything step by step in a video, and you don’t need to know how to program 😉.
Automating artificial intelligence with Python
We have created a simple script written in Python, which with a few configuration data will do the whole process automatically.
Script functions:
- Create title
- Create content
- Publish content and title on WordPress
Steps prior to the execution of the script:
We will need to upload a list of keywords in .CSV format to the Google Colab environment. With this information, the AI will generate the title and content automatically.
From our script, we have programmed the connection with WP to simplify the process. So we need to have the username and password of the WordPress blog where we want to host the contents, although it is not necessary to be an administrator.
Running Python code in the browser with Google Colab
Colab, also known as Colaboratory, allows us to share content programmed in Python and run the code easily whether you are a student, data scientist or AI researcher:
- Save a file copy of Google Colab from the File menu in your Drive.
- Install dependencies that Google Colab needs to run the program in your browser by running first cell ▶️.
- Upload a file named articlos.csv with the template provided in this article to the folder located in the side menu. If you change the name, don’t forget to reference the new name in the Google Colab file.
- If it has been executed successfully, a green checkbox will be displayed. Do not proceed to the next step, until that check is displayed.
- Add OpenAI API key. If you don’t already have one, you can create an OpenAI API for free.
- Next, add your WordPress credentials so that it can insert content into your blog posts and publish them automatically.
- Add your WordPress user again and in the password, enter the password that is generated in your WP user, when you click on “Application passwords”.
- Run the following ▶️.
- If you were able to complete the various code instructions, a new post will be published in your WordPress generated by AI.
To help you understand the script better, here you can watch a video with a demo of the process:
See video translation
This content is generated from the audio voiceover so it may contain errors.
(00:01) hello everyone today I want to share with you from a Social Web a script that will allow
you from a list of keywords generate titles and contents for posts in 100 automatic way and once
generated it will allow you to upload them to your WordPress automatically that is to say by
simply providing a list of keywords and clicking play you will be able to fill in and publish
your blog with automatic content generated 100 by AI if you find it interesting I will explain
now step by step how it all works whether you are a veteran or if
(00:36) you have never
tried any programming language I will detail the process and you will be able to use it until
you know how to use it and even modify it and adapt it to your needs for this we are going to
use Google collab and python Google collab you can imagine it as a Google Docs or a Google sheet
but for programming languages it will allow you to program and execute code in the cloud share
it easily and in this case with the link that you will find in the video description you can
access to a copy of it of the same collab I recommend you
(01:09) almost always to do this
Google itself is going to recommend it but that you make a copy for this you can make a copy and
drive a copy in GitHub if you use this account this type of service is more used by programmers
with drive it is enough and you are going to use python python for those of you who have not
heard it is a programming language it is one of the most used nowadays very widespread for this
type of tasks and if you have never done anything like this do not worry it is a very simple
language very permissive and very
(01:40) semantic that is to say if you understand English
just read the instructions basically you are going to find out what it does the instructions are
executed in colab by blocks as you can see this is a block here below is another block each
block has at the top left a play button with this you execute the whole cell and you can see
here for example that I have already executed and it has been executed correctly it marks with a
green tick if it was executed incorrectly it would Mark with a red X and would indicate the
error and
(02:10) the line in which the error occurred don’t worry this code is very simple
if you fill in all the data and click play there should be no problem for those of you who
already know how to program or have already run colab I will quickly explain what you need to do
to run it so as not to waste your time and to make you understand what you need to do then we
are going to go step by step and in detail seeing how to execute everything to even modify it
for those who have never worked with this or want to stay with it
(02:38) do a more
complete explanation so above and roughly speaking what we’re going to do is to use a CSV
document in this case I have it here in sheets the name has to be CSV articles because within
the code itself we are looking for it if you modify the title in one of the points and it does
not match it we’ll give you an error so make sure it is correct this is one of the important
things in programming always make sure before you think that the code is wrong that all the
things have their correct name many
(03:05) times we are wrong and here I put article by
example and then it is called articles and we bang our heads on the table until we realize that
it was a typographical error and nothing more then you will need a document CSV articles with a
header a single column and a heading called title this you can also see in the code and further
down here on line 27 of the second row we are looking for the title column so also make sure
this is the right field and below the title you can include all your keywords here you can
include as many as you want
(03:41) there is no limit only the time you can keep the
computer running and the budget you have in open AI because at the end of the day you can have
the computer running in the budget you have an open AI because at the end of the day you can
have as many as you want there is no limit when creating with a limited number of credits that
you will be given for free but after that number you will have to pay it is a very affordable
price very affordable is not comparable to the price of a human editor but well don’t put here A
(04:04) whole hrf report because you will probably melt all the credits these are the examples
of keywords in this case we have four SEO online marketing local SEO lean building and other
basis on which we will generate content that is to say SEO will generate One content online
marketing will generate another local SEO will generate another once you fill in all your data
here what it will do is to go through all the keywords it will use two prompts is going to chain
them together first we’re going to generate a prompt with
(04:37) which we will generate
the title and another prompt with which we will generate the content and once these contents
have been generated it will simply upload them to our WordPress using xmlrcp or RPC excuse me
and that is the complete code it is a very useful base to generate content that you can use and
extend as you wish so if you already know your way around if you have worked with python just go
in open the document include your data and there should be no problem if you have any questions
you can leave them in the comments contact us or give
(05:14) us your ideas and now for the
beginners we are going to go step by step to see how each thing works so the points are the same
you need the document articles ccsv with your keywords and you need to execute each cell step by
step here at the top left you press play and as you can see this little green arrow will be
marking you the code is always executed from top to bottom from left to right okay you can see
that it ran very fast but a little green arrow will Mark where you are standing where the code
is currently located and below the cell it
(05:50) will show you the result here I have
already installed everything as you can see it has a little green arrow it marks a little green
arrow it marks the time of execution and everything is correct so we would move on to the next
cell here we are going to do several things we are going to upload our collab and that is to say
we are going to upload our file to colab in this case this is the file that we are going to
upload remember that it has to be called article cssv we are going to import python tools we
need to make this code
(06:21) work first of all remember that everything here is well
explained everything you see in green and preceded by a hash mark is a comment these comments
are not read by the compiler are not read by the programming language and are not executed they
are buy and for users only here Alvaro has explained everything very well step by step you have
the explanation of what each line does so if at any time you get lost take a second to read this
and it will probably explain the process to you you will read the file articles pcsv you are
going to
(07:01) pass it to a data frame and which is basically one of the ways we can use
to read files in Python using the pandas Library you can see it here it is the standard so if
you start working with this you will see it quite a few times and then you have to read your
openai key the open AI key is something private you can generate it from your account do not
share it because with it you have access to the credit consumption and with it you can you
access your paid credits but if someone acquires it they could use your
(07:34) credits
without permission so always keep it private then you need the credentials of the user with
which you want to publish in WordPress in this case the username and password which you will
have to replace here and the domain if you have a different WP login because you have modified
it for security be sure to modify it as well and no further changes should be necessary and here
we come to the code that we explained earlier we are going to iterate that is for each title or
for each keyword in our CSV article document
(08:07) vamosa generate a catchy title for an
article with the following string and here what we’re going to do is we’re going to take this
title the keyword and paste it in for example let’s take SEO and put it here you can always
modify this that is you can generate a catchy title a click bait title this is a prompt and you
can play with them it is always within the limit of your imagination no programming is required
here we simply play with what we asked the artificial intelligence to do and try to achieve the
best result well we are
(08:41) going to generate that title will generate it and once we
have that title we will take the answer that open eye gives us we will format it a little and we
will save it foreign and with that title already generated what we’re going to do is a second
prompt and we’re going to ask you to generate a complete article of a minimum of 700 words and a
maximum of 1500 words with the title we have generated and a number of features here you can see
that it solves the main doubts that users have on Google and answers their
(09:13)
frequently asked questions this as in the previous point you can always modify it you can always
adapt it to your use case for example you can reduce the maximum number of keywords you can
reduce the minimum number you can ask that instead of answering the questions of Google users
you can ask him to make an impact on the user to have a sales character in the article that is
you can adapt it to what interests you into your cases even here you can play and to try to make
things different for example adding that this number is
(09:48) variable that this number
is variable or that even in the different inputs I use several of a list this is already more
advanced I leave here the idea once the prompt is executed it will save it it will format
commands it will remove quotation marks for example this can always be made cleaner here you
have the base you can always use the Python’s replace command to eliminate things strange if you
see that of many asterisks which should not be the case but well it is a generative guide we
never know what it can generate then you
(10:21) can come to the code and instead of
replacing the double quotation marks you copy the line and add an asterisk and it replaces what
you add here with nothing this you can play a lot and optimize it to the maximum at all times
then once you have that generated here you have to add the username and password this is a
different username and password the username of your WordPress if you have to go to the profile
section you go to your WordPress for example in this case I am in the agency we go to all users
select a user in this case it is the
(10:59) user articulosia and we have to go down until
we reach the application passwords field in this field we have to name our application for
example let’s call article CA and we give to the field at a new application password we wait for
it to be generated and it will generate this password this is the password that we are going to
have to add here and this is what’s going to allow WordPress once we modify the code here once
we modify it here in our domain correctly automatically publish the generated contents
(11:37) this password is obviously going to be disabled once I’m done with the video so well
if you want to try using it but it shouldn’t work then with this data we would already have
everything complete so that the contents of our blog are generated and uploaded automatically if
you look here in the code what we are going to send to our WordPress is the title that we have
generated the content that we have generated and hear the status here it is published by default
you can change it to draft if you don’t want
(12:07) them to be generated directly
published and you want to make a manual revision I recommend you to leave it in draft at least
until you debug the system and see that everything works correctly and the rest of the code
basically what it does is make the request to be sent to WordPress and then checks so here is
the complete code it really works it’s very simple and you have everything very well explained
and commented so if you have any questions you can leave it in the comments you can contact us
we are at
(12:46) social networks thank you very much for your time best regards
Where can I find the script to publish content by AI on WordPress?
The script runs on Google Colab which is free and allows you to have a machine ready with everything you need, so you don’t have to install anything on your computer.
What problems can I encounter when I run it?
Some of the problems that you may encounter when executing the script can be solved simply by watching the video carefully and following the process step by step, but there are external problems that may occur:
- CSV encoding: In some cases, the generation of the CSV file is done with a different encoding, or it drags contents that mess up the document and prevents it from being read correctly. For this, you can use this demo file to test the tool.
🔧 Demo CSV Template IA-WP Articles
- Access problems: It is important that you check your WP accesses, especially the second password, which is the one that people usually have the most problems with. In addition to this, check with your hosting provider or WordPress configuration that you have not blocked access via API Rest. Here you should consult your hosting provider.
- OpenAI’s availability problems: OpenAI sometimes overloads and does not return data, especially during US hours. This can cause the program to fail because it does not receive data in the request to the GPT AI.
Will Google penalize AI content?
Google has created different AI-based tools to process natural language, such as Google Translate and Google Assistant, with the aim of facilitating communication and access to information. But… What do you think about generating content automatically? The best thing to do is to go to the source and he reaffirms: if the content is useful and created for people first, that’s not a problem.
Our opinion is that if it really responds to search intent to a greater extent than the content currently displayed, it will certainly rank more relevant.
What does it mean to respond to search intent?
- Have a trained language model to understand the user’s questions or queries.
- Have a database or information source to provide a relevant answer.
- Have an intent classification system.
- Have a search system to find relevant information.
- Make sure to provide a clear, accurate and useful answer.
What does chat GPT have to say about automated web copywriting?
Once we have everything ready, we wanted to ask ChatGPT 3 about the advantages and disadvantages of using an automated script in Google Colab to insert content on WordPress and this is what he answered us:
Resources
Here are some additional resources for more in-depth content automation:
- AI copywriting: Is it safe to generate automatic content?
- Google Colaboratory. (s. f.). https://colab.research.google.com/
- Spam Policies for Google Web Search | Google Search Central | Documentation |. (s. f.). Google Developers. https://developers.google.com/search/docs/essentials/spam-policies
If you are looking to improve your SEO and don't have time to manage your own content, we can help!
We specialise in using AI to create high quality targeted content that helps you improve your online visibility.