Overview
Hazel bots are standalone services that connect to your workspace and interact with channels and messages in real-time. The Bot SDK is built with Effect-TS and provides:- Type-safe RPC client for sending messages and managing channels
- Real-time event streaming via Electric SQL
- Slash command registration with type-safe arguments
- Message handlers for @mentions and message events
- OAuth integration tokens for Linear, GitHub, Figma, and Notion
Creating a Bot
1. Register Your Bot
Bots are created and managed through the RPC API:2. Bot Scopes
Bots request specific permissions via scopes:| Scope | Description |
|---|---|
messages:read | Read messages in channels where bot is installed |
messages:write | Send, edit, and delete messages |
channels:read | Read channel information and members |
channels:write | Create threads, update channel metadata |
users:read | Read user profiles and presence |
reactions:write | Add/remove message reactions |
commands:register | Register slash commands |
3. Install the Bot SDK
Building a Bot
Simple Echo Bot
Here’s a complete example that echoes messages and responds to/echo commands:
AI Bot with Tool Integration
The Hazel Bot example from the source shows advanced AI integration:packages/domain/src/rpc/bots.ts:14-22
Linear Integration Bot
The Linear Bot demonstrates OAuth integration and AI-powered issue creation:bots/linear-bot/src/index.ts:26-53
Bot API Reference
Message Operations
Channel Operations
Event Handlers
Slash Commands
Integration Tokens
Access OAuth tokens for connected integrations:linear, github, figma, notion
Bot Management
List Bots
Update Bot
Regenerate Token
Delete Bot
Bot Marketplace
List Public Bots
Install Bot
Uninstall Bot
Best Practices
Secure Token Storage
Store bot tokens in environment variables or secrets managers:Never commit tokens to version control.
Handle Errors Gracefully
Use
bot.withErrorHandler() or bot.ai.withErrorHandler() to catch and log errors:Rate Limiting
The SDK includes built-in rate limiting (10 messages/second). For higher throughput, batch operations when possible.
Next Steps
GitHub Integration
Subscribe channels to GitHub repositories
RSS Feeds
Automate content posting with RSS subscriptions