KosmoKrator

productivity

Google Forms Lua API for KosmoKrator Agents

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

7 functions 5 read 2 write Manual OAuth token auth

Lua Namespace

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

list_forms

List Google Forms owned by the authenticated user.

Parameters

NameTypeRequiredDescription
pageSizeintegernoMax forms per page (default: 20, max: 100)
pageTokenstringnoToken from a previous response to fetch the next page
filterstringnoFilter expression, e.g. "creator_email = '[email protected]'"

Examples

local result = app.integrations.google-forms.list_forms()

for _, form in ipairs(result.forms) do
  print(form.formId .. ": " .. (form.info.title or "Untitled"))
end

Paginated

local result = app.integrations.google-forms.list_forms({ pageSize = 10 })

if result.nextPageToken then
  local next = app.integrations.google-forms.list_forms({ pageToken = result.nextPageToken })
end

get_form

Get the full details of a specific Google Form, including questions and settings.

Parameters

NameTypeRequiredDescription
idstringyesThe form ID

Examples

local form = app.integrations.google-forms.get_form({ id = "FORM_ID" })

print("Title: " .. form.info.title)
print("Questions:")

for _, item in ipairs(form.items) do
  print("  - " .. item.title .. " (" .. item.questionItem.question.questionId .. ")")
end

create_form

Create a new Google Form.

Parameters

NameTypeRequiredDescription
infoobjectnoFull form info object (JSON) for advanced creation
titlestringnoTitle shown at the top of the form
descriptionstringnoDescription shown below the title
documentTitlestringnoTitle shown in Google Drive

Examples

local result = app.integrations.google-forms.create_form({
  title = "Customer Feedback Survey",
  description = "Please share your experience with our service.",
  documentTitle = "Q1 2026 Customer Feedback"
})

print("Created form: " .. result.formId)
print("Edit URL: " .. result.responderUri)

With pre-configured questions

local result = app.integrations.google-forms.create_form({
  info = {
    title = "Event RSVP",
    description = "Please confirm your attendance.",
    documentTitle = "Annual Meetup RSVP",
    items = {
      {
        title = "Will you attend?",
        questionItem = {
          question = {
            required = true,
            choiceQuestion = {
              type = "RADIO",
              options = {
                { value = "Yes" },
                { value = "No" },
                { value = "Maybe" }
              }
            }
          }
        }
      },
      {
        title = "Dietary restrictions?",
        questionItem = {
          question = {
            required = false,
            textQuestion = {
              paragraph = false
            }
          }
        }
      }
    }
  }
})

list_responses

List responses submitted to a Google Form.

Parameters

NameTypeRequiredDescription
idstringyesThe form ID
pageSizeintegernoMax responses per page
pageTokenstringnoToken from a previous response to fetch the next page
filterstringnoFilter expression, e.g. "timestamp >= 1234567890"

Examples

local result = app.integrations.google-forms.list_responses({ id = "FORM_ID" })

for _, response in ipairs(result.responses) do
  print("Response " .. response.responseId .. " at " .. response.lastSubmittedTime)

  for qid, answer in pairs(response.answers) do
    print("  Q: " .. qid)
    for _, a in ipairs(answer.textAnswers.answers) do
      print("    A: " .. a.value)
    end
  end
end

Filter by date

local result = app.integrations.google-forms.list_responses({
  id = "FORM_ID",
  filter = "timestamp >= 1711929600"
})

get_response

Get a specific form response by ID.

Parameters

NameTypeRequiredDescription
form_idstringyesThe form ID
idstringyesThe response ID

Examples

local response = app.integrations.google-forms.get_response({
  form_id = "FORM_ID",
  id = "RESPONSE_ID"
})

for qid, answer in pairs(response.answers) do
  print(qid .. ": " .. answer.textAnswers.answers[1].value)
end

create_response

Submit a response to a Google Form.

Parameters

NameTypeRequiredDescription
idstringyesThe form ID
answersobjectyesMap of question IDs to answer objects

Answer Format

Each answer should follow this structure:

{
  "QUESTION_ID": {
    "textAnswers": {
      "answers": [
        { "value": "your answer" }
      ]
    }
  }
}

Examples

