KosmoKrator

communication

Google Chat Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Google Chat KosmoKrator integration.

7 functions 6 read 1 write Manual OAuth token auth

Lua Namespace

Agents call this integration through app.integrations.google_chat.*. Use lua_read_doc("integrations.google-chat") 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.

Google Chat — Lua API Reference

list_spaces

List Google Chat spaces the authenticated user belongs to.

Parameters

NameTypeRequiredDescription
pageSizeintegernoMaximum number of spaces to return (1–1000, default 100)
pageTokenstringnoPage token from a previous response for pagination

Example

local result = app.integrations.google_chat.list_spaces({
  pageSize = 50
})

for _, space in ipairs(result.spaces) do
  print(space.displayName .. " (" .. space.name .. ")")
end

-- Fetch next page if available
if result.nextPageToken then
  local next = app.integrations.google_chat.list_spaces({
    pageSize = 50,
    pageToken = result.nextPageToken
  })
end

get_space

Get details about a specific Google Chat space.

Parameters

NameTypeRequiredDescription
namestringyesResource name of the space (e.g., "spaces/AAAAAAAAAAA")

Example

local space = app.integrations.google_chat.get_space({
  name = "spaces/AAAAAAAAAAA"
})

print("Space: " .. space.displayName)
print("Type: " .. space.spaceType)

list_messages

List messages in a Google Chat space.

Parameters

NameTypeRequiredDescription
parentstringyesResource name of the space (e.g., "spaces/AAAAAAAAAAA")
pageSizeintegernoMaximum number of messages (1–1000, default 1000)
pageTokenstringnoPage token from a previous response for pagination

Example

local result = app.integrations.google_chat.list_messages({
  parent = "spaces/AAAAAAAAAAA",
  pageSize = 50
})

for _, msg in ipairs(result.messages) do
  print(msg.sender.displayName .. ": " .. (msg.text or "[card message]"))
end

get_message

Get a specific message from a Google Chat space.

Parameters

NameTypeRequiredDescription
parentstringyesResource name of the space (e.g., "spaces/AAAAAAAAAAA")
namestringyesResource name of the message, relative to the space (e.g., "messages/BBBBBBBBBBB")

Example

local msg = app.integrations.google_chat.get_message({
  parent = "spaces/AAAAAAAAAAA",
  name = "messages/BBBBBBBBBBB"
})

print(msg.text)

create_message

Send a message to a Google Chat space. Either text or cardsV2 must be provided.

Parameters

NameTypeRequiredDescription
parentstringyesResource name of the space (e.g., "spaces/AAAAAAAAAAA")
textstringnoPlain-text body of the message
cardsV2arraynoArray of card v2 widgets for rich messages

Example — Plain text

local msg = app.integrations.google_chat.create_message({
  parent = "spaces/AAAAAAAAAAA",
  text = "Hello from the AI agent!"
})

print("Sent message: " .. msg.name)

Example — Card message

local msg = app.integrations.google_chat.create_message({
  parent = "spaces/AAAAAAAAAAA",
  cardsV2 = {
    {
      cardId = "status-card",
      card = {
        sections = {
          {
            widgets = {
              {
                textParagraph = {
                  text = "<b>Build Status</b>: Passed ✅"
                }
              }
            }
          }
        }
      }
    }
  }
})

list_memberships

List members (human users and bots) in a Google Chat space.

Parameters

NameTypeRequiredDescription
parentstringyesResource name of the space (e.g., "spaces/AAAAAAAAAAA")
pageSizeintegernoMaximum number of memberships (1–1000, default 1000)
pageTokenstringnoPage token from a previous response for pagination

Example

local result = app.integrations.google_chat.list_memberships({
  parent = "spaces/AAAAAAAAAAA"
})

for _, member in ipairs(result.memberships) do
  print(member.member.displayName .. " — " .. member.role)
end

get_current_user

Get the authenticated user’s membership details in a Google Chat space.

Parameters

NameTypeRequiredDescription
parentstringyesResource name of the space (e.g., "spaces/AAAAAAAAAAA")

