An easy-to-use unofficial SDK for Feishu and Lark Open Platform.
go-lark implements messaging APIs, with full-fledged supports on building Chat Bot and Notification Bot.
It is widely used and tested by in-house ~450 developers with over 1.5k Go packages.
MsgBuffer
go get github.com/go-lark/lark
There are two types of bot that is supported by go-lark. We need to create a bot manually.
Chat Bot:
ChatBot
.Notification Bot:
Chat Bot:
import "github.com/go-lark/lark"
func main() {
bot := lark.NewChatBot("<App ID>", "<App Secret>")
bot.StartHeartbeat()
bot.PostText("hello, world", lark.WithEmail("someone@example.com"))
}
Notification Bot:
import "github.com/go-lark/lark"
func main() {
bot := lark.NewNotificationBot("<WEB HOOK URL>")
bot.PostNotificationV2(lark.NewMsgBuffer(lark.MsgText).Text("hello, wolrd").Build())
}
The default API endpoints are for Feishu, in order to switch to Lark, we should use SetDomain
:
bot := lark.NewChatBot("<App ID>", "<App Secret>")
bot.SetDomain(lark.DomainLark)
See full documentation on README.