Skip to content

Latest commit

 

History

History
95 lines (67 loc) · 3 KB

index.md

File metadata and controls

95 lines (67 loc) · 3 KB
layout
default

build codecov Go Report Card Go Module Go Reference Mentioned in Awesome Go

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.

Features

  • 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

Installation

go get github.com/go-lark/lark

Quick Start

Prerequisite

There are two types of bot that is supported by go-lark. We need to create a bot manually.

Chat Bot:

Notification Bot:

  • Create from group chat.
  • Web Hook URL is required.

Sending Message

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())
}

Limits

  • 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.

Switch to Lark Endpoints

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)

Documentation

See full documentation on README.