DEV Community

Roberto Luna
Roberto Luna

Posted on

Refactoring Content Automation for Bluesky: A Technical Deep-Dive

Refactoring Content Automation for Bluesky: A Technical Deep-Dive

 

TL;DR: I refactored the content automation script to fix inconsistent image card rendering and auto-publishing issues on Bluesky. The changes involved updating craft.service.ts, modifying JSON files, and adjusting metadata.

The Problem

The initial problem was with the auto-publisher getting stuck due to a bug in craft.service.ts. This caused inconsistent image card rendering and publication issues on Bluesky. The error messages indicated issues with Vercel settings and build errors.

What I Tried First

My first approach was to debug craft.service.ts and identify the misconfigured Vercel setting causing build errors. I attempted to fix the issue by adjusting the Vercel settings, but it required multiple attempts to resolve.

The Implementation

The implementation involved several key changes:

Updating craft.service.ts

The changes to craft.service.ts included refactoring the image card rendering logic to ensure consistent publication on Bluesky. Specifically, I updated the function renderImageCard to use the OpenAI SDK for DALL-E 3 image generation:

// craft.service.ts
import { OpenAI } from 'openai';

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

async function renderImageCard(text: string) {
  const response = await openai.images.generate({
    model: 'dall-e-3',
    prompt: text,
    n: 1,
  });
  return response.data[0].url;
}
Enter fullscreen mode Exit fullscreen mode

Modifying JSON Files

I updated the JSON files to reflect the changes in the auto-publishing process. For example, bluesky_en.json and bluesky_es.json were modified to include new progress and advance messages:

// content/2026/07/01/content-automation/bluesky_en.json
[
  {
    "type": "progress",
    "text": "Just spent the morning fixing the bug in `craft.service.ts` that was causing inconsistent image card rendering. Now the redesign I did"
  }
]
Enter fullscreen mode Exit fullscreen mode

Adjusting Metadata

The metadata files, such as metadata.json, were updated to include new Bluesky URIs and publication information:

// content/2026/07/01/content-automation/metadata.json
{
  "bluesky_published": true,
  "bluesky_uris": {
    "es": [
      "at://did:plc:y5omxao2h2bnmixo7sigikex/app.bsky.feed.post/3mprnrbubxs2z"
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

Key Takeaway

The key takeaway from this experience is the importance of debugging and refactoring code to ensure consistent and reliable automation processes. By updating craft.service.ts and modifying related files, I was able to resolve the issues with image card rendering and auto-publishing on Bluesky.

What's Next

Next, I plan to integrate more advanced image generation capabilities using the OpenAI SDK and explore additional automation features for content publishing on Bluesky. I will also monitor the performance of the refactored script and make adjustments as needed to ensure smooth operation.

vibecoding #buildinpublic #contentautomation #bluesky #openai #dall-e3


Part of my Build in Public series — sharing the real process of building SaaS projects from Playa del Carmen, México.

Repo: zaerohell/content-automation · 2026-07-03

#playadev #buildinpublic

Top comments (0)