All documentation

    AI Content Suite

    Rank Pilot AI SEO's content tooling covers long-form article writing, quick on-page content snippets, structured content briefs, and a free-standing AI content detector. All of it is powered by server-side Supabase edge functions that call OpenRouter first and fall back to the Lovable AI Gateway, so the suite keeps working even if one provider is rate-limited or out of credit.

    AI Blog Writer (BlogWriter.tsx)

    The Blog Writer page lets a user pick a target website, choose between a blog article or a newsletter format, and set tone, length and comma-separated keywords. There's a toggle for including image placement suggestions, and an "insert internal links" switch — Pro+ users have automatic internal linking always on, while lower tiers can opt in.

    On generation, the page calls the generate-article edge function with the topic, format, tone, length, keywords, target domain/website ID and the autoInsertLinks flag. The UI walks through a two-step "researching" → "writing" status so the user sees progress.

    Behind the scenes, generate-article:

    • Runs a Tavily web search (when TAVILY_API_KEY is configured) to gather up to eight sources and an answer summary, which is folded into the prompt as citable research.
    • Resolves an internal-linking plan by checking a 7-day cache in saved_ai_results (tool_type = internal_linking) for the website, and refreshing it via the internal-linking function if the cache is stale or missing.
    • Builds a system/user prompt that asks the model for a structured Markdown article (or newsletter) with a title, meta description, headings, citations to numbered sources, and 2–4 naturally placed internal links using the anchor/URL pairs from the linking plan.
    • Calls OpenRouter (google/gemini-2.5-flash) first, falling back to Lovable AI Gateway (google/gemini-3-flash-preview) on 429/402/5xx errors.
    • Generates a BlogPosting JSON-LD schema from the finished article (headline, description, word count, keywords, articleBody excerpt, and placeholder author/publisher/URL fields for the user to fill in) and returns it alongside the article as both raw JSON and a ready-to-paste <script> tag.
    • Counts inserted markdown links and reports back how many internal links made it into the final copy, so the UI can tell the user whether linking worked or whether they should run the Internal Linking Advisor first.

    Save, archive and send-to-robot behaviour

    Generated articles aren't auto-saved. The writer has three explicit actions:

    • Save to archive — inserts (or updates, if already saved) a row in blog_articles with the topic, tone, length, keywords, article body, research summary/sources and a draft status.
    • Send to Robot — first saves the article if it hasn't been saved yet, then queues it into autopilot_queue as a blog_article task with the full approved payload (article body, keywords, sources, JSON-LD script). The archived article's status flips to queued.
    • Copy buttons let the user copy the article body or the JSON-LD schema straight to the clipboard.

    An Archive panel lists up to 50 previously saved articles per user, showing topic, tone, date, a "🔍 Researched" badge when Tavily sources were used, and a status badge (draft/queued/published). Articles can be reloaded into the editor or deleted from here.

    Quick content generation (generate-content)

    The generate-content function powers smaller, single-shot content requests used across the AI Tools page and elsewhere. Given a type (blog_post, meta_tags, content_ideas or social_post), a keyword, and optional domain/context, it builds a tailored system/user prompt for that content type and returns the raw AI response. It uses the same OpenRouter → Lovable AI fallback pattern as the Blog Writer.

    Content briefs (content-brief)

    The content-brief function produces a structured, writer-ready brief rather than free text. It supports two modes:

    • Standard brief — for a keyword/keywords, domain and optional target audience, it asks the model to fill a create_content_brief tool schema covering title, target word count, content type (blog post, guide, listicle, comparison, how-to, case study), primary/secondary keywords, search intent, a section-by-section outline with key points, competitor angles, internal link suggestions and CTA ideas.
    • Linkable-asset mode (type: "linkable-asset") — used by the Backlink Builder to generate a guest-post topic and outline for a given niche, aimed at earning outreach links.

    Both modes force the model to respond via the create_content_brief function-call tool so the output is always valid structured JSON, and both fall back from OpenRouter to Lovable AI on quota errors.

    AI Content Detector

    AiContentDetector.tsx is a free, no-signup tool: paste 80–10,000 characters of text and get an AI-likelihood verdict. It calls the ai-content-detector edge function, which runs a two-agent pipeline:

    1. A Classifier Agent scores AI likelihood (0–100), assigns a verdict (human/mixed/likely_ai/ai), lists 3–6 specific signals (repetitive structure, generic transitions like "furthermore" or "delve into", uniform sentence length, em-dash overuse, etc.), and scores every sentence individually.
    2. A Reviewer Agent cross-checks the classifier's output against the original text for false positives (formal human writing, non-native English) and false negatives (edited AI text), adjusts the score, and writes a plain-English explanation and recommendation — pointing users toward the AI Content Suite if a rewrite is warranted.

    The function enforces an in-memory, per-IP rate limit of 8 scans per hour. The UI colour-codes each sentence by its AI score (green/amber/orange/red highlighting) and shows an overall verdict card with confidence level, a likelihood progress bar, and the reviewer's explanation.

    AI Tools page

    AITools.tsx is a dashboard hub of smaller, tab-based AI utilities for a selected website, including Meta Tag Generator, Keyword tools, Content Brief, Internal Linking, Ads copy, Funnel and CRO panels. Each panel follows a consistent pattern: call the relevant edge function, display editable results (via EditableField), let the user save results into saved_ai_results for later reuse (SaveRemoveButtons), send approved output into the autopilot_queue (ApproveQueueButton), and export results to PDF via ExportAIResultsPDF. Results already saved for a website are shown automatically on load via useSavedAIResult, so users don't need to regenerate content they've already approved.