KosmoKrator

productivity

Google Contacts Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write OAuth browser flow auth

Lua Namespace

Agents call this integration through app.integrations.google_contacts.*. Use lua_read_doc("integrations.google_contacts") 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 Contacts — Lua API Reference

list_connections

List the authenticated user’s contacts (connections) from Google Contacts.

Parameters

NameTypeRequiredDescription
pageSizeintegernoNumber of connections per page (1–2000, default 200)
pageTokenstringnoToken from a previous response to get the next page
sortOrderstringno"LAST_NAME_ASCENDING" or "LAST_NAME_DESCENDING"
syncTokenstringnoSync token to return only changed contacts since last sync

Response

Returns an object with:

  • connections — array of contact objects
  • totalItems — total number of contacts
  • nextPageToken — token for the next page (if more results exist)
  • nextSyncToken — token for incremental sync (use on next call)

Each contact includes: resourceName, displayName, givenName, familyName, emailAddresses, phoneNumbers, organization, title, biography, photoUrl.

Example

local result = app.integrations.google_contacts.list_connections({
  pageSize = 50,
  sortOrder = "LAST_NAME_ASCENDING"
})

for _, contact in ipairs(result.connections) do
  print(contact.displayName)
  if contact.emailAddresses then
    for _, email in ipairs(contact.emailAddresses) do
      print("  " .. email.value)
    end
  end
end

Paginated listing

local page_token = nil
repeat
  local result = app.integrations.google_contacts.list_connections({
    pageSize = 200,
    pageToken = page_token
  })

  for _, contact in ipairs(result.connections) do
    print(contact.displayName)
  end

  page_token = result.nextPageToken
until page_token == nil

get_connection

Get detailed information about a specific contact by resource name.

Parameters

NameTypeRequiredDescription
resourceNamestringyesThe resource name (e.g., "people/c123456789")
personFieldsstringnoComma-separated fields to include (default: names,emailAddresses,phoneNumbers,biographies,organizations,photos)

Example

local contact = app.integrations.google_contacts.get_connection({
  resourceName = "people/c123456789"
})

print(contact.displayName)
print(contact.biography or "No notes")

create_contact

Create a new contact in Google Contacts.

Parameters

NameTypeRequiredDescription
givenNamestringno*Given (first) name
familyNamestringno*Family (last) name
emailAddressesarraynoArray of email strings (e.g., {"[email protected]"})
phoneNumbersarraynoArray of phone strings (e.g., {"+1234567890"})
biographystringnoNotes or biography text

*At least givenName or familyName is required.

Example

local result = app.integrations.google_contacts.create_contact({
  givenName = "Jane",
  familyName = "Smith",
  emailAddresses = { "[email protected]" },
  phoneNumbers = { "+15551234567" },
  biography = "Met at the conference"
})

print("Created: " .. result.displayName .. " (" .. result.resourceName .. ")")

list_contact_groups

List all contact groups owned by the user.

Parameters

NameTypeRequiredDescription
pageSizeintegernoNumber of groups per page (1–2000, default 200)
pageTokenstringnoToken from a previous response
syncTokenstringnoSync token for incremental updates

Example

local result = app.integrations.google_contacts.list_contact_groups({
  pageSize = 50
})

for _, group in ipairs(result.contactGroups) do
  print(group.name .. " (" .. group.memberCount .. " members)")
end

get_contact_group

Get details of a specific contact group.

Parameters

NameTypeRequiredDescription
resourceNamestringyesThe resource name (e.g., "contactGroups/myContacts" or "contactGroups/123")

Example

local group = app.integrations.google_contacts.get_contact_group({
  resourceName = "contactGroups/myContacts"
})

print(group.name .. ": " .. group.memberCount .. " members")
for _, member in ipairs(group.memberResourceNames) do
  print("  " .. member)
end

list_other_contacts

List contacts the user has interacted with but not added to a group.

Parameters

NameTypeRequiredDescription
pageSizeintegernoNumber of contacts per page (1–1000, default 200)
pageTokenstringnoToken from a previous response
syncTokenstringnoSync token for incremental updates

Example

local result = app.integrations.google_contacts.list_other_contacts({
  pageSize = 100
})

for _, contact in ipairs(result.otherContacts) do
  print(contact.displayName or "Unknown")
  if contact.emailAddresses then
    for _, email in ipairs(contact.emailAddresses) do
      print("  " .. email)
    end
  end
end

get_current_user

Get the authenticated user’s profile information. Takes no parameters.

Example

local user = app.integrations.google_contacts.get_current_user({})

