You might have noticed that I recently updated Idea factory.
For those who never visited this section of the website, Idea factory is a space where I am saving all the links / articles / medias that I found interesting.
On the technical side, Idea factory relies on WordPress, the super popular content management system. One big constraint with this CMS though, is the time to publish!
Consider this. To create an article I will have to:
- Connect to WordPress
- Press « Add new article »
- Find a cover picture on the web
- Upload the cover picture
- Write the article
- Then finally click publish
End-to-end, the whole process can easily takes me more than 10 minutes!
So, I asked myself, how can I make this fits in less than 1 minute?
(Spoiler Zapier was the answer)
To present it briefly, Zapier is a platform as a service which gives you the ability to automate different tasks by connecting multiple services together.
For example: If I am sending a tweet with a specific hashtag (the trigger), then Zapier will post a new status for me on Facebook (first action) and also save the associated media on my Google drive (second action).
It’s worth mentioning that in Zapier, you can combined an unlimited amount of steps (not like IFTTT for instance ), write you own code or even push notifications directly from your browser using a dedicated Google Chrome extension!
If this do that and that and that and that and …
Let’s now come back to our initial problem and look at the general solution I put in place.
As I explained earlier, if you install the Zapier Google Chrome extension you are given the ability to run a specific task on any webpage.
On the background, this is what happens the Chrome extension button is clicked:
- Zapier will start the task.
- Pass the page title I am on,
- Pass the page URL,
- Pass an optional text argument.
This second step is a little bit more complex as it uses a custom code section.
If the code is finding a text occurence, it returns it, otherwise it uses the page title.
For this third step, I am using an external service: Apify.
This platform provides the ability to create web crawlers on the fly which are going to scrap the whole content of a given page.
As an input I am feeding my crawler with the URL retrieved in step 1. And on the Apify side, this code is executed on the page where the crawler runs:
At first glance, this seems like a complicated piece of code. However, if you look closer the only thing I am doing here is getting the cover image of the webpage and the page description.
The previous operation is going to take a couple of seconds to run. So, just to make sure that the process is now over, I am delaying the rest of the execution for 1 minute.
Apify should now be done. Time to get back the results.
Let’s now create an article using the WordPress API.
As a title I am passing the result of step 2. For the content and excerpt I am giving the results of the crawler (step 5).
Finally, just to confirm that everything went fine I am pushing to myself a Slack notification with the link to the article.
We have seen in this article how I used Zapier to avoid the long and repetitive task of creating WordPress articles again and again.
If you have any questions regarding this workflow I am more than happy to share additional details.
Also, if you have other ideas of tasks that could be automated, feel free to leave a comment.