layout |
---|
default |
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.
- Notification bot & chat bot supported
- Send messages (Group, Private, Rich Text, and Card)
- Quick to build message with
MsgBuffer
- Easy to create incoming message hook
- Encryption and token verification supported
- Middleware support for Gin & Hertz web framework
- Highly extensible
- Documentation & tests
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:
- Feishu: create from Feishu Open Platform.
- Lark: create from Lark Developer.
- App ID and App Secret are required to init a
ChatBot
.
Notification Bot:
- Create from group chat.
- Web Hook URL is required.
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("[email protected]"))
}
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())
}
- go-lark is tested on Feishu endpoints, which literally compats Lark endpoints, because Feishu and Lark basically shares the same API specification. We do not guarantee all of the APIs work well with Lark, until we have tested it on Lark.
- go-lark only supports Custom App. Marketplace App is not supported yet.
- go-lark implements messaging, group chat, and bot API, other APIs such as Lark Doc, Calendar and so on are not supported.
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.