Example

local me = app.integrations.google_chat.get_current_user({
  parent = "spaces/AAAAAAAAAAA"
})

print("Display name: " .. me.member.displayName)
print("Role: " .. me.role)

Multi-Account Usage

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

-- Default account (always works)
app.integrations.google_chat.list_spaces({...})

-- Explicit default (portable across setups)
app.integrations.google_chat.default.list_spaces({...})

-- Named accounts
app.integrations.google_chat.work.list_spaces({...})
app.integrations.google_chat.personal.list_spaces({...})

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

Raw agent markdown
# Google Chat — Lua API Reference

## list_spaces

List Google Chat spaces the authenticated user belongs to.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `pageSize` | integer | no | Maximum number of spaces to return (1–1000, default 100) |
| `pageToken` | string | no | Page token from a previous response for pagination |

### Example

```lua
local result = app.integrations.google_chat.list_spaces({
  pageSize = 50
})

for _, space in ipairs(result.spaces) do
  print(space.displayName .. " (" .. space.name .. ")")
end

-- Fetch next page if available
if result.nextPageToken then
  local next = app.integrations.google_chat.list_spaces({
    pageSize = 50,
    pageToken = result.nextPageToken
  })
end
```

---

## get_space

Get details about a specific Google Chat space.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Resource name of the space (e.g., `"spaces/AAAAAAAAAAA"`) |

### Example

```lua
local space = app.integrations.google_chat.get_space({
  name = "spaces/AAAAAAAAAAA"
})

print("Space: " .. space.displayName)
print("Type: " .. space.spaceType)
```

---

## list_messages

List messages in a Google Chat space.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `parent` | string | yes | Resource name of the space (e.g., `"spaces/AAAAAAAAAAA"`) |
| `pageSize` | integer | no | Maximum number of messages (1–1000, default 1000) |
| `pageToken` | string | no | Page token from a previous response for pagination |

### Example

```lua
local result = app.integrations.google_chat.list_messages({
  parent = "spaces/AAAAAAAAAAA",
  pageSize = 50
})

for _, msg in ipairs(result.messages) do
  print(msg.sender.displayName .. ": " .. (msg.text or "[card message]"))
end
```

---

## get_message

Get a specific message from a Google Chat space.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `parent` | string | yes | Resource name of the space (e.g., `"spaces/AAAAAAAAAAA"`) |
| `name` | string | yes | Resource name of the message, relative to the space (e.g., `"messages/BBBBBBBBBBB"`) |

### Example

```lua
local msg = app.integrations.google_chat.get_message({
  parent = "spaces/AAAAAAAAAAA",
  name = "messages/BBBBBBBBBBB"
})

print(msg.text)
```

---

## create_message

Send a message to a Google Chat space. Either `text` or `cardsV2` must be provided.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `parent` | string | yes | Resource name of the space (e.g., `"spaces/AAAAAAAAAAA"`) |
| `text` | string | no | Plain-text body of the message |
| `cardsV2` | array | no | Array of card v2 widgets for rich messages |

### Example — Plain text

```lua
local msg = app.integrations.google_chat.create_message({
  parent = "spaces/AAAAAAAAAAA",
  text = "Hello from the AI agent!"
})

print("Sent message: " .. msg.name)
```

### Example — Card message

```lua
local msg = app.integrations.google_chat.create_message({
  parent = "spaces/AAAAAAAAAAA",
  cardsV2 = {
    {
      cardId = "status-card",
      card = {
        sections = {
          {
            widgets = {
              {
                textParagraph = {
                  text = "<b>Build Status</b>: Passed ✅"
                }
              }
            }
          }
        }
      }
    }
  }
})
```

---

## list_memberships

List members (human users and bots) in a Google Chat space.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `parent` | string | yes | Resource name of the space (e.g., `"spaces/AAAAAAAAAAA"`) |
| `pageSize` | integer | no | Maximum number of memberships (1–1000, default 1000) |
| `pageToken` | string | no | Page token from a previous response for pagination |

