๐ Automated SEO - Webhook Setup
Connect Fast SEO Fix to your Next.js, Astro, Gatsby, or custom site to automatically receive published content.
How It Works
Add a webhook endpoint to your site that receives blog posts
Protect endpoint with a secret token (Bearer authentication)
Add your webhook URL and token in Fast SEO Fix dashboard
Fast SEO Fix sends blog posts to your endpoint automatically
Code Templates
Choose your framework and copy the ready-to-use code:
Code Templates
Copy and paste this code into your project to receive published content from SEOBot.
// app/api/seobot/publish/route.js
import { NextResponse } from 'next/server';
import fs from 'fs/promises';
import path from 'path';
export async function POST(request) {
// Verify authentication
const auth = request.headers.get('authorization');
const expectedToken = process.env.SEOBOT_SECRET_TOKEN;
if (!auth || auth !== `Bearer ${expectedToken}`) {
return NextResponse.json(
{ error: 'Unauthorized' },
{ status: 401 }
);
}
try {
const { title, slug, content, publishDate, seoMeta, categories, tags } = await request.json();
// Create markdown file with frontmatter
const markdown = `---
title: "${title}"
date: ${publishDate}
slug: ${slug}
description: "${seoMeta.description}"
categories: [${categories.map(c => `"${c}"`).join(', ')}]
tags: [${tags.map(t => `"${t}"`).join(', ')}]
---
${content}`;
// Write to content directory
const filePath = path.join(process.cwd(), 'content/blog', `${slug}.md`);
await fs.writeFile(filePath, markdown, 'utf-8');
// Optional: Trigger rebuild (Vercel, Netlify, etc.)
if (process.env.DEPLOY_HOOK_URL) {
await fetch(process.env.DEPLOY_HOOK_URL, { method: 'POST' });
}
return NextResponse.json({
success: true,
url: `https://yoursite.com/blog/${slug}`,
postId: slug,
});
} catch (error) {
console.error('Publish error:', error);
return NextResponse.json(
{ error: error.message },
{ status: 500 }
);
}
}Setup Steps:
- Add the code to your project
- Set
SEOBOT_SECRET_TOKENin your .env file - Deploy your changes
- Use your API endpoint URL when connecting to SEOBot
Add this to your .env or .env.local file:
# SEOBot Publishing Secret
SEOBOT_SECRET_TOKEN=your-secret-token-here
# Optional: Deploy hook for auto-rebuild
DEPLOY_HOOK_URL=https://api.vercel.com/v1/integrations/deploy/...Generate a secure random token and use it in both your site's environment and in SEOBot's connection settings.
Your Webhook URL:
https://yoursite.com/api/seobot/publishImportant: Security
Generate a strong random token (at least 32 characters). Use the same token in both your site's environment and Fast SEO Fix connection settings.
Payload Structure
Fast SEO Fix sends a POST request with this JSON structure:
{
"title": "Blog Post Title",
"content": "<h1>Blog Post Title</h1><p>Content...</p>",
"contentMarkdown": "# Blog Post Title\n\nContent...",
"excerpt": "Brief summary of the post",
"slug": "blog-post-title",
"publishDate": "2024-01-15T00:00:00.000Z",
"author": "Your Name",
"categories": ["SEO", "Content Marketing"],
"seoMeta": {
"title": "SEO Title (60 chars)",
"description": "Meta description (160 chars)",
"ogImage": "https://cdn.fastseofix.com/image.png"
},
"featuredImage": {
"url": "https://cdn.fastseofix.com/featured.png",
"alt": "Image description"
}
}Testing Your Webhook
- Use ngrok - Tunnel localhost to public URL for testing
- Check logs - Monitor your server logs for incoming requests
- Verify token - Ensure Bearer token matches your environment variable
- Test publishing - Publish a test blog post from Fast SEO Fix