KosmoKrator

productivity

LINE Messaging Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the LINE Messaging KosmoKrator integration.

Lua Namespace

Agents call this integration through app.integrations.line.*. Use lua_read_doc("integrations.line") 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 LINE Messaging workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.line.reply_message({reply_token = "example_reply_token", messages = "example_messages", notification_disabled = true}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("line"))' --json
kosmo integrations:lua --eval 'print(docs.read("line.reply_message"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local line = app.integrations.line
local result = line.reply_message({reply_token = "example_reply_token", messages = "example_messages", notification_disabled = true})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.line, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.line.default.* or app.integrations.line.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need LINE Messaging, use the narrower mcp:lua command.

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.

LINE Messaging - Lua API Reference

Namespace: app.integrations.line

This integration wraps documented LINE Messaging API v2 endpoints for messaging, webhook settings, users, bot info, group chats, rich menus, per-user rich menus, and account linking. The configured API URL should normally be https://api.line.me; the integration appends /v2/... endpoint paths.

Most write tools return the LINE API response body, or an empty table for 204 No Content endpoints. Message tools accept raw LINE message objects so agents can use current LINE message types without this package flattening or renaming fields.

Messaging

reply_message, send_message, multicast_message, narrowcast_message, and broadcast_message all accept messages, an array of LINE message objects:

{
  { type = "text", text = "Hello from the bot." }
}

Common tools:

app.integrations.line.reply_message({
  reply_token = "reply-token-from-webhook",
  messages = {{ type = "text", text = "Thanks." }}
})

app.integrations.line.send_message({
  to = "U0000000000",
  messages = {{ type = "text", text = "Your order is ready." }},
  notification_disabled = false,
  custom_aggregation_units = "orders"
})

app.integrations.line.multicast_message({
  to = {"U0000000000", "U1111111111"},
  messages = {{ type = "text", text = "A shared update." }}
})

app.integrations.line.narrowcast_message({
  messages = {{ type = "text", text = "Segment update." }},
  recipient = { type = "operator", and = {{ type = "audience", audienceGroupId = 1234567890 }}}
})

app.integrations.line.broadcast_message({
  messages = {{ type = "text", text = "Announcement for all followers." }}
})

Operational message tools:

  • get_narrowcast_progress({ request_id = "request-id" })
  • mark_as_read({ chat_id = "U0000000000" })
  • start_loading_animation({ chat_id = "U0000000000", loading_seconds = 20 })
  • get_message_quota({})
  • get_message_quota_consumption({})
  • get_delivery_count({ type = "push", date = "20260506" })
  • validate_messages({ type = "push", messages = {{ type = "text", text = "Preview" }} })

Allowed delivery count types are reply, push, multicast, and broadcast. Allowed validation types are reply, push, multicast, narrowcast, and broadcast.

Webhooks

app.integrations.line.set_webhook_endpoint({
  endpoint = "https://example.test/line/webhook"
})

local webhook = app.integrations.line.get_webhook_endpoint({})

local test = app.integrations.line.test_webhook_endpoint({
  endpoint = "https://example.test/line/webhook"
})

Webhook test responses are passed through from LINE and can include endpoint, success, timestamp, and status details depending on the API response.

Users And Bot

local profile = app.integrations.line.get_profile({
  user_id = "U0000000000"
})

local followers = app.integrations.line.list_friends({
  limit = 100,
  start = nil
})

local bot = app.integrations.line.get_current_user({})

list_friends maps to LINE’s follower ID endpoint. It returns IDs and pagination fields from LINE, not expanded profile records.

Group Chats

local summary = app.integrations.line.get_group_summary({
  group_id = "C0000000000"
})

local count = app.integrations.line.get_group_member_count({
  group_id = "C0000000000"
})

local members = app.integrations.line.list_group_member_ids({
  group_id = "C0000000000",
  start = nil
})

local member = app.integrations.line.get_group_member_profile({
  group_id = "C0000000000",
  user_id = "U0000000000"
})

