Help Needed with Bluesky API Integration: Link Embedding, Title/Description Concatenation, and Thumbnail Issues

Hello everyone,

First off, thank you so much for taking the time to look at this. I’m hoping to get some help with a Bluesky API integration issue I’ve been struggling with.

I’ve been trying to automate posts to Bluesky from YouTube using their API, but I’ve run into several issues, especially with links not being embedded when posted through the API. The same links work perfectly when posted manually to Bluesky, so I’m wondering if anyone here has figured out a way to make URLs show up as embedded content when posting through the API?

In addition, I’ve been trying to include the video title, description, and thumbnail in the post. Initially, I attempted to concatenate the title and description into the text field, but I kept running into syntax and JSON errors. I wasn’t able to resolve these errors, so I decided to remove the concatenation approach and simply include the title and thumbnail instead. Unfortunately, now I can’t get the thumbnail to display properly, even though I’m passing the correct URL.

My Workflow:

  • Setup: Docker-based local install with n8n for automation.
  • YouTube Data: Using the YouTube API to fetch video details, including title, description, and thumbnail.
  • Bluesky Post JSON:
{
  "collection": "app.bsky.feed.post",
  "repo": "tfraley.me",
  "record": {
    "text": "{{ $node['Switch'].json['latest_video_title'] }}",
    "thumbnail": "{{ JSON.parse($node['Switch'].json['latest_video_thumbnail']).url }}",
    "createdAt": "{{ new Date().toISOString() }}"
  }
}

I’ve been able to get the title and URL working, but the thumbnail isn’t showing up in Bluesky. Here’s the format I’m getting for the thumbnail data:

{
  "url": "https://i4.ytimg.com/vi/oNA3EBcjT4s/hqdefault.jpg",
  "width": "480",
  "height": "360"
}

Despite having this, the thumbnail doesn’t appear when posting via the API.

Would love any insight into:

  • Getting the link to display as an embed when posted via the API.
  • Correctly posting the title and thumbnail without issues.
  • Resolving the concatenation errors when adding title and description together in the text field.

Thanks again for any help you can provide!

Hey @tfraley
Welcome to the community.

In Bluesky for more complex posts, such as those with embeds, the JSON structure becomes more detailed and often requires multiple steps/requests.
For example to use image embeds you have to first upload the images to bluesky via the com.atproto.repo.uploadBlob | Bluesky endpoint and then you can use the response details to perform the post action

Basically for more complex posts you have to use the ‘embeds’ attributes of the post object

{
  "$type": "app.bsky.feed.post",
  "text": "post which embeds an external URL as a card",
  "createdAt": "2023-08-07T05:46:14.423045Z",
  "embed": {
    "$type": "app.bsky.embed.external",
    "external": {
      "uri": "https://bsky.app",
      "title": "Bluesky Social",
      "description": "See what's next.",
      "thumb": {
        "$type": "blob",
        "ref": { "$link": "bafkreiash5eihfku2jg4skhyh5kes7j5d5fd6xxloaytdywcvb3r3zrzhu" },
        "mimeType": "image/png",
        "size": 23527
      }
    }
  }
}

Here is a very useful post I have bookmarked back when I last worked with Bluesky. It’s been some time now so i hope it’s not terribly dated.

For the concatenation it really depends on how you are doing it. If it’s through building the json with the n8n expressions {{ }} it should be doable.