From 16964f460317f0dc6a0b3db2139bd1f7c2ad1a9d Mon Sep 17 00:00:00 2001 From: herbygitea Date: Tue, 24 Mar 2026 23:41:38 +0000 Subject: [PATCH] Create instagram-automation-content-hub-plan.md via n8n --- .../instagram-automation-content-hub-plan.md | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 PBS/Tech/Projects/instagram-automation-content-hub-plan.md diff --git a/PBS/Tech/Projects/instagram-automation-content-hub-plan.md b/PBS/Tech/Projects/instagram-automation-content-hub-plan.md new file mode 100644 index 0000000..994ac6e --- /dev/null +++ b/PBS/Tech/Projects/instagram-automation-content-hub-plan.md @@ -0,0 +1,148 @@ +--- +project: instagram-automation-content-hub-plan +type: project-plan +status: active +tags: + - pbs + - n8n + - instagram + - automation + - mysql + - flask + - docker + - wordpress +created: 2026-03-15 +updated: 2026-03-15 +path: PBS/Tech/Projects/ +--- + +# Instagram Automation & Content Hub — Master Plan + +## Background + +This plan consolidates two sessions of work: +- Finishing error checking on the Instagram comment reply workflow +- Redesigning the data pipeline to simplify the reply workflow and automate recipe/reel syncing + +### Key Architecture Decision +The reply workflow will be refactored to use a **single `instagram_posts` table lookup** instead of +the current two-table lookup + merge pattern. The `instagram_posts` table will store the recipe URL +directly, eliminating the need to join with `pbs_recipes` at reply time. + +--- + +## Phase 1 — Foundation + +- [ ] Add phpMyAdmin back to Docker Compose on staging +- [ ] Design final MySQL schema + - `pbs_recipes` — post_id, title, url, keyword (updated) + - `instagram_posts` — reel_id, post_id (FK), url, keyword (new url field) + - Foreign key linking `instagram_posts.post_id` → `pbs_recipes.post_id` +- [ ] Migrate n8n datatables to MySQL +- [ ] Verify PBS-API can query updated schema + +--- + +## Phase 2 — Finish Error Checking on Reply Workflow + +- [ ] Refactor reply workflow to single `instagram_posts` table lookup (remove merge) +- [ ] Add IF node after table lookup → Notify Travis on no record found +- [ ] Add IF node for keyword not matched → Notify Travis +- [ ] Verify subscribe check → Notify Travis (already built) +- [ ] Verify hash check → Notify Travis (already built) +- [ ] Test all error paths on staging +- [ ] Deploy to production + +### Notify Travis Workflow (already built) +- Webhook trigger at: https://n8n.plantbasedsoutherner.com/webhook/notify-pbschat +- Payload format: + { + "title": "Alert title", + "message": "Detail message", + "timestamp": "={{ $now.toFormat('MMM dd, HH:mm:ss') }}" + } + +--- + +## Phase 3 — WordPress → MySQL Sync + +- [ ] Wire WordPress publish webhook (proof of concept built) to n8n workflow +- [ ] n8n workflow inserts/updates `pbs_recipes` table on post publish +- [ ] Handle duplicate detection (re-publish should UPDATE not INSERT) +- [ ] HMAC signature verification on incoming webhook (already built in WPCode Lite) +- [ ] Test with staging WordPress → staging n8n → staging MySQL +- [ ] Deploy to production + +### WordPress Webhook Details (already built) +- WPCode Lite snippet fires on post publish (admin only) +- Payload: post_id, title, url, tags, categories +- HMAC signature via X-PBS-Signature header +- Raw body passed via X-PBS-Body header (base64) for signature verification + +--- + +## Phase 4 — Instagram Reel Publish Webhook + +- [ ] Research Meta API for reel publish webhook event +- [ ] Build n8n workflow to receive reel publish event +- [ ] Insert record into `instagram_posts` on new reel +- [ ] Auto-populate URL by looking up matching `pbs_recipes` record via post_id in caption +- [ ] Trigger match verification check after insert + - If match found → update record, no alert + - If no match found → Notify Travis to manually link + +--- + +## Phase 5 — PBS Content Hub Updates (Planning Required First) + +- [ ] **Planning session required before any code is written** +- [ ] Review current Content Hub architecture and existing features +- [ ] Define full requirements for: + - Recipe review UI — Jenny can view new recipe records, confirm or edit keyword before reel goes live + - Reel/recipe match status dashboard — shows matched vs unmatched reels at a glance + - Manual match correction UI — fix bad or missing matches without touching MySQL directly +- [ ] Design UI/UX mockups +- [ ] Get Jenny feedback on workflow fit +- [ ] Build once requirements are locked + +--- + +## Full Automation Flow (Target State) + +1. Recipe published on WordPress + → WPCode Lite webhook fires + → n8n inserts record into `pbs_recipes` + +2. Jenny reviews PBS Content Hub + → Confirms or edits keyword + → One intentional human checkpoint ✅ + +3. Jenny publishes Instagram reel (with WordPress post_id in caption) + → Meta webhook fires + → n8n inserts record into `instagram_posts` with URL from `pbs_recipes` + +4. System verifies match + → If clean → ready for comments + → If broken → Notify Travis via Google Chat + +5. User comments on reel + → n8n comment reply workflow fires + → Single lookup on `instagram_posts` + → Keyword match → send DM + public reply + → All dead ends → Notify Travis + +--- + +## Notes + +- All development on staging first, then promote to production +- phpMyAdmin for direct MySQL access (Travis/admin only) +- PBS Content Hub is the Jenny-facing interface for data management +- Notify Travis workflow handles ALL alerts (Google Chat) +- n8n datatables to be fully retired once MySQL migration complete + +--- + +*Last Updated: March 15, 2026* +*Maintained by: Travis* +*Project: Plant Based Southerner — Instagram Automation* \ No newline at end of file