leave_group({ group_id = "C0000000000" }) removes the bot from the group. Use it only when that is the intended operational effect.

Rich Menus

Rich menu tools accept LINE rich menu objects directly.

local rich_menu = {
  size = { width = 2500, height = 843 },
  selected = false,
  name = "main-menu",
  chatBarText = "Menu",
  areas = {}
}

app.integrations.line.validate_rich_menu({ rich_menu = rich_menu })
local created = app.integrations.line.create_rich_menu({ rich_menu = rich_menu })

local list = app.integrations.line.list_rich_menus({})
local one = app.integrations.line.get_rich_menu({ rich_menu_id = "richmenu-123" })

Default and per-user rich menu tools:

  • set_default_rich_menu({ rich_menu_id = "richmenu-123" })
  • get_default_rich_menu({})
  • clear_default_rich_menu({})
  • link_rich_menu_to_user({ user_id = "U0000000000", rich_menu_id = "richmenu-123" })
  • get_user_rich_menu({ user_id = "U0000000000" })
  • unlink_rich_menu_from_user({ user_id = "U0000000000" })
  • delete_rich_menu({ rich_menu_id = "richmenu-123" })

Image upload/download endpoints are binary content endpoints and are not exposed by this JSON-only tool set.

local token = app.integrations.line.issue_link_token({
  user_id = "U0000000000"
})

Use the returned token in LINE’s account-linking flow for your service.

Multi-Account Usage

app.integrations.line.send_message({...})
app.integrations.line.default.send_message({...})
app.integrations.line.production.send_message({...})

Named account namespaces use the same functions with different stored credentials.

Raw agent markdown
# LINE Messaging - Lua API Reference

Namespace: `app.integrations.line`

This integration wraps documented LINE Messaging API v2 endpoints for messaging, webhook settings, users, bot info, group chats, rich menus, per-user rich menus, and account linking. The configured API URL should normally be `https://api.line.me`; the integration appends `/v2/...` endpoint paths.

Most write tools return the LINE API response body, or an empty table for `204 No Content` endpoints. Message tools accept raw LINE message objects so agents can use current LINE message types without this package flattening or renaming fields.

## Messaging

`reply_message`, `send_message`, `multicast_message`, `narrowcast_message`, and `broadcast_message` all accept `messages`, an array of LINE message objects:

```lua
{
  { type = "text", text = "Hello from the bot." }
}
```

Common tools:

```lua
app.integrations.line.reply_message({
  reply_token = "reply-token-from-webhook",
  messages = {{ type = "text", text = "Thanks." }}
})

app.integrations.line.send_message({
  to = "U0000000000",
  messages = {{ type = "text", text = "Your order is ready." }},
  notification_disabled = false,
  custom_aggregation_units = "orders"
})

app.integrations.line.multicast_message({
  to = {"U0000000000", "U1111111111"},
  messages = {{ type = "text", text = "A shared update." }}
})

app.integrations.line.narrowcast_message({
  messages = {{ type = "text", text = "Segment update." }},
  recipient = { type = "operator", and = {{ type = "audience", audienceGroupId = 1234567890 }}}
})

app.integrations.line.broadcast_message({
  messages = {{ type = "text", text = "Announcement for all followers." }}
})
```

Operational message tools:

- `get_narrowcast_progress({ request_id = "request-id" })`
- `mark_as_read({ chat_id = "U0000000000" })`
- `start_loading_animation({ chat_id = "U0000000000", loading_seconds = 20 })`
- `get_message_quota({})`
- `get_message_quota_consumption({})`
- `get_delivery_count({ type = "push", date = "20260506" })`
- `validate_messages({ type = "push", messages = {{ type = "text", text = "Preview" }} })`

Allowed delivery count types are `reply`, `push`, `multicast`, and `broadcast`. Allowed validation types are `reply`, `push`, `multicast`, `narrowcast`, and `broadcast`.

## Webhooks

