All connectors
Google Forms
Official
Google Forms
Let agents collect what people told you and turn it into summaries, follow-ups and reports.
- Read a form's questions and settings, and every response submitted to it.
- Check for new responses since the last time an agent looked.
- With Write access: create forms, add, edit, reorder and remove questions, turn forms into quizzes, and open or close them to new responses.
Agents work with a form when you share its edit link. To let them search your Drive for forms, also connect Google Drive. Responses cannot be changed or deleted, and read access cannot change your forms.
Setup instructions
Setup instructions
Connect your Google account
- Choose the level for Access:
- Read to let agents read forms and their responses without changing anything.
- Write to also let agents create forms, edit their questions and settings, and open or close them to responses.
- Select Continue with Google, choose your account, and approve the permissions Google lists. If Google shows a checkbox per permission, tick them all: Houston refuses a partial grant.
The connection can open every form your Google account can edit, but nothing else in your Drive; connecting Google Forms does not grant access to your other Google services.
Advanced: changing access and troubleshooting
- To change the access level, edit the connection and connect with Google again. Google then asks for the new set of permissions.
- To revoke access, remove the connection in Houston, or remove Houston from your Google Account's third-party connections.
- Google Workspace administrators can block third-party apps. If Google refuses the connection, ask your administrator to allow Houston.
- An agent that cannot open a form may have been given its responder link (it
contains
/forms/d/e/and ends in/viewform) or aforms.gleshort link. Share the edit link instead, from the address bar while editing the form. - Older forms without Google's current publishing settings can be read and edited, but agents cannot open or close them to responses. Do that in Google Forms instead.
Files
Files
connector.luau
-- Google Forms API v1. Arguments and results keep Google's native field names. local API = "https://forms.googleapis.com/v1" -- Request layer shared verbatim by the Google connectors (tools/validate checks they match). type Options = {[string]: any} type Endpoint = {method: string, path: string, access: string?, query: {string}?, body: boolean?, defaults: Options?, list: string?, required: {[string]: string}?, help: string} local function text(value: any, field: string): string assert(type(value) == "string" and value ~= "", field .. " must be a nonempty string") return value end local function options(value: any): Options if value == nil then return {} end assert(type(value) == "table", "opts must be an object") for key in value do assert(type(key) == "string", "opts must have named fields") end return table.clone(value) end -- Moves the named fields from args into a query string; arrays repeat the key. local function query(args: Options, names: {string}): string local parts: {string} = {} for _, name in names do local value = args[name] args[name] = nil for key, item in (if type(value) == "table" then value else {value}) do assert(type(key) == "number" and (type(item) == "string" or type(item) == "number" or type(item) == "boolean"), name .. " must be a string, number, boolean or an array of them") table.insert(parts, url.encode(name) .. "=" .. url.encode(item)) end end return if #parts > 0 then "?" .. table.concat(parts, "&") else "" end -- Older APIs name the reason in errors[], newer ones in an ErrorInfo detail. local function reasonOf(problem: any): string? for _, list in {problem.errors, problem.details} :: {any} do if type(list) == "table" then for _, item in list do if type(item) == "table" and type(item.reason) == "string" then return item.reason end end end end return nil end local function fail(operation: string, response: HttpResponse): never local ok, decoded = pcall(json.decode, await(response.body:readPrefix(4096))) local problem = if ok and type(decoded) == "table" and type(decoded.error) == "table" then decoded.error else {} local reason = reasonOf(problem) local message = "Google HTTP " .. tostring(response.statusCode) if type(problem.status) == "string" then message ..= " (" .. problem.status .. ")" end if type(problem.message) == "string" then message ..= ": " .. string.sub(problem.message, 1, 600) end if reason then message ..= " [" .. reason .. "]" end local retry = response.headers["retry-after"] if retry and retry[1] then message ..= "; Retry-After: " .. retry[1] end local limited = reason ~= nil and string.find(string.lower(reason), "ratelimitexceeded", 1, true) ~= nil return houston.fail({operation = operation, layer = "upstream", upstream_status = response.statusCode, retryable = response.statusCode == 429 or response.statusCode >= 500 or limited, message = message}) end local function decode(operation: string, response: HttpResponse): any if response.statusCode < 200 or response.statusCode >= 300 then fail(operation, response) end local raw = await(response.body:readAll()) if raw == "" then return {success = true} end local ok, value = pcall(json.decode, raw) if not ok or type(value) ~= "table" or not string.match(raw, "^%s*{") then houston.fail({operation = operation, layer = "upstream", upstream_status = response.statusCode, retryable = false, message = "Google returned an invalid JSON object"}) end return value end local function call(operation: string, method: string, href: string, body: any?): any return decode(operation, await(http.request({method = method, url = href, headers = if body ~= nil then {["Content-Type"] = {"application/json"}} else nil, body = if body ~= nil then json.encode(body) else nil}))) end -- Accepts a docs.google.com editor URL in place of its file ID; published and responder links (/d/e/...) carry no ID. local function docsId(value: any, product: string, field: string): any if type(value) ~= "string" then return value end local rest = string.match(value, "^https://docs%.google%.com/" .. product .. "/d/(.*)$") or string.match(value, "^https://docs%.google%.com/" .. product .. "/u/%d+/d/(.*)$") or string.match(value, "^https://docs%.google%.com/a/[^/]+/" .. product .. "/d/(.*)$") local id: string = if rest then string.match(rest, "^[^/?#]*") or "" else value assert(string.match(id, "^[%w_%-]+$") and id ~= "e", field .. " must be an ID or its https://docs.google.com/" .. product .. "/d/<id> URL") return id end -- Moves {placeholders} and declared query fields from args into the URL; remaining fields form the JSON body. local function target(name: string, endpoint: Endpoint, args: Options): string local defaults: Options = endpoint.defaults or {} for key, value in defaults do if args[key] == nil then args[key] = value end end local required: {[string]: string} = endpoint.required or {} for field, kind in required do local value = args[field] assert(if kind == "array" then type(value) == "table" and value[1] ~= nil elseif kind == "string" then type(value) == "string" and value ~= "" elseif kind == "object" then type(value) == "table" and next(value) ~= nil and value[1] == nil else false, name .. " requires " .. field .. " as a nonempty " .. kind) end local path = string.gsub(endpoint.path, "{(%w+)}", function(field: string) local value = url.segment(text(args[field], field), field) args[field] = nil return value end) path ..= query(args, endpoint.query or {}) if not endpoint.body then assert(next(args) == nil, name .. " received an unknown option") end return API .. path end local function invoke(name: string, endpoint: Endpoint, input: any): any local args = options(input) local result = call(name, endpoint.method, target(name, endpoint, args), if endpoint.body then args else nil) if endpoint.list and result[endpoint.list] == nil then result[endpoint.list] = json.decode("[]") end return result end local exports: {[string]: any} = {} local help: {[string]: string} = {} -- Exposes an operation when the connection allows the access it needs, if any. local function export(name: string, access: string?, fn: (any) -> any, doc: string) if access == nil or houston.allows(access) then exports[name], help[name] = fn, doc end end local function exportEndpoints(endpoints: {[string]: Endpoint}) for name, endpoint in endpoints do export(name, endpoint.access, function(args: Options?): any return invoke(name, endpoint, args) end, endpoint.help) end end -- help() introduces the API, then documents exactly the configured operations. local function helpWith(overview: {string}): () -> string return function(): string local names: {string} = {} for name in help do table.insert(names, name) end table.sort(names) local lines = table.clone(overview) for _, name in names do table.insert(lines, help[name]) end return table.concat(lines, "\n") end end -- End of the shared request layer. local RESPONSE = "{responseId, createTime, lastSubmittedTime, respondentEmail?, totalScore?, answers?={[questionId]={questionId, textAnswers?={answers={{value}}}, fileUploadAnswers?={answers={{fileId, fileName, mimeType}}}, grade?}}}" local endpoints: {[string]: Endpoint} = { getForm = {method = "GET", path = "/forms/{formId}", list = "items", help = "getForm({formId}) -> {formId, info={title, documentTitle, description?}, settings, revisionId, responderUri, linkedSheetId?, publishSettings?={publishState={isPublished, isAcceptingResponses}}, items=[{itemId, title?, description?, questionItem?={question={questionId, required?, choiceQuestion?, textQuestion?, scaleQuestion?, dateQuestion?, timeQuestion?, ratingQuestion?, fileUploadQuestion?, grading?}}, questionGroupItem?={questions=[{questionId, rowQuestion={title}}], grid}, pageBreakItem?, textItem?, imageItem?, videoItem?}]}. items are in display order and [] for an empty form. responderUri is the link respondents open; linkedSheetId is the spreadsheet collecting responses, readable with the Google Sheets connector. Legacy forms have no publishSettings."}, listResponses = {method = "GET", path = "/forms/{formId}/responses", list = "responses", query = {"filter", "pageSize", "pageToken"}, help = "listResponses({formId, filter?, pageSize?, pageToken?}) -> {responses=[" .. RESPONSE .. "], nextPageToken?}. responses is [] when none match; Google does not document their order. filter accepts only 'timestamp > T' or 'timestamp >= T', with T in RFC 3339 UTC such as 2026-10-01T00:00:00Z, compared with the submission time. To fetch new responses later, keep the largest lastSubmittedTime and pass filter='timestamp >= <it>', skipping responseIds already handled: a respondent who edits a response sends it again with a later lastSubmittedTime. A page holds up to 5000 responses; lower pageSize for long answers, since pages over 8 MiB fail. Pass nextPageToken as pageToken with the same filter until it is absent."}, getResponse = {method = "GET", path = "/forms/{formId}/responses/{responseId}", help = "getResponse({formId, responseId}) -> " .. RESPONSE .. ", plus formId."}, createForm = {method = "POST", path = "/forms", access = "data:write", body = true, defaults = {unpublished = true}, query = {"unpublished"}, required = {info = "object"}, list = "items", help = "createForm({info={title, documentTitle?}, unpublished?}) -> the new form, with formId, responderUri and revisionId. Google accepts only title and documentTitle, the file name in Drive, which batchUpdate cannot change later; add the description, questions and settings with batchUpdate. The form is created unpublished, so it accepts no responses: publish it with setPublishSettings once its questions are ready, or pass unpublished=false."}, batchUpdate = {method = "POST", path = "/forms/{formId}:batchUpdate", access = "data:write", body = true, required = {requests = "array"}, help = "batchUpdate({formId, requests, includeFormInResponse?, writeControl?}) -> {replies, writeControl, form?}. Applies requests in order, all or nothing; replies match requests one to one, and a createItem reply is {createItem={itemId, questionId={...}}}. Kinds: createItem={item, location={index}}, updateItem={item, location={index}, updateMask}, deleteItem={location={index}}, moveItem={originalLocation={index}, newLocation={index}}, updateFormInfo={info, updateMask} and updateSettings={settings, updateMask}. Indexes are zero-based positions in items, after the earlier requests of the batch apply. updateMask is required: 'description', 'title,description' or '*' for all fields. Example: requests={{updateFormInfo={info={description='Team lunch survey'}, updateMask='description'}}, {createItem={item={title='Which day?', questionItem={question={required=true, choiceQuestion={type='RADIO', options={{value='Tuesday'}, {value='Thursday'}}}}}}, location={index=0}}}}. Questions: choiceQuestion={type='RADIO'|'CHECKBOX'|'DROP_DOWN', options, shuffle?}, textQuestion={paragraph?}, scaleQuestion={low, high, lowLabel?, highLabel?}, dateQuestion={includeTime?, includeYear?}, timeQuestion={duration?}, ratingQuestion={ratingScaleLevel, iconType='STAR'|'HEART'|'THUMB_UP'}; file upload questions cannot be created. Quizzes: updateSettings={settings={quizSettings={isQuiz=true}}, updateMask='quizSettings.isQuiz'}, then question.grading={pointValue, correctAnswers={answers={{value}}}}. settings.emailCollectionType is DO_NOT_COLLECT, VERIFIED or RESPONDER_INPUT."}, setPublishSettings = {method = "POST", path = "/forms/{formId}:setPublishSettings", access = "data:write", body = true, required = {publishSettings = "object"}, help = "setPublishSettings({formId, publishSettings={publishState={isPublished, isAcceptingResponses}}, updateMask?}) -> {formId, publishSettings}. Both flags are required: {isPublished=true, isAcceptingResponses=true} publishes the form and accepts responses from those it is shared with, isAcceptingResponses=false closes it to new responses, and isPublished=false unpublishes it. updateMask accepts 'publish_state' or '*'. Legacy forms without publishSettings fail."}, } for name, endpoint in endpoints do export(name, endpoint.access, function(input: any): any local args = options(input) if string.find(endpoint.path, "{formId}", 1, true) then args.formId = docsId(args.formId, "forms", "formId") else assert(args.formId == nil, name .. " assigns the formId") end return invoke(name, endpoint, args) end, endpoint.help) end local overview = { "Google Forms API v1. Operations take one named options object with Google's camelCase fields and return Google's JSON unchanged. Calls return completed values: use instance.getForm(...) directly, without await.", "formId is the ID or the form's https://docs.google.com/forms/d/<id>/edit URL. Responder links (https://docs.google.com/forms/d/e/.../viewform) and forms.gle links carry no form ID: ask for the edit link. This connector cannot search for forms: ask for the link, or find the ID with the Google Drive connector (listFiles with q=\"mimeType = 'application/vnd.google-apps.form' and trashed = false\"). The account needs access to the form itself in Drive: being able to fill it in is not enough.", "Answers are keyed by questionId, not question text: read the form once with getForm and map each item.questionItem.question.questionId, and each questionGroupItem.questions[i].questionId, to its title. Every answer value is a string: a choice's text (one value per ticked box), the number picked on a scale, dates as '2026-10-21' or '10-21' without a year, with ' 14:51' when the question asks for a time. File upload answers carry Google Drive fileIds; download them with the Google Drive connector.", "No hidden paging or retries. Errors report the HTTP status and Google's message. Google allows about 390 reads, 180 listResponses and 150 writes per minute per user, and 975, 450 and 375 per minute across all Houston users; HTTP 429 errors are retryable after a pause.", } if houston.allows("data:write") then table.insert(overview, "Writes change a form's content, settings and publishing. An empty Luau table encodes as a JSON object: write an empty array, such as options, as json.decode('[]'). Responses cannot be submitted, edited or deleted, and forms cannot be deleted, renamed in Drive or shared here, including choosing who may respond: use Google Forms or the Google Drive connector. A failed or timed-out write may already have succeeded: check with getForm before repeating it, or pass writeControl={requiredRevisionId=form.revisionId} from getForm to batchUpdate, so a repeat fails with HTTP 400 instead of applying twice.") end exports.help = helpWith(overview) return exportshouston.json
{ "schema_version": 2, "name": "Google Forms", "files": [ "connector.luau" ], "icon": "icon.svg", "access": [ { "name": "data", "label": "Access", "levels": [ { "value": "read", "label": "Read" }, { "value": "write", "label": "Write" } ], "default": "read" } ], "auth": { "oauth": { "type": "oauth2", "label": "Connect with Google", "brand": "google", "authorize_url": "https://accounts.google.com/o/oauth2/v2/auth", "token_url": "https://oauth2.googleapis.com/token", "client_id": "{{publisher.client_id}}", "client_secret": "{{publisher.client_secret}}", "client_auth": "body", "pkce": "S256", "require_refresh": true, "authorize_params": { "access_type": "offline", "include_granted_scopes": "false", "prompt": "consent" }, "scopes": [ { "values": [ "https://www.googleapis.com/auth/userinfo.email" ] }, { "if": "{{ is access.data \"read\" }}", "values": [ "https://www.googleapis.com/auth/forms.body.readonly", "https://www.googleapis.com/auth/forms.responses.readonly" ] }, { "if": "{{ is access.data \"write\" }}", "values": [ "https://www.googleapis.com/auth/forms.body", "https://www.googleapis.com/auth/forms.responses.readonly" ] } ], "account": { "method": "GET", "url": "https://www.googleapis.com/oauth2/v2/userinfo", "headers": { "Authorization": { "value": "Bearer {{auth.oauth.access_token}}" } }, "label": "/email" } } }, "publisher": { "client_id": { "type": "string", "label": "Google OAuth client ID", "required": true, "order": 1 }, "client_secret": { "type": "secret", "label": "Google OAuth client secret", "required": true, "order": 2 } }, "proxy": [ { "match": { "protocol": "http", "host": [ "forms.googleapis.com" ], "method": [ "GET" ], "path": [ "/v1/forms/{formId}", "/v1/forms/{formId}/responses", "/v1/forms/{formId}/responses/{responseId}" ] }, "action": { "headers": { "set": { "Authorization": "Bearer {{auth.oauth.access_token}}" } } } }, { "if": "{{ allows access.data \"write\" }}", "match": { "protocol": "http", "host": [ "forms.googleapis.com" ], "method": [ "POST" ], "path": [ "/v1/forms", "/v1/forms/{formId}:batchUpdate", "/v1/forms/{formId}:setPublishSettings" ] }, "action": { "headers": { "set": { "Authorization": "Bearer {{auth.oauth.access_token}}" } } } } ] }icon.svg
README.md
--- description: Read responses and build forms in Google Forms. --- # Google Forms Let agents collect what people told you and turn it into summaries, follow-ups and reports. - Read a form's questions and settings, and every response submitted to it. - Check for new responses since the last time an agent looked. - With **Write** access: create forms, add, edit, reorder and remove questions, turn forms into quizzes, and open or close them to new responses. Agents work with a form when you share its edit link. To let them search your Drive for forms, also connect Google Drive. Responses cannot be changed or deleted, and read access cannot change your forms.SETUP.md
# Connect your Google account 1. Choose the level for **Access**: - **Read** to let agents read forms and their responses without changing anything. - **Write** to also let agents create forms, edit their questions and settings, and open or close them to responses. 2. Select **Continue with Google**, choose your account, and approve the permissions Google lists. If Google shows a checkbox per permission, tick them all: Houston refuses a partial grant. The connection can open every form your Google account can edit, but nothing else in your Drive; connecting Google Forms does not grant access to your other Google services. ## Advanced: changing access and troubleshooting - To change the access level, edit the connection and connect with Google again. Google then asks for the new set of permissions. - To revoke access, remove the connection in Houston, or remove Houston from [your Google Account's third-party connections](https://myaccount.google.com/connections). - Google Workspace administrators can block third-party apps. If Google refuses the connection, ask your administrator to allow Houston. - An agent that cannot open a form may have been given its responder link (it contains `/forms/d/e/` and ends in `/viewform`) or a `forms.gle` short link. Share the edit link instead, from the address bar while editing the form. - Older forms without Google's current publishing settings can be read and edited, but agents cannot open or close them to responses. Do that in Google Forms instead.tests
authentication.luau
return { contract = function(m) m.authentication({ { auth = {}, config = {}, endpoint = { "GET", "https://forms.googleapis.com/v1/forms/f1" }, expected = "Bearer synthetic-oauth-token", header = "Authorization", method = "oauth", oauth = true, publisher = { client_id = "synthetic-public-client", client_secret = "synthetic-client-secret", }, scopes = true, }, }) end, }endpoints.luau
return { contract = function(m) m.endpointRules() end, }errors.luau
return { scenario = {publisher = {client_id = "fixture-client", client_secret = "fixture-private-secret"}, config = {}, auth_method = "oauth", auth_config = {}}, access = {data = "write"}, configure = function() calls, status, payload, responseHeaders = 0, 200, "{}", {} http = {request = function(req) calls += 1 return fixture.operation({statusCode = status, headers = responseHeaders, body = fixture.reader(payload)}) end} end, run = function(c) local function upstream(code, body, headers, expected) status, payload, responseHeaders = code, body, headers local before = calls local ok, err = pcall(c.batchUpdate, {formId = "f1", requests = {{deleteItem = {location = {index = 0}}}}}) for _, text in expected do assert(not ok and string.find(tostring(err), text, 1, true), "missing " .. text .. " in " .. tostring(err)) end assert(calls == before + 1, "failed write was retried") end upstream(403, '{"error":{"code":403,"message":"The caller does not have permission","status":"PERMISSION_DENIED"}}', {}, {"HTTP 403 (PERMISSION_DENIED): The caller does not have permission", '"retryable":false'}) upstream(400, '{"error":{"code":400,"message":"Invalid requests[0].deleteItem: Index 0 out of bounds","status":"INVALID_ARGUMENT"}}', {}, {"HTTP 400 (INVALID_ARGUMENT)", "Index 0 out of bounds", '"retryable":false'}) upstream(429, '{"error":{"code":429,"message":"Quota exceeded for quota metric \'Write requests\' and limit \'Write requests per minute per user\'","status":"RESOURCE_EXHAUSTED"}}', {["retry-after"] = {"30"}}, {"HTTP 429 (RESOURCE_EXHAUSTED)", "Retry-After: 30", '"retryable":true'}) upstream(400, "<html><title>Error 400 (Bad Request)</title></html>", {}, {"Google HTTP 400", '"retryable":false'}) upstream(503, '{"error":{"code":503,"message":"The service is currently unavailable.","status":"UNAVAILABLE"}}', {}, {"HTTP 503", '"retryable":true'}) upstream(200, "<html>Maintenance</html>", {}, {"invalid JSON object"}) upstream(200, "[]", {}, {"invalid JSON object"}) status, payload = 404, '{"error":{"code":404,"message":"Requested entity was not found.","status":"NOT_FOUND"}}' local ok, err = pcall(c.getForm, {formId = "missing"}) assert(not ok and string.find(tostring(err), "NOT_FOUND", 1, true) and string.find(tostring(err), '"operation":"getForm"', 1, true), tostring(err)) end, }manifest.luau
return { contract = function(m) local function google(access, scopes) local r, err = m.resolve( { client_id = "publisher-client", client_secret = "publisher-secret" }, {}, nil, "oauth", { data = access } ) assert(r and not err, tostring(err)) local want = { "https://www.googleapis.com/auth/userinfo.email" } for _, scope in scopes do table.insert(want, "https://www.googleapis.com/auth/" .. scope) end assert(m.equal(r.Scopes, want), "requested OAuth scopes") r.Context.Auth.oauth.access_token = "fixture-token" return r end do local api = "https://forms.googleapis.com/v1/forms" for _, access in { "read", "write" } do local scope = "forms.body.readonly" if access == "write" then scope = "forms.body" end local r = google(access, { scope, "forms.responses.readonly" }) local reads = { "GET " .. api .. "/f1", "GET " .. api .. "/f1/responses?filter=timestamp%20%3E%202026-10-01T00%3A00%3A00Z", "GET " .. api .. "/f1/responses/ACYD", } m.routes(r, "Bearer fixture-token", true, reads) m.rejectOverrides(r, reads) local writes = { "POST " .. api .. "?unpublished=true", "POST " .. api .. "/f1:batchUpdate", "POST " .. api .. "/f1:setPublishSettings", } m.routes(r, "Bearer fixture-token", (access == "write"), writes) if access == "write" then m.rejectOverrides(r, writes) end m.routes(r, "Bearer fixture-token", false, { "POST https://oauth2.googleapis.com/token", "GET https://www.googleapis.com/drive/v3/files", "GET https://forms.googleapis.com.evil.test/v1/forms/f1", "GET https://content.googleapis.com/v1/forms/f1", "GET https://forms.googleapis.com/v2/forms/f1", "GET " .. api, "DELETE " .. api .. "/f1", "PATCH " .. api .. "/f1", "PUT " .. api .. "/f1", "GET " .. api .. "/f1/watches", "POST " .. api .. "/f1/watches", "POST " .. api .. "/f1/watches/w1:renew", "DELETE " .. api .. "/f1/watches/w1", "POST " .. api .. "/f1/responses", "DELETE " .. api .. "/f1/responses/ACYD", "GET " .. api .. "/%2e%2e/f1", "GET " .. api .. "/f1%2F..%2Fwatches", "GET " .. api .. "/f1/responses/%2e%2e", }) end end end, }reads.luau
return { scenario = {publisher = {client_id = "fixture-client", client_secret = "fixture-private-secret"}, config = {}, auth_method = "oauth", auth_config = {}}, access = {data = "read"}, configure = function() requests, responses = {}, {} http = {request = function(req) table.insert(requests, req) assert(#responses > 0, "unexpected request: " .. req.url) return fixture.operation({statusCode = 200, headers = {}, body = fixture.reader(table.remove(responses, 1))}) end} end, run = function(c) local API = "https://forms.googleapis.com/v1/forms/" local names = {} for name in c do table.insert(names, name) end table.sort(names) assert(table.concat(names, ",") == "getForm,getResponse,listResponses", table.concat(names, ",")) responses = { '{"formId":"1FaB_c-9","info":{"title":"Lunch"},"revisionId":"r1","items":[{"itemId":"i1","title":"Which day?","questionItem":{"question":{"questionId":"q1","choiceQuestion":{"type":"RADIO"}}}}]}', '{"formId":"f1","info":{"title":"Draft"}}', } local form = c.getForm({formId = "https://docs.google.com/forms/d/1FaB_c-9/edit#responses"}) assert(form.items[1].questionItem.question.questionId == "q1" and form.revisionId == "r1") assert(requests[1].url == API .. "1FaB_c-9", requests[1].url) local empty = c.getForm({formId = "f1"}) assert(json.encode(empty.items) == "[]" and requests[2].url == API .. "f1", requests[2].url) responses = { '{"responses":[{"responseId":"ACYD","lastSubmittedTime":"2026-10-20T09:00:00.123Z","answers":{"q1":{"questionId":"q1","textAnswers":{"answers":[{"value":"Tuesday"}]}}}}],"nextPageToken":"p2"}', '{}', '{"responseId":"ACYD","formId":"f1","answers":{}}', } local page = c.listResponses({formId = "https://docs.google.com/forms/u/1/d/f1/edit", filter = "timestamp > 2026-10-01T00:00:00Z", pageSize = 50}) assert(page.responses[1].answers.q1.textAnswers.answers[1].value == "Tuesday" and page.nextPageToken == "p2") assert(requests[3].url == API .. "f1/responses?filter=timestamp%20%3E%202026-10-01T00%3A00%3A00Z&pageSize=50", requests[3].url) local none = c.listResponses({formId = "https://docs.google.com/a/example.com/forms/d/f1/edit", pageToken = "p2"}) assert(json.encode(none.responses) == "[]" and requests[4].url == API .. "f1/responses?pageToken=p2", requests[4].url) assert(c.getResponse({formId = "f1", responseId = "ACYD"}).responseId == "ACYD") assert(requests[5].url == API .. "f1/responses/ACYD", requests[5].url) for _, req in requests do assert(req.method == "GET" and req.body == nil, req.method .. " " .. req.url) assert(req.headers == nil or req.headers.Authorization == nil, "connector set credentials") end local sent = #requests local invalid = { {}, {formId = ""}, {formId = ".."}, {formId = "f/1"}, {formId = "f1 x"}, {formId = "https://docs.google.com/forms/d/e/1FAIpQLSc/viewform"}, {formId = "https://forms.gle/abc123"}, {formId = "https://docs.google.com.example.com/forms/d/f1/edit"}, {formId = "https://example.com/?u=https://docs.google.com/forms/d/f1"}, {formId = "https://docs.google.com/spreadsheets/d/s1/edit"}, {formId = "https://docs.google.com/forms/#d/f1"}, {formId = "https://docs.google.com/forms/d/f1.x/edit"}, {formId = "f1", key = "api-key"}, {formId = "f1", fields = "items"}, } for _, args in invalid do assert(not pcall(c.getForm, args), "accepted " .. json.encode(args)) end assert(not pcall(c.getForm, "f1")) assert(not pcall(c.getResponse, {formId = "f1"}), "getResponse requires responseId") assert(not pcall(c.getResponse, {formId = "f1", responseId = ".."})) assert(not pcall(c.getResponse, {formId = "f1", responseId = "a/b"})) assert(not pcall(c.listResponses, {formId = "f1", pageSize = 50, extra = true})) assert(not pcall(c.listResponses, {formId = "f1", filter = {key = "x"}})) assert(#requests == sent, "invalid input reached Google") assert(#responses == 0) end, }writes.luau
return { scenario = {publisher = {client_id = "fixture-client", client_secret = "fixture-private-secret"}, config = {}, auth_method = "oauth", auth_config = {}}, access = {data = "write"}, configure = function() requests, responses = {}, {} http = {request = function(req) table.insert(requests, req) assert(#responses > 0, "unexpected request: " .. req.url) return fixture.operation({statusCode = 200, headers = {}, body = fixture.reader(table.remove(responses, 1))}) end} end, run = function(c) local API = "https://forms.googleapis.com/v1/forms" local names = {} for name in c do table.insert(names, name) end table.sort(names) assert(table.concat(names, ",") == "batchUpdate,createForm,getForm,getResponse,listResponses,setPublishSettings", table.concat(names, ",")) local function same(a, b) if type(a) ~= "table" or type(b) ~= "table" then return a == b end for key, value in a do if not same(value, b[key]) then return false end end for key in b do if a[key] == nil then return false end end return true end local function sent(href, body) local req = requests[#requests] assert(req.method == "POST" and req.url == href, req.method .. " " .. req.url) assert(req.headers["Content-Type"][1] == "application/json" and req.headers.Authorization == nil) assert(same(json.decode(req.body), body), req.body) end responses = {'{"formId":"new","info":{"title":"Lunch"},"responderUri":"https://docs.google.com/forms/d/e/1FAIpQL/viewform"}', '{"formId":"live"}'} local created = c.createForm({info = {title = "Lunch"}}) assert(created.formId == "new" and json.encode(created.items) == "[]") sent(API .. "?unpublished=true", {info = {title = "Lunch"}}) c.createForm({info = {title = "Live"}, unpublished = false}) sent(API .. "?unpublished=false", {info = {title = "Live"}}) responses = {'{"replies":[{"createItem":{"itemId":"i1","questionId":["q1"]}}],"writeControl":{"requiredRevisionId":"r2"}}'} local requestsBody = {{createItem = {item = {title = "Which day?", questionItem = {question = {required = true, choiceQuestion = {type = "RADIO", options = {{value = "Tuesday"}}}}}}, location = {index = 0}}}} local reply = c.batchUpdate({formId = "https://docs.google.com/forms/d/f1/edit", requests = requestsBody, writeControl = {requiredRevisionId = "r1"}}) assert(reply.replies[1].createItem.questionId[1] == "q1") sent(API .. "/f1:batchUpdate", {requests = requestsBody, writeControl = {requiredRevisionId = "r1"}}) responses = {'{"formId":"f1","publishSettings":{"publishState":{"isPublished":true,"isAcceptingResponses":false}}}'} local closed = c.setPublishSettings({formId = "f1", publishSettings = {publishState = {isPublished = true, isAcceptingResponses = false}}, updateMask = "publish_state"}) assert(closed.publishSettings.publishState.isAcceptingResponses == false) sent(API .. "/f1:setPublishSettings", {publishSettings = {publishState = {isPublished = true, isAcceptingResponses = false}}, updateMask = "publish_state"}) -- Google's system parameters stay out of the URL; Google rejects them as unknown body fields. responses = {'{"replies":[{}]}'} c.batchUpdate({formId = "f1", requests = {{deleteItem = {location = {index = 2}}}}, key = "k", access_token = "t", alt = "media"}) sent(API .. "/f1:batchUpdate", {requests = {{deleteItem = {location = {index = 2}}}}, key = "k", access_token = "t", alt = "media"}) local count = #requests assert(not pcall(c.createForm, {formId = "f1", info = {title = "Copy"}}), "createForm assigns the formId") assert(not pcall(c.createForm, {info = {title = "Lunch"}, unpublished = {mode = "draft"}})) assert(not pcall(c.batchUpdate, {formId = "f1"}), "batchUpdate requires requests") assert(not pcall(c.batchUpdate, {formId = "f1", requests = {}})) assert(not pcall(c.batchUpdate, {formId = "f1", requests = "x"})) assert(not pcall(c.batchUpdate, {formId = "f1", requests = {deleteItem = {}}})) assert(not pcall(c.batchUpdate, {formId = "https://docs.google.com/forms/d/e/1FAIpQL/viewform", requests = {{deleteItem = {location = {index = 0}}}}})) assert(not pcall(c.createForm, {}), "createForm requires info") assert(not pcall(c.createForm, {info = "Lunch"})) assert(not pcall(c.setPublishSettings, {formId = "f1"}), "setPublishSettings requires publishSettings") assert(not pcall(c.setPublishSettings, {formId = "f1", publishSettings = {}})) assert(not pcall(c.setPublishSettings, {formId = "f1", publishSettings = {{isPublished = true}}})) assert(not pcall(c.setPublishSettings, {publishSettings = {}})) assert(not pcall(c.setPublishSettings, {formId = "f/1", publishSettings = {}})) assert(#requests == count, "invalid input reached Google") assert(#responses == 0) end, }