1. Project Setup
Initialize a new bot project with the Hazel Bot SDK
Let's set up a new bot project from scratch.
Create the Project
Create a new directory and initialize it:
mkdir task-bot
cd task-bot
bun init -yInstall Dependencies
Install the Bot SDK and Effect:
bun add @hazel/bot-sdk effectConfigure TypeScript
Update your tsconfig.json:
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"types": ["bun-types"]
}
}Set Up Environment Variables
Create a .env file:
BOT_TOKEN=your-bot-token-hereAdd .env to .gitignore:
echo ".env" >> .gitignoreCreate the Entry Point
Create index.ts:
import { Effect } from "effect"
import { runHazelBot } from "@hazel/bot-sdk"
runHazelBot({
setup: (bot) =>
Effect.gen(function* () {
yield* Effect.log("Task Bot is starting...")
}),
})Run the Bot
bun run index.tsYou should see:
Task Bot is starting...The bot is now running and connected to Hazel! Press Ctrl+C to stop it.
Project Structure
Your project should look like this:
task-bot/
├── index.ts # Bot entry point
├── package.json
├── tsconfig.json
├── .env # Bot token (not in git)
└── .gitignoreWhat's Next?
Now that the project is set up, let's make the bot respond to messages.