KosmoKrator

messaging

LINE Messaging Lua API for KosmoKrator Agents

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

5 functions 3 read 2 write Bearer token auth

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.

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

send_message

Send a push message to a specific LINE user, group, or room.

Parameters

NameTypeRequiredDescription
tostringyesLINE user ID, group ID, or room ID
messagesarrayyesArray of message objects (see message types below)
notification_disabledbooleannoSuppress push notification (default: false)

Message Types

Text Message

{ type = "text", text = "Hello, world!" }

Image Message

{ type = "image", originalContentUrl = "https://example.com/image.jpg", previewImageUrl = "https://example.com/preview.jpg" }

Sticker Message

{ type = "sticker", packageId = "446", stickerId = "1988" }

Location Message

{ type = "location", title = "Tokyo Tower", address = "4-2-8 Shibakoen, Minato, Tokyo", latitude = 35.6598, longitude = 139.7394 }

Examples

Send a text message

local result = app.integrations.line.send_message({
  to = "U4af4980629...",
  messages = {
    { type = "text", text = "Hello! This is a message from the bot." }
  }
})

print("Sent " .. result.message_count .. " message(s)")

Send multiple messages

local result = app.integrations.line.send_message({
  to = "U4af4980629...",
  messages = {
    { type = "text", text = "Here is the update:" },
    { type = "sticker", packageId = "446", stickerId = "1988" }
  }
})

broadcast_message

Broadcast a message to all friends of the LINE Official Account.

Parameters

NameTypeRequiredDescription
messagesarrayyesArray of message objects (same types as send_message)
notification_disabledbooleannoSuppress push notification (default: false)

Example

local result = app.integrations.line.broadcast_message({
  messages = {
    { type = "text", text = "📢 New announcement for everyone!" }
  }
})

print("Broadcast sent with " .. result.message_count .. " message(s)")

get_profile

Get the profile information of a LINE user.

Parameters

NameTypeRequiredDescription
user_idstringyesThe LINE user ID (e.g., "U4af4980629...")

Response Fields

FieldDescription
displayNameUser’s display name
userIdLINE user ID
pictureUrlProfile image URL
statusMessageStatus message
languageUser’s language

Example

local result = app.integrations.line.get_profile({
  user_id = "U4af4980629..."
})

print("Name: " .. result.displayName)
print("Status: " .. (result.statusMessage or "none"))

list_friends

List friends (followers) of the LINE Official Account.

Parameters

NameTypeRequiredDescription
limitintegernoMax results per page (default: 100, max: 1000)
startstringnoContinuation token from a previous response

Example

local result = app.integrations.line.list_friends({
  limit = 50
})

for _, user in ipairs(result.friends or {}) do
  print("Friend: " .. (user.displayName or user.userId))
end

-- Paginate
if result.next then
  local next = app.integrations.line.list_friends({
    start = result.next
  })
end

get_current_user

Get the profile of the LINE Official Account (bot) itself.

Parameters

None.

Example

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

print("Bot name: " .. result.displayName)
print("Bot ID: " .. result.userId)

Multi-Account Usage

If you have multiple LINE accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.line.send_message({...})

-- Explicit default (portable across setups)
app.integrations.line.default.send_message({...})

-- Named accounts
app.integrations.line.production.send_message({...})
app.integrations.line.staging.send_message({...})

All functions are identical across accounts — only the credentials differ.

Raw agent markdown
# LINE Messaging — Lua API Reference

## send_message

Send a push message to a specific LINE user, group, or room.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `to` | string | yes | LINE user ID, group ID, or room ID |
| `messages` | array | yes | Array of message objects (see message types below) |
| `notification_disabled` | boolean | no | Suppress push notification (default: `false`) |

### Message Types

#### Text Message

```lua
{ type = "text", text = "Hello, world!" }
```

#### Image Message

```lua
{ type = "image", originalContentUrl = "https://example.com/image.jpg", previewImageUrl = "https://example.com/preview.jpg" }
```

#### Sticker Message

```lua
{ type = "sticker", packageId = "446", stickerId = "1988" }
```

#### Location Message

```lua
{ type = "location", title = "Tokyo Tower", address = "4-2-8 Shibakoen, Minato, Tokyo", latitude = 35.6598, longitude = 139.7394 }
```

### Examples

#### Send a text message

```lua
local result = app.integrations.line.send_message({
  to = "U4af4980629...",
  messages = {
    { type = "text", text = "Hello! This is a message from the bot." }
  }
})

print("Sent " .. result.message_count .. " message(s)")
```

#### Send multiple messages

```lua
local result = app.integrations.line.send_message({
  to = "U4af4980629...",
  messages = {
    { type = "text", text = "Here is the update:" },
    { type = "sticker", packageId = "446", stickerId = "1988" }
  }
})
```

---

## broadcast_message

Broadcast a message to all friends of the LINE Official Account.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `messages` | array | yes | Array of message objects (same types as send_message) |
| `notification_disabled` | boolean | no | Suppress push notification (default: `false`) |

### Example

```lua
local result = app.integrations.line.broadcast_message({
  messages = {
    { type = "text", text = "📢 New announcement for everyone!" }
  }
})

print("Broadcast sent with " .. result.message_count .. " message(s)")
```

---

## get_profile

Get the profile information of a LINE user.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `user_id` | string | yes | The LINE user ID (e.g., `"U4af4980629..."`) |

### Response Fields

| Field | Description |
|-------|-------------|
| `displayName` | User's display name |
| `userId` | LINE user ID |
| `pictureUrl` | Profile image URL |
| `statusMessage` | Status message |
| `language` | User's language |

### Example

```lua
local result = app.integrations.line.get_profile({
  user_id = "U4af4980629..."
})

print("Name: " .. result.displayName)
print("Status: " .. (result.statusMessage or "none"))
```

---

## list_friends

List friends (followers) of the LINE Official Account.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max results per page (default: 100, max: 1000) |
| `start` | string | no | Continuation token from a previous response |

### Example

```lua
local result = app.integrations.line.list_friends({
  limit = 50
})

for _, user in ipairs(result.friends or {}) do
  print("Friend: " .. (user.displayName or user.userId))
end

-- Paginate
if result.next then
  local next = app.integrations.line.list_friends({
    start = result.next
  })
end
```

---

## get_current_user

Get the profile of the LINE Official Account (bot) itself.

### Parameters

None.

### Example

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

print("Bot name: " .. result.displayName)
print("Bot ID: " .. result.userId)
```

---

## Multi-Account Usage

If you have multiple LINE accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.line.send_message({...})

-- Explicit default (portable across setups)
app.integrations.line.default.send_message({...})

-- Named accounts
app.integrations.line.production.send_message({...})
app.integrations.line.staging.send_message({...})
```

All functions are identical across accounts — only the credentials differ.

Metadata-Derived Lua Example

local result = app.integrations.line.line_send_message({
  to = "example_to",
  messages = "example_messages",
  notification_disabled = true
})
print(result)

Functions

line_send_message

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

Operation
Write write
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.

line_broadcast_message

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

Operation
Write write
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.

line_get_profile

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

Operation
Read read
Full name
line.line_get_profile
ParameterTypeRequiredDescription
user_id string yes The LINE user ID to look up (e.g., "U4af4980629...").

line_list_friends

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

Operation
Read read
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.

line_get_current_user

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

Operation
Read read
Full name
line.line_get_current_user
ParameterTypeRequiredDescription
No parameters.