local result = app.integrations.google-forms.create_response({
  id = "FORM_ID",
  answers = {
    ["QUESTION_ID_1"] = {
      textAnswers = {
        answers = {
          { value = "Yes" }
        }
      }
    },
    ["QUESTION_ID_2"] = {
      textAnswers = {
        answers = {
          { value = "Great experience, thank you!" }
        }
      }
    }
  }
})

print("Submitted response: " .. result.responseId)

get_current_user

Get the authenticated Google user’s profile.

Parameters

None.

Examples

local user = app.integrations.google-forms.get_current_user()

print("Email: " .. user.email)
print("Name: " .. (user.displayName or "N/A"))

Multi-Account Usage

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

-- Default account (always works)
app.integrations.google-forms.function_name({...})

-- Explicit default (portable across setups)
app.integrations.google-forms.default.function_name({...})

-- Named accounts
app.integrations.google-forms.work.function_name({...})
app.integrations.google-forms.personal.function_name({...})

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

Raw agent markdown
# Google Forms — Lua API Reference

## list_forms

List Google Forms owned by the authenticated user.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `pageSize` | integer | no | Max forms per page (default: 20, max: 100) |
| `pageToken` | string | no | Token from a previous response to fetch the next page |
| `filter` | string | no | Filter expression, e.g. `"creator_email = '[email protected]'"` |

### Examples

```lua
local result = app.integrations.google-forms.list_forms()

for _, form in ipairs(result.forms) do
  print(form.formId .. ": " .. (form.info.title or "Untitled"))
end
```

### Paginated

```lua
local result = app.integrations.google-forms.list_forms({ pageSize = 10 })

if result.nextPageToken then
  local next = app.integrations.google-forms.list_forms({ pageToken = result.nextPageToken })
end
```

---

## get_form

Get the full details of a specific Google Form, including questions and settings.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The form ID |

### Examples

```lua
local form = app.integrations.google-forms.get_form({ id = "FORM_ID" })

print("Title: " .. form.info.title)
print("Questions:")

for _, item in ipairs(form.items) do
  print("  - " .. item.title .. " (" .. item.questionItem.question.questionId .. ")")
end
```

---

## create_form

Create a new Google Form.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `info` | object | no | Full form info object (JSON) for advanced creation |
| `title` | string | no | Title shown at the top of the form |
| `description` | string | no | Description shown below the title |
| `documentTitle` | string | no | Title shown in Google Drive |

### Examples

```lua
local result = app.integrations.google-forms.create_form({
  title = "Customer Feedback Survey",
  description = "Please share your experience with our service.",
  documentTitle = "Q1 2026 Customer Feedback"
})

print("Created form: " .. result.formId)
print("Edit URL: " .. result.responderUri)
```

### With pre-configured questions

```lua
local result = app.integrations.google-forms.create_form({
  info = {
    title = "Event RSVP",
    description = "Please confirm your attendance.",
    documentTitle = "Annual Meetup RSVP",
    items = {
      {
        title = "Will you attend?",
        questionItem = {
          question = {
            required = true,
            choiceQuestion = {
              type = "RADIO",
              options = {
                { value = "Yes" },
                { value = "No" },
                { value = "Maybe" }
              }
            }
          }
        }
      },
      {
        title = "Dietary restrictions?",
        questionItem = {
          question = {
            required = false,
            textQuestion = {
              paragraph = false
            }
          }
        }
      }
    }
  }
})
```

---

## list_responses

List responses submitted to a Google Form.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The form ID |
| `pageSize` | integer | no | Max responses per page |
| `pageToken` | string | no | Token from a previous response to fetch the next page |
| `filter` | string | no | Filter expression, e.g. `"timestamp >= 1234567890"` |

### Examples

```lua
local result = app.integrations.google-forms.list_responses({ id = "FORM_ID" })

for _, response in ipairs(result.responses) do
  print("Response " .. response.responseId .. " at " .. response.lastSubmittedTime)

  for qid, answer in pairs(response.answers) do
    print("  Q: " .. qid)
    for _, a in ipairs(answer.textAnswers.answers) do
      print("    A: " .. a.value)
    end
  end
end
```

### Filter by date

```lua
local result = app.integrations.google-forms.list_responses({
  id = "FORM_ID",
  filter = "timestamp >= 1711929600"
})
```

---

## get_response

Get a specific form response by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `form_id` | string | yes | The form ID |
| `id` | string | yes | The response ID |

### Examples

