Important
これは非公式のSDKです。L is B社およびdirect公式チームとは関係ありません。
This is an unofficial SDK for the direct (direct4b.com) chat service. It provides a low-level SDK (direct-go) and a high-level bot framework (daab-go).
- direct-go: Go SDK for Direct4B WebSocket/MessagePack RPC API
- daab-go: Bot framework and CLI tools built on direct-go
- direct-teams-bridge: Multi-account direct4b ⇄ Microsoft Teams bridge
- direct-mcp-server: OAuth-protected MCP server for Direct4B read and send tools
- direct-slack-compat: Minimal Slack-compatible Web API and Events API adapter for Direct4B
This SDK is developed based on the following official repositories:
- lisb/direct-js - Direct JavaScript SDK
- lisb/daab - Direct as a Bot framework
- lisb/hubot-direct - Hubot adapter for direct
# For the SDK
go get github.com/f4ah6o/direct-go-sdk/direct-go
# For the bot framework
go get github.com/f4ah6o/direct-go-sdk/daab-gopackage main
import (
"context"
"log"
direct "github.com/f4ah6o/direct-go-sdk/direct-go"
"github.com/f4ah6o/direct-go-sdk/direct-go/auth"
)
func main() {
// Load token from .env file or environment
a := auth.NewAuth()
token, err := a.GetToken()
if err != nil {
log.Fatal(err)
}
// Create client
client := direct.NewClient(direct.Options{
Token: token,
Endpoint: direct.DefaultEndpoint,
})
// Connect
ctx := context.Background()
if err := client.Connect(); err != nil {
log.Fatal(err)
}
defer client.Close()
// Send a message
err = client.SendText(roomID, "Hello, World!")
if err != nil {
log.Fatal(err)
}
}package main
import (
"context"
"log"
"os"
"github.com/f4ah6o/direct-go-sdk/daab-go/bot"
)
func main() {
// Create a new bot
r := bot.New(
bot.WithName("mybot"),
)
// Add a simple handler
r.Hear("hello", func(ctx context.Context, res bot.Response) {
res.Send("Hello there!")
})
// Add a response handler (only when directly addressed)
r.Respond("ping", func(ctx context.Context, res bot.Response) {
res.Reply("pong")
})
// Run the bot
ctx := context.Background()
if err := r.Run(ctx); err != nil {
log.Fatal(err)
}
}import (
"log"
"os"
"github.com/f4ah6o/direct-go-sdk/daab-go/bot"
)
func main() {
r := bot.New()
// Add middleware for logging and recovery
logger := log.New(os.Stdout, "[BOT] ", log.LstdFlags)
r.Use(bot.LoggingMiddleware(logger))
r.Use(bot.RecoveryMiddleware(logger))
// Add rate limiting (1 request per 10 seconds per user)
r.Use(bot.RateLimitMiddleware(10 * time.Second))
// Add filter to only process messages from specific users
r.Use(bot.FilterMiddleware(func(ctx context.Context, res bot.Response) bool {
return res.UserID() == "allowed_user_id"
}))
// Your handlers...
r.Hear("test", func(ctx context.Context, res bot.Response) {
res.Send("Filtered and rate-limited response!")
})
r.Run(context.Background())
}# Login to obtain access token
daabgo login
# Initialize a new bot project
daabgo init my-bot
# Run the bot
cd my-bot
daabgo run
# Show available commands
daabgo --helpdirect-mcp-server exposes Direct4B read/send tools over MCP Streamable HTTP.
OAuth login and token issuance are expected to be handled by an upstream OAuth
gateway or identity provider. The Go server validates incoming Bearer JWTs with
the configured JWKS URL and enforces direct:read / direct:write scopes.
cp mcp.config.example.yaml mcp.config.yaml
# Edit mcp.config.yaml for your gateway, JWKS URL, public resource URL, and Direct accounts.
go run ./cmd/direct-mcp-server --config mcp.config.yamlProtected resource metadata is served at:
/.well-known/oauth-protected-resource
direct-slack-compat exposes a small Slack-compatible subset for simple bots:
auth.test, chat.postMessage, conversations.list, conversations.history,
and users.list.
cp slackcompat.config.example.yaml slackcompat.config.yaml
# Edit slackcompat.config.yaml for Direct accounts and token refs.
go run ./cmd/direct-slack-compat --config slackcompat.config.yamlThe adapter intentionally does not implement Slack OAuth, Socket Mode, Block Kit, modals, full threads, or interactive components.
| Variable | Description | Default |
|---|---|---|
DIRECT_TOKEN |
Access token for authentication | - |
HUBOT_DIRECT_ENDPOINT |
WebSocket endpoint URL | wss://api.direct4b.com/albero-app-server/api |
HUBOT_DIRECT_PROXY_URL |
Proxy URL for connections | - |
HTTPS_PROXY |
HTTPS proxy URL (fallback) | - |
HTTP_PROXY |
HTTP proxy URL (fallback) | - |
- AGENTS.md - Complete development guide
- direct-go/COVERAGE.md - API porting status
See daab-go-examples for complete example projects:
ping- Simple echo botwebhook- Webhook server example
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Run tests:
go test ./... - Run linter:
golangci-lint run - Commit your changes
- Push to the branch
- Create a Pull Request
# Run tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run tests with race detector
go test -race ./...
# Build the CLI
cd daab-go && go build -o daabgo cmd/daabgo/main.go