### Example

```lua
local result = app.integrations.google_chat.list_memberships({
  parent = "spaces/AAAAAAAAAAA"
})

for _, member in ipairs(result.memberships) do
  print(member.member.displayName .. " — " .. member.role)
end
```

---

## get_current_user

Get the authenticated user's membership details in a Google Chat space.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `parent` | string | yes | Resource name of the space (e.g., `"spaces/AAAAAAAAAAA"`) |

### Example

```lua
local me = app.integrations.google_chat.get_current_user({
  parent = "spaces/AAAAAAAAAAA"
})

print("Display name: " .. me.member.displayName)
print("Role: " .. me.role)
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations.google_chat.list_spaces({...})

-- Explicit default (portable across setups)
app.integrations.google_chat.default.list_spaces({...})

-- Named accounts
app.integrations.google_chat.work.list_spaces({...})
app.integrations.google_chat.personal.list_spaces({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.google_chat.google_chat_list_spaces({
  pageSize = 1,
  pageToken = "example_pageToken"
})
print(result)

Functions

google_chat_list_spaces

List Google Chat spaces the authenticated user belongs to. Returns space names, display names, and types. Supports pagination with pageSize and pageToken.

Operation
Read read
Full name
google-chat.google_chat_list_spaces
ParameterTypeRequiredDescription
pageSize integer no Maximum number of spaces to return (1–1000, default 100).
pageToken string no Page token from a previous list response to fetch the next page of results.

google_chat_get_space

Get details about a specific Google Chat space. Returns the space name, display name, type, and other metadata.

Operation
Read read
Full name
google-chat.google_chat_get_space
ParameterTypeRequiredDescription
name string yes Resource name of the space (e.g., "spaces/AAAAAAAAAAA").

google_chat_list_messages

List messages in a Google Chat space. Returns message text, sender info, and creation timestamps. Supports pagination with pageSize and pageToken.

Operation
Read read
Full name
google-chat.google_chat_list_messages
ParameterTypeRequiredDescription
parent string yes Resource name of the space (e.g., "spaces/AAAAAAAAAAA").
pageSize integer no Maximum number of messages to return (1–1000, default 1000).
pageToken string no Page token from a previous list response to fetch the next page of results.

google_chat_get_message

Get a specific message from a Google Chat space. Returns the full message including text, cards, sender, and annotations.

Operation
Read read
Full name
google-chat.google_chat_get_message
ParameterTypeRequiredDescription
parent string yes Resource name of the space (e.g., "spaces/AAAAAAAAAAA").
name string yes Resource name of the message, relative to the space (e.g., "messages/BBBBBBBBBBB").

google_chat_create_message

Send a message to a Google Chat space. Supports plain text and card-based rich messages (cardsV2). Either text or cardsV2 must be provided.

Operation
Write write
Full name
google-chat.google_chat_create_message
ParameterTypeRequiredDescription
parent string yes Resource name of the space to send the message to (e.g., "spaces/AAAAAAAAAAA").
text string no Plain-text body of the message.
cardsV2 array no Array of card widgets in Google Chat card v2 format for rich messages. Each entry must have a "cardId" and "card" with "sections".

google_chat_list_memberships

List members (human users and bots) in a Google Chat space. Returns member names, display names, and roles. Supports pagination with pageSize and pageToken.

Operation
Read read
Full name
google-chat.google_chat_list_memberships
ParameterTypeRequiredDescription
parent string yes Resource name of the space (e.g., "spaces/AAAAAAAAAAA").
pageSize integer no Maximum number of memberships to return (1–1000, default 1000).
pageToken string no Page token from a previous list response to fetch the next page of results.

google_chat_get_current_user

Get the authenticated user's membership details in a Google Chat space. Returns the user's display name, role, and membership state.

Operation
Read read
Full name
google-chat.google_chat_get_current_user
ParameterTypeRequiredDescription
parent string yes Resource name of the space (e.g., "spaces/AAAAAAAAAAA").