Building My Automated Social Media Publisher — Part 3: Building the Machine
In the first two parts of this series, I explained why I wanted to automate the promotion of my blog posts and why we eventually decided to use Buffer as the intermediary between our application and the social networks.
That decision solved one major problem, but it left another one:
What exactly should our application do?
The temptation when starting a software project is to keep adding features. Once you realise that something is possible, it is very easy to decide that the application should do that as well.
We deliberately went in the opposite direction.
Start With the Actual Job
The application had one basic purpose: take articles from my blogs and turn them into scheduled social-media promotions.
Everything else was secondary.
That gave us a relatively short list of things the application actually needed to understand:
- which websites were publishing articles;
- which articles were available;
- which social destination should receive each promotion;
- what promotional text should be used;
- which image should accompany it;
- when the promotion should be published;
- and whether it had already been scheduled or published.
That became the foundation of the application.
A Small Database
The first important piece was a database.
We needed somewhere to keep a record of the promotions rather than relying on Buffer alone to remember what our application had done.
A promotion could therefore have information associated with the original article, its source website, its image, its promotional text, its publication date and time, its status and the destinations to which it had been assigned.
The database became the application's memory.
This was important because it meant that our application could make decisions based on its own history.
For example, it could determine whether an article had already been promoted instead of simply creating another promotion every time it encountered the article.
Articles and Promotions Are Different Things
Another useful distinction emerged during the design.
An article isn't the same thing as a promotion.
The article exists on the blog. The promotion is something our application creates to advertise that article.
That distinction gives us considerable flexibility.
The same article can have its own promotional record, with its own publication date, text, image and destination.
The blog publishes the article. Our application publishes the promotion.
Destinations
We also separated the idea of a promotion from the social network to which it would be sent.
Instead of hard-coding every social network into the promotion itself, the application keeps destinations as separate records.
That means a promotion can be associated with a particular destination without the rest of the application needing to know all the details of that destination.
This fitted neatly with our decision to use Buffer.
The application knows what it wants to publish and where it should go. Buffer handles the final connection to the social network.
Finding the Articles
There was still one rather obvious problem.
If I had to enter every article into the application manually, we hadn't really automated very much.
So the next part of the system was the article aggregator.
My different blogs already had feeds containing their latest articles. We could therefore use those feeds as the source for a central collection of articles.
The application could then look at the articles that had been published rather than requiring me to tell it about every new post.
If the blogs already know when I publish something, why should I have to tell another application?
Keeping the Application Small
At this point we had the beginnings of a useful architecture:
- the blogs publish the original articles;
- the aggregator discovers those articles;
- the database records promotions;
- destinations identify where promotions should go;
- Buffer provides the connection to the social networks.
Notice what we weren't building.
We weren't building another blogging platform. We weren't building a replacement for Buffer. We weren't building a general-purpose social media management system.
We were building a small piece of software that joined those things together for one particular purpose.
Then Scheduling Became the Interesting Part
Once the application could find articles and create promotions, the next question was obvious:
When should all these promotions actually be published?
I didn't want five new articles to result in five social-media posts appearing at once. The whole point was to spread the promotions out.
That meant the application needed rules for deciding which days should be used, how many posts could appear in a week and what should happen when dates were already occupied.
This turned out to be considerably more interesting than simply sending a post to Buffer.
Building the Scheduling Rules
The next stage of the project was therefore to teach the application how to programme a week's worth of promotions rather than simply publish everything as soon as it found it.
That meant defining exactly how one, two, three, four, five, six or seven articles should be distributed across a week — and then dealing with the limits of a real calendar.
In Part 4, we'll look at how those scheduling rules were designed, tested and eventually turned into an automated weekly programmer.

Comments
Post a Comment