print("Signed in as: " .. user.displayName)
if user.emailAddresses then
  for _, email in ipairs(user.emailAddresses) do
    print("  " .. email.value .. (email.primary and " (primary)" or ""))
  end
end

Multi-Account Usage

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

-- Default account (always works)
app.integrations.google_contacts.list_connections({...})

-- Explicit default (portable across setups)
app.integrations.google_contacts.default.list_connections({...})

-- Named accounts
app.integrations.google_contacts.work.list_connections({...})
app.integrations.google_contacts.personal.list_connections({...})

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

Raw agent markdown
# Google Contacts — Lua API Reference

## list_connections

List the authenticated user's contacts (connections) from Google Contacts.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `pageSize` | integer | no | Number of connections per page (1–2000, default 200) |
| `pageToken` | string | no | Token from a previous response to get the next page |
| `sortOrder` | string | no | `"LAST_NAME_ASCENDING"` or `"LAST_NAME_DESCENDING"` |
| `syncToken` | string | no | Sync token to return only changed contacts since last sync |

### Response

Returns an object with:
- `connections` — array of contact objects
- `totalItems` — total number of contacts
- `nextPageToken` — token for the next page (if more results exist)
- `nextSyncToken` — token for incremental sync (use on next call)

Each contact includes: `resourceName`, `displayName`, `givenName`, `familyName`, `emailAddresses`, `phoneNumbers`, `organization`, `title`, `biography`, `photoUrl`.

### Example

```lua
local result = app.integrations.google_contacts.list_connections({
  pageSize = 50,
  sortOrder = "LAST_NAME_ASCENDING"
})

for _, contact in ipairs(result.connections) do
  print(contact.displayName)
  if contact.emailAddresses then
    for _, email in ipairs(contact.emailAddresses) do
      print("  " .. email.value)
    end
  end
end
```

### Paginated listing

```lua
local page_token = nil
repeat
  local result = app.integrations.google_contacts.list_connections({
    pageSize = 200,
    pageToken = page_token
  })

  for _, contact in ipairs(result.connections) do
    print(contact.displayName)
  end

  page_token = result.nextPageToken
until page_token == nil
```

---

## get_connection

Get detailed information about a specific contact by resource name.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `resourceName` | string | yes | The resource name (e.g., `"people/c123456789"`) |
| `personFields` | string | no | Comma-separated fields to include (default: names,emailAddresses,phoneNumbers,biographies,organizations,photos) |

### Example

```lua
local contact = app.integrations.google_contacts.get_connection({
  resourceName = "people/c123456789"
})

print(contact.displayName)
print(contact.biography or "No notes")
```

---

## create_contact

Create a new contact in Google Contacts.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `givenName` | string | no* | Given (first) name |
| `familyName` | string | no* | Family (last) name |
| `emailAddresses` | array | no | Array of email strings (e.g., `{"[email protected]"}`) |
| `phoneNumbers` | array | no | Array of phone strings (e.g., `{"+1234567890"}`) |
| `biography` | string | no | Notes or biography text |

*At least `givenName` or `familyName` is required.

### Example

```lua
local result = app.integrations.google_contacts.create_contact({
  givenName = "Jane",
  familyName = "Smith",
  emailAddresses = { "[email protected]" },
  phoneNumbers = { "+15551234567" },
  biography = "Met at the conference"
})

print("Created: " .. result.displayName .. " (" .. result.resourceName .. ")")
```

---

## list_contact_groups

List all contact groups owned by the user.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `pageSize` | integer | no | Number of groups per page (1–2000, default 200) |
| `pageToken` | string | no | Token from a previous response |
| `syncToken` | string | no | Sync token for incremental updates |

### Example

```lua
local result = app.integrations.google_contacts.list_contact_groups({
  pageSize = 50
})

for _, group in ipairs(result.contactGroups) do
  print(group.name .. " (" .. group.memberCount .. " members)")
end
```

---

## get_contact_group

Get details of a specific contact group.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `resourceName` | string | yes | The resource name (e.g., `"contactGroups/myContacts"` or `"contactGroups/123"`) |

### Example

```lua
local group = app.integrations.google_contacts.get_contact_group({
  resourceName = "contactGroups/myContacts"
})

print(group.name .. ": " .. group.memberCount .. " members")
for _, member in ipairs(group.memberResourceNames) do
  print("  " .. member)
end
```

---

## list_other_contacts

List contacts the user has interacted with but not added to a group.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `pageSize` | integer | no | Number of contacts per page (1–1000, default 200) |
| `pageToken` | string | no | Token from a previous response |
| `syncToken` | string | no | Sync token for incremental updates |