```lua
local response = app.integrations.google-forms.get_response({
  form_id = "FORM_ID",
  id = "RESPONSE_ID"
})

for qid, answer in pairs(response.answers) do
  print(qid .. ": " .. answer.textAnswers.answers[1].value)
end
```

---

## create_response

Submit a response to a Google Form.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The form ID |
| `answers` | object | yes | Map of question IDs to answer objects |

### Answer Format

Each answer should follow this structure:

```json
{
  "QUESTION_ID": {
    "textAnswers": {
      "answers": [
        { "value": "your answer" }
      ]
    }
  }
}
```

### Examples

```lua
local result = app.integrations.google-forms.create_response({
  id = "FORM_ID",
  answers = {
    ["QUESTION_ID_1"] = {
      textAnswers = {
        answers = {
          { value = "Yes" }
        }
      }
    },
    ["QUESTION_ID_2"] = {
      textAnswers = {
        answers = {
          { value = "Great experience, thank you!" }
        }
      }
    }
  }
})

print("Submitted response: " .. result.responseId)
```

---

## get_current_user

Get the authenticated Google user's profile.

### Parameters

None.

### Examples

```lua
local user = app.integrations.google-forms.get_current_user()

print("Email: " .. user.email)
print("Name: " .. (user.displayName or "N/A"))
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations.google-forms.function_name({...})

-- Explicit default (portable across setups)
app.integrations.google-forms.default.function_name({...})

-- Named accounts
app.integrations.google-forms.work.function_name({...})
app.integrations.google-forms.personal.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.google_forms.gforms_list_forms({
  pageSize = 1,
  pageToken = "example_pageToken",
  filter = "example_filter"
})
print(result)

Functions

gforms_list_forms

List Google Forms owned by the authenticated user. Returns form IDs, titles, and metadata. Supports pagination and filtering.

Operation
Read read
Full name
google-forms.gforms_list_forms
ParameterTypeRequiredDescription
pageSize integer no Maximum number of forms to return per page (default: 20, max: 100).
pageToken string no Token from a previous response to fetch the next page of results.
filter string no Filter expression. Example: "creator_email = '[email protected]'" to filter by creator.

gforms_get_form

Get the full details of a specific Google Form, including its questions, layout, and settings.

Operation
Read read
Full name
google-forms.gforms_get_form
ParameterTypeRequiredDescription
id string yes The form ID (found in the form URL or from list_forms).

gforms_create_form

Create a new Google Form. Provide a title and optional description. The form will appear in the authenticated user's Google Drive.

Operation
Write write
Full name
google-forms.gforms_create_form
ParameterTypeRequiredDescription
info object no Full form info object (JSON). Use this for advanced form creation with questions pre-configured.
title string no The title of the form. Shown at the top of the form.
description string no A description of the form's purpose. Shown below the title.
documentTitle string no The title shown in Google Drive. Defaults to the form title if not set.

gforms_list_responses

List responses submitted to a Google Form. Returns answers, timestamps, and respondent metadata. Supports pagination and filtering by date.

Operation
Read read
Full name
google-forms.gforms_list_responses
ParameterTypeRequiredDescription
id string yes The form ID to list responses for.
pageSize integer no Maximum number of responses to return per page.
pageToken string no Token from a previous response to fetch the next page.
filter string no Filter expression. Example: "timestamp >= 1234567890" to filter by submission time (Unix epoch).

gforms_get_response

Get a specific form response by ID. Returns all answers, the submission timestamp, and respondent metadata.

Operation
Read read
Full name
google-forms.gforms_get_response
ParameterTypeRequiredDescription
form_id string yes The form ID.
id string yes The response ID.

gforms_create_response

Submit a response to a Google Form. Provide answers keyed by question ID. Use get_form first to discover question IDs and their types.

Operation
Write write
Full name
google-forms.gforms_create_response
ParameterTypeRequiredDescription
id string yes The form ID to submit a response to.
answers object yes Object mapping question IDs to answer objects. Each answer should have the format: {"textAnswers": {"answers": [{"value": "your answer"}]}}.

gforms_get_current_user

Get the authenticated Google user's profile — email, display name, and profile photo. Use this to verify the connected account.

Operation
Read read
Full name
google-forms.gforms_get_current_user
ParameterTypeRequiredDescription
No parameters.