Workflow code
Copy this code to understand the workflow logic. Replace all API keys and credentials with your own before running.
// Affiliate content automation pipeline
// Node 1: Google Sheets — read next keyword from queue
// Node 2: Perplexity API — research keyword intent and top results
const researchPrompt = `Research the keyword "${keyword}" for an SEO article.
Return: search intent, top 5 competitor angles, key stats to include,
related keywords, suggested article structure (H2s and H3s)`
// Node 3: Claude — write full SEO article (1500-2000 words)
const articlePrompt = `Write a comprehensive SEO article for "${keyword}".
Structure: ${research.structure}
Include these stats: ${research.stats}
Add Amazon affiliate links naturally for: ${affiliateProducts}
Target: Indian audience, conversational tone, no AI-sounding phrases`
// Node 4: Claude — generate meta title, description, alt text
// Node 5: Stability AI — generate featured image
// Node 6: WordPress API — create draft post
// - Title, content, meta, featured image
// - Set category and tags
// - Schedule for optimal time (Tue/Wed/Thu, 9am IST)
// Node 7: Google Sheets — mark keyword as "Published" with URL
// Node 8: Google Search Console API — request indexing
// Node 9: Internal linking — find related posts, add 2-3 links