```lua
app.integrations.line.set_webhook_endpoint({
  endpoint = "https://example.test/line/webhook"
})

local webhook = app.integrations.line.get_webhook_endpoint({})

local test = app.integrations.line.test_webhook_endpoint({
  endpoint = "https://example.test/line/webhook"
})
```

Webhook test responses are passed through from LINE and can include endpoint, success, timestamp, and status details depending on the API response.

## Users And Bot

```lua
local profile = app.integrations.line.get_profile({
  user_id = "U0000000000"
})

local followers = app.integrations.line.list_friends({
  limit = 100,
  start = nil
})

local bot = app.integrations.line.get_current_user({})
```

`list_friends` maps to LINE's follower ID endpoint. It returns IDs and pagination fields from LINE, not expanded profile records.

## Group Chats

```lua
local summary = app.integrations.line.get_group_summary({
  group_id = "C0000000000"
})

local count = app.integrations.line.get_group_member_count({
  group_id = "C0000000000"
})

local members = app.integrations.line.list_group_member_ids({
  group_id = "C0000000000",
  start = nil
})

local member = app.integrations.line.get_group_member_profile({
  group_id = "C0000000000",
  user_id = "U0000000000"
})
```

`leave_group({ group_id = "C0000000000" })` removes the bot from the group. Use it only when that is the intended operational effect.

## Rich Menus

Rich menu tools accept LINE rich menu objects directly.

```lua
local rich_menu = {
  size = { width = 2500, height = 843 },
  selected = false,
  name = "main-menu",
  chatBarText = "Menu",
  areas = {}
}

app.integrations.line.validate_rich_menu({ rich_menu = rich_menu })
local created = app.integrations.line.create_rich_menu({ rich_menu = rich_menu })

local list = app.integrations.line.list_rich_menus({})
local one = app.integrations.line.get_rich_menu({ rich_menu_id = "richmenu-123" })
```

Default and per-user rich menu tools:

- `set_default_rich_menu({ rich_menu_id = "richmenu-123" })`
- `get_default_rich_menu({})`
- `clear_default_rich_menu({})`
- `link_rich_menu_to_user({ user_id = "U0000000000", rich_menu_id = "richmenu-123" })`
- `get_user_rich_menu({ user_id = "U0000000000" })`
- `unlink_rich_menu_from_user({ user_id = "U0000000000" })`
- `delete_rich_menu({ rich_menu_id = "richmenu-123" })`

Image upload/download endpoints are binary content endpoints and are not exposed by this JSON-only tool set.

## Account Link

```lua
local token = app.integrations.line.issue_link_token({
  user_id = "U0000000000"
})
```

Use the returned token in LINE's account-linking flow for your service.

## Multi-Account Usage

```lua
app.integrations.line.send_message({...})
app.integrations.line.default.send_message({...})
app.integrations.line.production.send_message({...})
```

Named account namespaces use the same functions with different stored credentials.
Metadata-derived Lua example
local result = app.integrations.line.reply_message({reply_token = "example_reply_token", messages = "example_messages", notification_disabled = true})
print(result)

Functions

reply_message Write

Send a reply message using a webhook reply token.

Lua path
app.integrations.line.reply_message
Full name
line.line_reply_message
ParameterTypeRequiredDescription
reply_token string yes Reply token from a webhook event.
messages array yes Array of LINE message objects.
notification_disabled boolean no Disable push notification when true.
send_push_message Write

Send a push message to a specific LINE user, group, or room. Supports text, image, video, sticker, location, flex, and other message types.

Lua path
app.integrations.line.send_push_message
Full name
line.line_send_message
ParameterTypeRequiredDescription
to string yes LINE user ID, group ID, or room ID to send the message to.
messages array yes Array of message objects. Each message must have a "type" (e.g., "text", "image", "sticker") and corresponding fields. Example for text: [{"type": "text", "text": "Hello!"}].
notification_disabled boolean no If true, the recipient will not receive a push notification. Default: false.
custom_aggregation_units string no Optional custom aggregation unit for message analytics.
multicast_message Write

Send messages to multiple LINE user IDs.