### Example

```lua
local result = app.integrations.google_contacts.list_other_contacts({
  pageSize = 100
})

for _, contact in ipairs(result.otherContacts) do
  print(contact.displayName or "Unknown")
  if contact.emailAddresses then
    for _, email in ipairs(contact.emailAddresses) do
      print("  " .. email)
    end
  end
end
```

---

## get_current_user

Get the authenticated user's profile information. Takes no parameters.

### Example

```lua
local user = app.integrations.google_contacts.get_current_user({})

print("Signed in as: " .. user.displayName)
if user.emailAddresses then
  for _, email in ipairs(user.emailAddresses) do
    print("  " .. email.value .. (email.primary and " (primary)" or ""))
  end
end
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations.google_contacts.list_connections({...})

-- Explicit default (portable across setups)
app.integrations.google_contacts.default.list_connections({...})

-- Named accounts
app.integrations.google_contacts.work.list_connections({...})
app.integrations.google_contacts.personal.list_connections({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.google_contacts.google_contacts_list_connections({
  pageSize = 1,
  pageToken = "example_pageToken",
  sortOrder = "example_sortOrder",
  syncToken = "example_syncToken"
})
print(result)

Functions

google_contacts_list_connections

List contacts (connections) from the authenticated user's Google Contacts. Returns names, emails, phone numbers, biographies, organizations, and photos. Supports pagination and incremental sync.

Operation
Read read
Full name
google_contacts.google_contacts_list_connections
ParameterTypeRequiredDescription
pageSize integer no Number of connections to return per page (1–2000, default 200).
pageToken string no Token from a previous response to retrieve the next page of results.
sortOrder string no Sort order for results: "LAST_NAME_ASCENDING" or "LAST_NAME_DESCENDING".
syncToken string no Sync token from a previous list response to return only contacts that changed since then.

google_contacts_get_connection

Get detailed information about a specific contact by resource name (e.g., "people/c123456789"). Returns names, emails, phone numbers, biographies, organizations, and photos.

Operation
Read read
Full name
google_contacts.google_contacts_get_connection
ParameterTypeRequiredDescription
resourceName string yes The resource name of the person to retrieve (e.g., "people/c123456789").
personFields string no Comma-separated person fields to include (default: "names,emailAddresses,phoneNumbers,biographies,organizations,photos").

google_contacts_create_contact

Create a new contact in Google Contacts. Provide at least a name. You can also add email addresses, phone numbers, and a biography (notes).

Operation
Write write
Full name
google_contacts.google_contacts_create_contact
ParameterTypeRequiredDescription
givenName string no Given (first) name of the contact.
familyName string no Family (last) name of the contact.
emailAddresses array no Email addresses. Each entry is a string (e.g., ["[email protected]"]).
phoneNumbers array no Phone numbers. Each entry is a string (e.g., ["+1234567890"]).
biography string no Notes or biography text for the contact.

google_contacts_list_contact_groups

List all contact groups in the user's Google Contacts. Includes system groups (e.g., "My Contacts", "Starred") and user-created groups. Returns group name, type, and member count.

Operation
Read read
Full name
google_contacts.google_contacts_list_contact_groups
ParameterTypeRequiredDescription
pageSize integer no Number of groups to return per page (1–2000, default 200).
pageToken string no Token from a previous response to retrieve the next page.
syncToken string no Sync token from a previous list response to return only groups that changed.

google_contacts_get_contact_group

Get details of a specific contact group by resource name (e.g., "contactGroups/myContacts"). Returns the group name, type, member count, and member resource names.

Operation
Read read
Full name
google_contacts.google_contacts_get_contact_group
ParameterTypeRequiredDescription
resourceName string yes The resource name of the contact group (e.g., "contactGroups/myContacts" or "contactGroups/123").

google_contacts_list_other_contacts

List "Other Contacts" — people the user has interacted with (e.g., via email) but hasn't added to their contacts. Returns names, email addresses, and phone numbers.

Operation
Read read
Full name
google_contacts.google_contacts_list_other_contacts
ParameterTypeRequiredDescription
pageSize integer no Number of contacts to return per page (1–1000, default 200).
pageToken string no Token from a previous response to retrieve the next page.
syncToken string no Sync token from a previous list response to return only changed contacts.

google_contacts_get_current_user

Get the authenticated user's own Google profile information — display name, email addresses, and profile photo.

Operation
Read read
Full name
google_contacts.google_contacts_get_current_user
ParameterTypeRequiredDescription
No parameters.