productivity
Lark Suite Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Lark Suite KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.lark.*.
Use lua_read_doc("integrations.lark") inside KosmoKrator to discover the same reference at runtime.
Call Lua from the Headless CLI
Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic
Lark Suite workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.lark.list_chats({page_size = 1, page_token = "example_page_token"}))' --json kosmo integrations:lua --eval 'print(docs.read("lark"))' --json
kosmo integrations:lua --eval 'print(docs.read("lark.list_chats"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local lark = app.integrations.lark
local result = lark.list_chats({page_size = 1, page_token = "example_page_token"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.lark, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.lark.default.* or app.integrations.lark.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Lark Suite, use the narrower mcp:lua command.
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json Agent-Facing Lua Docs
This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.
Lark Suite — Lua API Reference
list_chats
List chats the current authenticated user belongs to.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
page_size | integer | no | Number of chats per page (max 50, default 20) |
page_token | string | no | Pagination cursor from a previous response |
Examples
-- List first page of chats
local result = app.integrations.lark.list_chats({
page_size = 20
})
for _, chat in ipairs(result.data.items) do
print(chat.name .. " (" .. chat.chat_id .. ")")
end
-- Get next page
if result.data.has_more then
local next = app.integrations.lark.list_chats({
page_size = 20,
page_token = result.data.page_token
})
end
get_chat
Get detailed information about a specific chat.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
chat_id | string | yes | The chat ID (e.g., "oc_a0553eda9014c201e6969b478895c230") |
Example
local result = app.integrations.lark.get_chat({
chat_id = "oc_a0553eda9014c201e6969b478895c230"
})
print("Chat: " .. result.data.name)
print("Members: " .. result.data.member_count)
create_chat
Create a new group chat.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
chat_id | string | yes | Unique identifier for the new chat |
name | string | yes | Display name for the group chat |
Example
local result = app.integrations.lark.create_chat({
chat_id = "oc_my_project_chat",
name = "Project Discussion"
})
print("Created chat: " .. result.data.chat_id)
list_messages
List messages in a specific chat.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
chat_id | string | yes | The chat ID to list messages from |
page_size | integer | no | Number of messages per page (max 50, default 20) |
page_token | string | no | Pagination cursor from a previous response |
Example
local result = app.integrations.lark.list_messages({
chat_id = "oc_a0553eda9014c201e6969b478895c230",
page_size = 10
})
for _, msg in ipairs(result.data.items) do
print(msg.sender.id .. ": " .. msg.body.content)
end
send_message
Send a message to a specific chat.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
chat_id | string | yes | The chat ID to send the message to |
content | string | yes | Message content (JSON-encoded for rich types) |
msg_type | string | no | Message type: "text", "post", "image", "file", etc. (default: "text") |
Message Types
| Type | Content Format | Example |
|---|---|---|
text | {"text":"Hello"} | Plain text message |
post | Rich text JSON | Formatted post with sections |
image | {"image_key":"..."} | Image message |
file | {"file_key":"..."} | File attachment |
Examples
-- Send a simple text message
app.integrations.lark.send_message({
chat_id = "oc_a0553eda9014c201e6969b478895c230",
content = '{"text":"Hello team!"}',
msg_type = "text"
})
-- Send plain text (auto-wrapped)
app.integrations.lark.send_message({
chat_id = "oc_a0553eda9014c201e6969b478895c230",
content = "Quick update: deployment complete.",
msg_type = "text"
})
list_members
List members of a specific chat.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
chat_id | string | yes | The chat ID to list members from |
page_size | integer | no | Number of members per page (max 50, default 20) |
page_token | string | no | Pagination cursor from a previous response |
Example
local result = app.integrations.lark.list_members({
chat_id = "oc_a0553eda9014c201e6969b478895c230"
})
for _, member in ipairs(result.data.items) do
print(member.name .. " (" .. member.member_id .. ")")
end
get_current_user
Get information about the currently authenticated Lark user.
Parameters
None.
Example
local result = app.integrations.lark.get_current_user({})
print("User: " .. result.data.name)
print("ID: " .. result.data.user_id)
Multi-Account Usage
If you have multiple Lark accounts configured, use account-specific namespaces:
-- Default account (always works)
app.integrations.lark.list_chats({})
-- Explicit default (portable across setups)
app.integrations.lark.default.list_chats({})
-- Named accounts
app.integrations.lark.work.send_message({
chat_id = "oc_abc123",
content = "Hello from work account!",
msg_type = "text"
})
app.integrations.lark.personal.list_chats({})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# Lark Suite — Lua API Reference
## list_chats
List chats the current authenticated user belongs to.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page_size` | integer | no | Number of chats per page (max 50, default 20) |
| `page_token` | string | no | Pagination cursor from a previous response |
### Examples
```lua
-- List first page of chats
local result = app.integrations.lark.list_chats({
page_size = 20
})
for _, chat in ipairs(result.data.items) do
print(chat.name .. " (" .. chat.chat_id .. ")")
end
-- Get next page
if result.data.has_more then
local next = app.integrations.lark.list_chats({
page_size = 20,
page_token = result.data.page_token
})
end
```
---
## get_chat
Get detailed information about a specific chat.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `chat_id` | string | yes | The chat ID (e.g., `"oc_a0553eda9014c201e6969b478895c230"`) |
### Example
```lua
local result = app.integrations.lark.get_chat({
chat_id = "oc_a0553eda9014c201e6969b478895c230"
})
print("Chat: " .. result.data.name)
print("Members: " .. result.data.member_count)
```
---
## create_chat
Create a new group chat.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `chat_id` | string | yes | Unique identifier for the new chat |
| `name` | string | yes | Display name for the group chat |
### Example
```lua
local result = app.integrations.lark.create_chat({
chat_id = "oc_my_project_chat",
name = "Project Discussion"
})
print("Created chat: " .. result.data.chat_id)
```
---
## list_messages
List messages in a specific chat.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `chat_id` | string | yes | The chat ID to list messages from |
| `page_size` | integer | no | Number of messages per page (max 50, default 20) |
| `page_token` | string | no | Pagination cursor from a previous response |
### Example
```lua
local result = app.integrations.lark.list_messages({
chat_id = "oc_a0553eda9014c201e6969b478895c230",
page_size = 10
})
for _, msg in ipairs(result.data.items) do
print(msg.sender.id .. ": " .. msg.body.content)
end
```
---
## send_message
Send a message to a specific chat.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `chat_id` | string | yes | The chat ID to send the message to |
| `content` | string | yes | Message content (JSON-encoded for rich types) |
| `msg_type` | string | no | Message type: `"text"`, `"post"`, `"image"`, `"file"`, etc. (default: `"text"`) |
### Message Types
| Type | Content Format | Example |
|------|---------------|---------|
| `text` | `{"text":"Hello"}` | Plain text message |
| `post` | Rich text JSON | Formatted post with sections |
| `image` | `{"image_key":"..."}` | Image message |
| `file` | `{"file_key":"..."}` | File attachment |
### Examples
```lua
-- Send a simple text message
app.integrations.lark.send_message({
chat_id = "oc_a0553eda9014c201e6969b478895c230",
content = '{"text":"Hello team!"}',
msg_type = "text"
})
-- Send plain text (auto-wrapped)
app.integrations.lark.send_message({
chat_id = "oc_a0553eda9014c201e6969b478895c230",
content = "Quick update: deployment complete.",
msg_type = "text"
})
```
---
## list_members
List members of a specific chat.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `chat_id` | string | yes | The chat ID to list members from |
| `page_size` | integer | no | Number of members per page (max 50, default 20) |
| `page_token` | string | no | Pagination cursor from a previous response |
### Example
```lua
local result = app.integrations.lark.list_members({
chat_id = "oc_a0553eda9014c201e6969b478895c230"
})
for _, member in ipairs(result.data.items) do
print(member.name .. " (" .. member.member_id .. ")")
end
```
---
## get_current_user
Get information about the currently authenticated Lark user.
### Parameters
None.
### Example
```lua
local result = app.integrations.lark.get_current_user({})
print("User: " .. result.data.name)
print("ID: " .. result.data.user_id)
```
---
## Multi-Account Usage
If you have multiple Lark accounts configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations.lark.list_chats({})
-- Explicit default (portable across setups)
app.integrations.lark.default.list_chats({})
-- Named accounts
app.integrations.lark.work.send_message({
chat_id = "oc_abc123",
content = "Hello from work account!",
msg_type = "text"
})
app.integrations.lark.personal.list_chats({})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.lark.list_chats({page_size = 1, page_token = "example_page_token"})
print(result) Functions
list_chats Read
List chats the current authenticated user belongs to in Lark. Returns chat IDs, names, and metadata for use with other Lark tools.
- Lua path
app.integrations.lark.list_chats- Full name
lark.lark_list_chats
| Parameter | Type | Required | Description |
|---|---|---|---|
page_size | integer | no | Number of chats to return per page (max 50, default 20). |
page_token | string | no | Pagination cursor from a previous response to fetch the next page. |
get_chat Read
Get detailed information about a specific Lark chat, including its name, description, owner, and member count.
- Lua path
app.integrations.lark.get_chat- Full name
lark.lark_get_chat
| Parameter | Type | Required | Description |
|---|---|---|---|
chat_id | string | yes | The chat ID to retrieve (e.g., "oc_a0553eda9014c201e6969b478895c230"). |
create_chat Write
Create a new group chat in Lark. Specify a chat ID and name for the new chat.
- Lua path
app.integrations.lark.create_chat- Full name
lark.lark_create_chat
| Parameter | Type | Required | Description |
|---|---|---|---|
chat_id | string | yes | A unique identifier for the new chat (e.g., "oc_my_new_chat"). |
name | string | yes | The display name for the new group chat. |
list_messages Read
List messages in a specific Lark chat. Returns message IDs, sender info, content, and timestamps.
- Lua path
app.integrations.lark.list_messages- Full name
lark.lark_list_messages
| Parameter | Type | Required | Description |
|---|---|---|---|
chat_id | string | yes | The chat ID to list messages from (e.g., "oc_a0553eda9014c201e6969b478895c230"). |
page_size | integer | no | Number of messages to return per page (max 50, default 20). |
page_token | string | no | Pagination cursor from a previous response to fetch the next page. |
send_message Write
Send a message to a specific Lark chat. Supports text and rich message types.
- Lua path
app.integrations.lark.send_message- Full name
lark.lark_send_message
| Parameter | Type | Required | Description |
|---|---|---|---|
chat_id | string | yes | The chat ID to send the message to (e.g., "oc_a0553eda9014c201e6969b478895c230"). |
content | string | yes | The message content. For text messages, pass plain text or JSON like '{"text":"Hello"}'. For rich messages, pass the appropriate JSON structure. |
msg_type | string | no | The message type: "text", "post", "image", "file", etc. Defaults to "text". |
list_members Read
List members of a specific Lark chat. Returns member IDs, names, and roles.
- Lua path
app.integrations.lark.list_members- Full name
lark.lark_list_members
| Parameter | Type | Required | Description |
|---|---|---|---|
chat_id | string | yes | The chat ID to list members from (e.g., "oc_a0553eda9014c201e6969b478895c230"). |
page_size | integer | no | Number of members to return per page (max 50, default 20). |
page_token | string | no | Pagination cursor from a previous response to fetch the next page. |
get_current_user Read
Get information about the currently authenticated Lark user, including name, user ID, and avatar.
- Lua path
app.integrations.lark.get_current_user- Full name
lark.lark_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||