Lua path
app.integrations.line.multicast_message
Full name
line.line_multicast_message
ParameterTypeRequiredDescription
to array yes Array of LINE user IDs.
messages array yes Array of LINE message objects.
notification_disabled boolean no Disable push notification when true.
narrowcast_message Write

Send a narrowcast message with recipient and demographic filters.

Lua path
app.integrations.line.narrowcast_message
Full name
line.line_narrowcast_message
ParameterTypeRequiredDescription
messages array yes Array of LINE message objects.
recipient object no Recipient object such as audienceGroupId include/exclude filters.
filter object no Demographic filter object.
notification_disabled boolean no Disable push notification when true.
get_narrowcast_progress Read

Get the progress status of a LINE narrowcast request.

Lua path
app.integrations.line.get_narrowcast_progress
Full name
line.line_get_narrowcast_progress
ParameterTypeRequiredDescription
request_id string yes Narrowcast request ID.
broadcast_message Write

Broadcast a message to all users who have added the LINE Official Account as a friend. Supports all message types.

Lua path
app.integrations.line.broadcast_message
Full name
line.line_broadcast_message
ParameterTypeRequiredDescription
messages array yes Array of message objects to broadcast. Each message must have a "type" (e.g., "text", "image", "flex"). Example: [{"type": "text", "text": "Announcement!"}].
notification_disabled boolean no If true, recipients will not receive push notifications. Default: false.
mark_as_read Write

Mark messages in a LINE chat as read.

Lua path
app.integrations.line.mark_as_read
Full name
line.line_mark_as_read
ParameterTypeRequiredDescription
chat_id string yes LINE user ID, group ID, or room ID.
start_loading_animation Write

Display a LINE loading animation for a chat.

Lua path
app.integrations.line.start_loading_animation
Full name
line.line_start_loading_animation
ParameterTypeRequiredDescription
chat_id string yes LINE chat ID.
loading_seconds integer no Optional loading duration in seconds.
get_message_quota Read

Get the monthly LINE message quota limit.

Lua path
app.integrations.line.get_message_quota
Full name
line.line_get_message_quota
ParameterTypeRequiredDescription
No parameters.
get_message_quota_consumption Read

Get LINE message quota consumption for the current month.

Lua path
app.integrations.line.get_message_quota_consumption
Full name
line.line_get_message_quota_consumption
ParameterTypeRequiredDescription
No parameters.
get_delivery_count Read

Get number of sent LINE messages for reply, push, multicast, or broadcast on a date.

Lua path
app.integrations.line.get_delivery_count
Full name
line.line_get_delivery_count
ParameterTypeRequiredDescription
type string yes Delivery type: reply, push, multicast, or broadcast.
date string yes Date in yyyyMMdd format.
validate_messages Write

Validate LINE message objects for a target send endpoint.

Lua path
app.integrations.line.validate_messages
Full name
line.line_validate_messages
ParameterTypeRequiredDescription
type string yes Validation type: reply, push, multicast, narrowcast, or broadcast.
messages array yes Array of LINE message objects to validate.
set_webhook_endpoint Write

Set the LINE channel webhook endpoint URL.

Lua path
app.integrations.line.set_webhook_endpoint
Full name
line.line_set_webhook_endpoint
ParameterTypeRequiredDescription
endpoint string yes HTTPS webhook endpoint URL.
get_webhook_endpoint Read

Get LINE channel webhook endpoint information.

Lua path
app.integrations.line.get_webhook_endpoint
Full name
line.line_get_webhook_endpoint
ParameterTypeRequiredDescription
No parameters.
test_webhook_endpoint Write

Test the LINE webhook endpoint.

Lua path
app.integrations.line.test_webhook_endpoint
Full name
line.line_test_webhook_endpoint
ParameterTypeRequiredDescription
endpoint string no Optional endpoint URL to test.
get_profile Read

Get the profile information of a LINE user, including display name, profile image URL, status message, and language.

Lua path
app.integrations.line.get_profile
Full name
line.line_get_profile
ParameterTypeRequiredDescription
user_id string yes The LINE user ID to look up (e.g., "U4af4980629...").
list_followers Read

