Back to Eliza

@elizaos/plugin-bluesky

plugins/plugin-bluesky/README.md

2.0.15.8 KB
Original Source

@elizaos/plugin-bluesky

BlueSky plugin for elizaOS - A comprehensive AT Protocol client for social interactions on BlueSky.

Overview

This plugin provides BlueSky integration for elizaOS agents, enabling:

  • Posting: Create, delete, like, and repost posts
  • Direct Messaging: Send and receive direct messages
  • Notifications: Monitor and respond to mentions, follows, likes, and reposts
  • Profile Management: Access user profiles and timelines
  • Automated Posting: Schedule and automate post creation

Installation

TypeScript/JavaScript

bash
npm install @elizaos/plugin-bluesky
# or
bun add @elizaos/plugin-bluesky

Configuration

Environment Variables

Required:

Optional:

VariableDescriptionDefault
BLUESKY_SERVICEBlueSky service URLhttps://bsky.social
BLUESKY_DRY_RUNSimulate operations without executingfalse
BLUESKY_POLL_INTERVALNotification polling interval (seconds)60
BLUESKY_ENABLE_POSTINGEnable automated postingtrue
BLUESKY_ENABLE_DMSEnable direct messagingtrue
BLUESKY_POST_INTERVAL_MINMinimum post interval (seconds)1800
BLUESKY_POST_INTERVAL_MAXMaximum post interval (seconds)3600
BLUESKY_ENABLE_ACTION_PROCESSINGEnable action processingtrue
BLUESKY_ACTION_INTERVALAction processing interval (seconds)120
BLUESKY_POST_IMMEDIATELYPost immediately on startupfalse
BLUESKY_MAX_ACTIONS_PROCESSINGMax actions per batch5

Quick Start

TypeScript

typescript
import { blueSkyPlugin } from "@elizaos/plugin-bluesky";

// Add to your elizaOS agent
const agent = createAgent({
  plugins: [blueSkyPlugin],
});

// Or use the client directly
import { BlueSkyClient, validateBlueSkyConfig } from "@elizaos/plugin-bluesky";

const client = new BlueSkyClient({
  service: "https://bsky.social",
  handle: "your-handle.bsky.social",
  password: "your-app-password",
});

await client.authenticate();
const post = await client.sendPost({ content: { text: "Hello BlueSky!" } });

Features

Posting

typescript
// Create a post
const post = await client.sendPost({
  content: { text: "Hello BlueSky!" },
});

// Reply to a post
const reply = await client.sendPost({
  content: { text: "This is a reply!" },
  replyTo: { uri: post.uri, cid: post.cid },
});

// Like a post
await client.likePost(post.uri, post.cid);

// Repost
await client.repost(post.uri, post.cid);

// Delete a post
await client.deletePost(post.uri);

Direct Messages

typescript
// Get conversations
const { conversations } = await client.getConversations();

// Get messages from a conversation
const { messages } = await client.getMessages(convoId);

// Send a message
const message = await client.sendMessage({
  convoId: "conversation-id",
  message: { text: "Hello!" },
});

Notifications

typescript
// Get notifications
const { notifications } = await client.getNotifications(50);

// Mark as read
await client.updateSeenNotifications();

Timeline

typescript
// Get timeline
const timeline = await client.getTimeline({ limit: 50 });

for (const item of timeline.feed) {
  console.log(`@${item.post.author.handle}: ${item.post.record.text}`);
}

Profiles

typescript
// Get a profile
const profile = await client.getProfile("user.bsky.social");
console.log(`${profile.displayName} - ${profile.followersCount} followers`);

Events

The plugin emits the following events for elizaOS integration:

EventDescription
bluesky.mention_receivedAgent was mentioned in a post
bluesky.follow_receivedAgent received a new follower
bluesky.like_receivedAgent's post was liked
bluesky.repost_receivedAgent's post was reposted
bluesky.quote_receivedAgent's post was quoted
bluesky.should_respondTrigger for response generation
bluesky.create_postTrigger for automated posting

Development

TypeScript

bash
cd typescript
bun install
bun run build
npx vitest

Architecture

plugin-bluesky/
├── typescript/           # TypeScript implementation
│   ├── index.ts         # Main plugin export
│   ├── client.ts        # BlueSky API client
│   ├── types/           # Type definitions
│   ├── services/        # Service implementations
│   ├── managers/        # Agent manager
│   └── utils/           # Configuration utilities
├── python/              # Python implementation
│   ├── elizaos_plugin_bluesky/
│   │   ├── __init__.py  # Package exports
│   │   ├── client.py    # BlueSky API client
│   │   ├── config.py    # Configuration
│   │   ├── types.py     # Type definitions
│   │   └── errors.py    # Error types
│   └── tests/           # Test suite
├── rust/                # Rust implementation
│   ├── src/
│   │   ├── lib.rs       # Library root
│   │   ├── client.rs    # BlueSky API client
│   │   ├── config.rs    # Configuration
│   │   ├── types.rs     # Type definitions
│   │   └── error.rs     # Error types
│   └── tests/           # Integration tests
└── package.json         # Root package configuration

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please ensure your changes maintain feature parity across all three language implementations.