Automated Blog Posting for Webasyst Store
Summary
I assembled an automated posting pipeline for a fabric store blog on Webasyst. The goal was to publish two articles a day without manual intervention. First, I analyzed the blog structure internally: two categories, URLs of the form /blog/{category}/{slug}/, and an archive by year in the sidebar. Then, I consolidated everything into a single "Blog", issued an API token with scope=blog, and built the pipeline: topic from the queue → DeepSeek writes the article → linker adds links to products → publication via API. Additionally, I eliminated duplicate publications that occurred due to network failures.
Technology Stack
| Technology | Role |
|---|---|
| Webasyst | Platform for the store, Blog application |
| PHP | API client blog_api.py (Webasyst API) |
| Python | Pipeline: run_one.py, linker, verify, publish |
| DeepSeek API | Article generation by AI-SEO prompt |
| JSON | themes.txt, internal_links.json, registry.json |
| PowerShell | publish.ps1, preview.ps1 |
Context and Task
The fabric store has a blog on the Webasyst platform (Blog application). The task was to set up regular automated posting: two articles a day, each about fabric or material, with internal links to catalog products. Doing this manually is unrealistic, so the task was to automate the entire cycle from topic to published article.
Additionally, the blog had structural issues: two categories, an archive by year in the sidebar, and empty meta tags for some posts. Before setting up automated posting, it was necessary to bring the materials to a logical structure.
Exploring the Blog Structure
First, I figured out how the blog is structured internally without making any changes. Facts:
| Parameter | Value |
|---|---|
| Platform | Webasyst, Blog application |
| Categories | "News" (url novosti, 5 posts) and "Articles" (url stati, 31 posts) |
| Total Posts | 36, IDs 1–37 (ID 4 deleted) |
| Post URL | /blog/{category}/{slug}/ |
| Sidebar | archive by year 2025/2024/2023 (by month), blocks "News"/"Articles" |
| Meta Tags | plugin working, for verified posts meta_title/meta_description filled |
Blocker: Token Scope
The current API token had scope=shop, so blog methods responded with access_denied (blog.blog.getList). A token with scope=blog can only be issued through OAuth flow: you need to log in as an administrator and confirm access. I did not have the admin login/password, so the owner issued the token, which I placed in .env as WEBASYST_BLOG_TOKEN. After this, the blog API started responding (with retries due to unstable network).
Migration to a Single "Blog"
Target structure: one category "Blog", all materials inside, "News" and "Articles" removed from the front, archive by year hidden.
Key question: URL scheme. When moving to a category with url blog, posts would become /blog/blog/{slug}/ (double blog). Options:
- keep the combined category url
stati→/blog/stati/{slug}/; - do not merge categories, but only hide them from the menu (URLs do not change).
Chosen option: url stati — minimum risk for SEO, double blog looks bad.
flowchart LR
A["Category "News"<br>5 posts"] --> C["Single "Blog"<br>url stati"]
B["Category "Articles"<br>31 posts"] --> C
C --> D["/blog/stati/{slug}/"]
Migration: the category was renamed to "Blog" (url stati), 5 posts from "News" were moved, "News" was hidden (private). Backups were saved in data/backups/. Years and menu items in the sidebar are theme/Site settings, not removed via blog API, so they remain for manual theme editing.
Architecture of the Automated Posting Pipeline
The pipeline is built from separate modules, each responsible for one step. The full cycle is launched by the script run_one.py --publish, and publish.ps1 runs two articles in a row.
flowchart LR
A["themes.txt<br>(topic queue)"] --> B["slug.pick"]
B --> C["DeepSeek API<br>writes article"]
C --> D["linker<br>1–4 links to products"]
D --> E["verify<br>HTML check"]
E --> F["blog.post.add"]
F --> G["blog.post.update<br>(text/slug/meta/date)"]
G --> H["status = published"]
H --> I["registry.json +<br>topic moves out of queue"]
Steps:
- Topic from the queue — takes the first line from
themes.txt(100 topics, no overlap with existing posts). - Slug — generated from the topic, checked for uniqueness against
registry.json, catalog, and front. - DeepSeek writes the article — prompt by AI-SEO in
prompts/blog_prompt.md: H2-structure, FAQ, meta ≤60/155 characters. - Linker adds links — 1–4 links to products/categories from
internal_links.json(202 links), distributed across different H2, no duplicates. - Verify checks HTML — rejects the article before publication if something is wrong.
- Publication —
blog.post.add→blog.post.updatewith text/slug/meta/date →status=published. - Fixation — result written to
registry.json, topic removed from the queue only after success.
Data for Internal Linking
internal_links.json contains 202 links to products and categories in the catalog. Linker uses them to insert relevant anchors in the text. This turns each article into an entry point to the catalog and strengthens internal linking.
Protection and Reliability
Paid API and a live site require careful handling. Key mechanisms:
- Backup before migration — all structural changes go after saving to
data/backups/. - Topic queue — topic is removed from
themes.txtonly after successful publication, so it remains and is not lost on failure. - Registry —
registry.jsonstores slug → post_id mapping to avoid duplicate publication and reuse of an occupied slug. - Post verification — post-verification checks that the article is live and returns HTTP 200.
Problems and Solutions
1. blog.post.add does not accept text and status
blog.post.add creates an empty published post — it does not accept text/url/status. Content is written by a separate call to blog.post.update. After add, a mandatory pause of ~15 seconds is required: without it, replication does not complete, and update responds with "Post not found".
2. status="draft" hides the post from API
If the post is set to draft, it disappears from the API selection, and update responds with 404 — this is normal behavior, not an error. Publication is performed by reverting to status=published.
3. Quality of anchors in linker
Early versions placed links on general words like "density", "composition", "color", "width", "weave" — this looked like spam. Linker was tightened:
- anchor — not shorter than two words;
- words "density/composition/color/width/weave" — in stop-list;
- phrase cannot consist of general words ("active leisure", "workwear").
In verify.py, a check for "anchor from one word" was added — the pipeline rejects such an article before publication.
4. Duplicate publications due to network failure
Symptom: the same article was published repeatedly. Cause — order of operations in run_one.py: the result was recorded in registry.json and the topic removed from the queue only after post-verification. With ConnectTimeout in verify script, it crashed with an error, but the post was already published → the topic remained in the queue → next run published it again (duplicate with empty text).
Solution:
- After
publisher.create(), the result is recorded inregistry.jsonand job, the topic is removed from the queue immediately. - Post-verification became non-fatal — it writes only warnings.
- Added protection:
known_titles()considersjobs/*.jsonas well, to avoid publishing a topic that already has a post_id. - Duplicate removed via API.
flowchart TD
A["create() returned post_id"] --> B["Immediately: registry + job +<br>topic out of queue"]
B --> C["post-verify<br>(non-fatal, only warning)"]
C -->|network error| D["Topic already removed —<br>no duplicate"]
5. PowerShell 5.1 and ExecutionPolicy
&& is not supported in Windows PowerShell 5.1 (this is from PowerShell 7+), and local .ps1 files are blocked by ExecutionPolicy. Launch — through powershell -ExecutionPolicy Bypass -File .\publish.ps1 or Set-ExecutionPolicy -Scope CurrentUser RemoteSigned.
Results
The pipeline was tested with live publication. Live articles were published and return HTTP 200, headers and content are in place, links are set.
| What was done | Outcome |
|---|---|
| Blog structure | Single category "Blog" (url stati), "News" hidden |
| Topic queue | 100 topics in themes.txt, no overlap with existing |
| Internal linking | internal_links.json — 202 links to products/categories |
| Generation | DeepSeek API, AI-SEO prompt (H2, FAQ, meta ≤60/155) |
| Publication | Full cycle run_one.py --publish, 2 articles a day via publish.ps1 |
| Reliability | Registry + topic queue, network failure duplicates eliminated |
Conclusions
- Structure exploration — before any changes. First, the blog structure internally (categories, URLs, meta), then changes. This saved blind fixes.
- Token scope — separate blocker. Blog methods do not work with
scope=shoptoken; a separatescope=blogtoken via OAuth is needed. - URL scheme to decide before migration. Choosing url
statiinstead ofblogeliminated risk of doubleblog/blogin URL. - Order of result fixation determines reliability. Registry and topic queue should be updated immediately after post creation, not after post-verification — otherwise, network failure leads to duplicates.
- Anchor quality — separate task. Stop-list and "anchor from one word" check in verify protect from spammy linking.
- Paid API and live site require backups and idempotence. Backup before migration and topic queue that does not lose on failure — mandatory part.
