Hanu
Golang Framework for writing Slack bots
Install / Use
/learn @sbstjn/HanuREADME
hanu - Go for Slack Bots!
The Go framework hanu is your best friend to create Slack bots! hanu uses allot for easy command and request parsing (e.g. whisper <word>) and runs fine as a Heroku worker. All you need is a Slack API token and you can create your first bot within seconds! Just have a look at the hanu-example bot or read my tutorial …
Features
- Respond to mentions
- Respond to direct messages
- Auto-Generated command list for
help - Works fine as a worker on Heroku
Usage
Use the following example code or the hanu-example bot to get started.
package main
import (
"log"
"strings"
"github.com/sbstjn/hanu"
)
func main() {
slack, err := hanu.New("SLACK_BOT_API_TOKEN")
if err != nil {
log.Fatal(err)
}
Version := "0.0.1"
slack.Command("shout <word>", func(conv hanu.ConversationInterface) {
str, _ := conv.String("word")
conv.Reply(strings.ToUpper(str))
})
slack.Command("whisper <word>", func(conv hanu.ConversationInterface) {
str, _ := conv.String("word")
conv.Reply(strings.ToLower(str))
})
slack.Command("version", func(conv hanu.ConversationInterface) {
conv.Reply("Thanks for asking! I'm running `%s`", Version)
})
slack.Listen()
}
The example code above connects to Slack using SLACK_BOT_API_TOKEN as the bot's token and can respond to direct messages and mentions for the commands shout <word> , whisper <word> and version.
You don't have to care about help requests, hanu has it built in and will respond with a list of all defined commands on direct messages like this:
/msg @hanu help
Of course this works fine with mentioning you bot's username as well:
@hanu help
Slack
Use direct messages for communication:
/msg @hanu version
Or use the bot in a public channel:
@hanu version
Dependencies
- github.com/sbstjn/allot for parsing
cmd <param1:string> <param2:integer>strings - golang.org/x/net/websocket for websocket communication with Slack
Credits
Related Skills
imsg
333.3kiMessage/SMS CLI for listing chats, history, and sending messages via Messages.app.
slack
333.3kUse when you need to control Slack from OpenClaw via the slack tool, including reacting to messages or pinning/unpinning items in Slack channels or DMs.
xurl
333.3kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
docs-writer
98.9k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