List the friends (followers) of the LINE Official Account. Returns user IDs that can be used with send_message and get_profile.

Lua path
app.integrations.line.list_followers
Full name
line.line_list_friends
ParameterTypeRequiredDescription
limit integer no Maximum number of friends to return (default: 100, max: 1000).
start string no Continuation token from a previous response to fetch the next page of results.
get_bot_info Read

Get the profile of the LINE Official Account (bot) itself, including display name, icon URL, and basic info.

Lua path
app.integrations.line.get_bot_info
Full name
line.line_get_current_user
ParameterTypeRequiredDescription
No parameters.
get_group_summary Read

Get LINE group chat summary information.

Lua path
app.integrations.line.get_group_summary
Full name
line.line_get_group_summary
ParameterTypeRequiredDescription
group_id string yes LINE group ID.
get_group_member_count Read

Get member count for a LINE group chat.

Lua path
app.integrations.line.get_group_member_count
Full name
line.line_get_group_member_count
ParameterTypeRequiredDescription
group_id string yes LINE group ID.
list_group_member_ids Read

List LINE group member user IDs.

Lua path
app.integrations.line.list_group_member_ids
Full name
line.line_list_group_member_ids
ParameterTypeRequiredDescription
group_id string yes LINE group ID.
start string no Continuation token.
get_group_member_profile Read

Get profile information for a LINE group member.

Lua path
app.integrations.line.get_group_member_profile
Full name
line.line_get_group_member_profile
ParameterTypeRequiredDescription
group_id string yes LINE group ID.
user_id string yes LINE user ID.
leave_group Write

Leave a LINE group chat.

Lua path
app.integrations.line.leave_group
Full name
line.line_leave_group
ParameterTypeRequiredDescription
group_id string yes LINE group ID.
create_rich_menu Write

Create a LINE rich menu object.

Lua path
app.integrations.line.create_rich_menu
Full name
line.line_create_rich_menu
ParameterTypeRequiredDescription
rich_menu object yes LINE rich menu object without richMenuId.
validate_rich_menu Write

Validate a LINE rich menu object.

Lua path
app.integrations.line.validate_rich_menu
Full name
line.line_validate_rich_menu
ParameterTypeRequiredDescription
rich_menu object yes LINE rich menu object without richMenuId.
list_rich_menus Read

List LINE rich menus configured for the channel.

Lua path
app.integrations.line.list_rich_menus
Full name
line.line_list_rich_menus
ParameterTypeRequiredDescription
No parameters.
get_rich_menu Read

Get LINE rich menu metadata.

Lua path
app.integrations.line.get_rich_menu
Full name
line.line_get_rich_menu
ParameterTypeRequiredDescription
rich_menu_id string yes LINE rich menu ID.
delete_rich_menu Write

Delete a LINE rich menu by ID.

Lua path
app.integrations.line.delete_rich_menu
Full name
line.line_delete_rich_menu
ParameterTypeRequiredDescription
rich_menu_id string yes Rich menu ID.
set_default_rich_menu Write

Set the default rich menu for all LINE users.

Lua path
app.integrations.line.set_default_rich_menu
Full name
line.line_set_default_rich_menu
ParameterTypeRequiredDescription
rich_menu_id string yes Rich menu ID.
get_default_rich_menu Read

Get the default LINE rich menu ID.

Lua path
app.integrations.line.get_default_rich_menu
Full name
line.line_get_default_rich_menu
ParameterTypeRequiredDescription
No parameters.
clear_default_rich_menu Write

Clear the default LINE rich menu.

Lua path
app.integrations.line.clear_default_rich_menu
Full name
line.line_clear_default_rich_menu
ParameterTypeRequiredDescription
No parameters.
get_user_rich_menu Read

Get the rich menu linked to a LINE user.

Lua path
app.integrations.line.get_user_rich_menu
Full name
line.line_get_user_rich_menu
ParameterTypeRequiredDescription
user_id string yes LINE user ID.