All connectors
Google Slides
Official
Google Slides
Let agents read your decks, check how each slide looks and build new ones.
- Read every slide's text and speaker notes, and the presentation's comments.
- See a presentation's layout and structure, and preview any slide as an image.
- With Write access: create presentations, add, reorder, copy and delete slides, write and replace text and notes, add shapes, images and tables, format text, and comment and reply.
Agents work with a presentation when you share its link. To let them search your Drive for presentations, also connect Google Drive. Read access cannot change your presentations.
Setup instructions
Setup instructions
Connect your Google account
- Choose the level for Access:
- Read to let agents read presentations and preview slides without changing anything.
- Write to also let agents create presentations and edit their slides, text, notes and comments.
- 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 presentation your Google account can open, but nothing else in your Drive; connecting Google Slides 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 presentation may be using a link from Publish
to the web (it contains
/presentation/d/e/). Share the presentation's normal link instead, from the address bar while it is open. - PowerPoint files stored in Drive open in Slides but cannot be read by agents. Convert one with File > Save as Google Slides and share the new link.
- Slide previews are links that work without signing in for 30 minutes. Agents are told not to share them beyond people who may see the presentation.
Files
Files
connector.luau
-- Google Slides API v1. Arguments and results keep Google's native field names. local API = "https://slides.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 PAGE = "{objectId, pageType, revisionId?, pageElements=[{objectId, size, transform, title?, description?, shape?={shapeType, text?={textElements=[{startIndex?, endIndex, textRun?={content, style}, autoText?, paragraphMarker?}]}, placeholder?={type, index?}}, table?={rows, columns, tableRows=[{tableCells=[{text?}]}]}, image?, video?, line?, sheetsChart?, wordArt?, elementGroup?={children}}], slideProperties?={layoutObjectId, isSkipped?, notesPage}}" local endpoints: {[string]: Endpoint} = { getPresentation = {method = "GET", path = "/presentations/{presentationId}", query = {"commentsViewMode", "fields"}, help = "getPresentation({presentationId, commentsViewMode?, fields?}) -> {presentationId, title, revisionId?, locale, pageSize={width, height}, slides=[" .. PAGE .. "], layouts=[{objectId, layoutProperties={displayName}}], masters, notesMaster}. slides are in presentation order, and absent for an empty deck; pageElements are in stacking order, back to front. Fields equal to 0 are omitted, such as a translateX at the left edge. revisionId is present only for editors and valid for 24 hours. Every layout and master comes too, and responses over 8 MiB fail: fields='presentationId,title,revisionId,slides.objectId' lists the slide IDs only. commentsViewMode='COMMENTS_VIEW_MODE_INCLUDED' adds comments=[{commentId, anchorId, headPost={postId, author, content, createTime}, replies, status, plainTextQuote}] and each slide's commentAnchors, or fails with HTTP 403 for users who cannot see comments."}, getPage = {method = "GET", path = "/presentations/{presentationId}/pages/{pageObjectId}", query = {"commentsViewMode", "fields"}, help = "getPage({presentationId, pageObjectId, commentsViewMode?, fields?}) -> " .. PAGE .. ". One slide, layout, master or notes page; with commentsViewMode, also its comments and commentAnchors."}, getThumbnail = {method = "GET", path = "/presentations/{presentationId}/pages/{pageObjectId}/thumbnail", query = {"thumbnailProperties.thumbnailSize"}, help = "getThumbnail({presentationId, pageObjectId, thumbnailSize?}) -> {width, height, contentUrl}. Renders the page as a PNG; thumbnailSize is SMALL (200 px wide), MEDIUM (800), LARGE (1600) or WIDTH2000_PX, else Google's choice. contentUrl is the image link: a plain GET without credentials fetches it for 30 minutes. Google allows only about 60 thumbnails per minute per user."}, createPresentation = {method = "POST", path = "/presentations", access = "data:write", body = true, help = "createPresentation({title?}) -> the new presentation, with presentationId, revisionId and one title slide whose placeholders are CENTERED_TITLE and SUBTITLE. Creates it in the root of My Drive with an ID Google chooses; Google ignores fields other than title and presentationId, which this connector leaves to Google, so add content with batchUpdate."}, batchUpdate = {method = "POST", path = "/presentations/{presentationId}:batchUpdate", access = "data:write", body = true, required = {requests = "array"}, help = "batchUpdate({presentationId, requests, writeControl?}) -> {presentationId, replies, writeControl, commentUpdateState?}. Applies requests in order, all or nothing; replies match requests one to one, e.g. {createSlide={objectId}} or {insertComment={commentThread={commentId}}}. Kinds include createSlide={objectId?, insertionIndex?, slideLayoutReference?={predefinedLayout='TITLE_AND_BODY'|'TITLE_ONLY'|'BLANK'|'SECTION_HEADER'...} or {layoutId}, placeholderIdMappings?={{layoutPlaceholder={type='TITLE'|'BODY'|'CENTERED_TITLE'|'SUBTITLE', index?}, objectId}}}; a predefinedLayout fails with HTTP 400 when the deck's master lacks it, as in many themed decks: pass layoutId from getPresentation's layouts instead. Also duplicateObject={objectId}, deleteObject={objectId}, updateSlidesPosition={slideObjectIds, insertionIndex}, updateSlideProperties={objectId, slideProperties={isSkipped}, fields='isSkipped'}, replaceAllText={containsText={text, matchCase?, searchByRegex?}, replaceText, pageObjectIds?}, insertText={objectId, text, insertionIndex?, cellLocation?={rowIndex, columnIndex}}, deleteText={objectId, textRange={type='ALL'} or {type='FIXED_RANGE', startIndex, endIndex}}, updateTextStyle={objectId, textRange, style={bold?, fontSize?={magnitude, unit='PT'}, link?={url}, ...}, fields='bold'}, updateParagraphStyle={objectId, textRange, style={alignment='CENTER'}, fields='alignment'}, createParagraphBullets={objectId, textRange, bulletPreset='BULLET_DISC_CIRCLE_SQUARE'|'NUMBERED_DIGIT_ALPHA_ROMAN'}, createShape={objectId?, shapeType='TEXT_BOX'|'RECTANGLE'..., elementProperties={pageObjectId, size, transform}}, createImage={url, elementProperties} (a public PNG, JPEG or GIF under 50 MB), createTable={rows, columns, elementProperties}, replaceAllShapesWithImage, updateShapeProperties, updatePageProperties, updatePageElementTransform, groupObjects, insertComment={content, objectId or shapeTextAnchor or tableCellTextAnchor or tableAnchor, assigneeEmailAddress?}, addCommentReply={commentId, post={content?, commentAction?='RESOLVE'|'REOPEN'}}, updateCommentPost, deleteComment and deleteCommentReply (your own posts only). createSheetsChart, replaceAllShapesWithSheetsChart and refreshSheetsChart need Sheets access this connector does not request. Text indexes count UTF-16 code units within one shape or table cell, not the UTF-8 bytes # counts: é is 1 unit and an emoji 2. Take them from getPage's textElements, never from offsets in getPresentationText. insertText without insertionIndex inserts at the start: prefer replaceAllText for edits, and deleteText with textRange={type='ALL'} then insertText to replace a shape's text. A shape's final newline cannot be deleted. Sizes and positions use EMU: 914400 per inch, 12700 per point, e.g. size={width={magnitude=3000000, unit='EMU'}, height={magnitude=500000, unit='EMU'}}, transform={scaleX=1, scaleY=1, translateX=311700, translateY=1000000, unit='EMU'}; pageSize from getPresentation gives the slide's size. Give new objects your own objectId, 5 to 50 letters, digits, _, - or : starting with a letter, digit or _, to edit them later in the same batch. Speaker notes are the shape whose ID is slideProperties.notesPage.notesProperties.speakerNotesObjectId: write them with insertText on that ID, which creates the shape if needed. A new slide's notes ID is known only after a getPage, so write its notes in a second batch. Comments can fail while other edits are saved: when a batch writes comments, check that commentUpdateState is ALL_SAVED, not ALL_FAILED_UNKNOWN_REASON; other batches report NO_UPDATES_REQUESTED or omit it. writeControl={requiredRevisionId=deck.revisionId} fails with HTTP 400 if the presentation changed since that read. Example: requests={{createSlide={objectId='q3_summary', slideLayoutReference={predefinedLayout='TITLE_AND_BODY'}, placeholderIdMappings={{layoutPlaceholder={type='TITLE'}, objectId='q3_summary_title'}, {layoutPlaceholder={type='BODY'}, objectId='q3_summary_body'}}}}, {insertText={objectId='q3_summary_title', text='Q3 results'}}, {insertText={objectId='q3_summary_body', text='Revenue up 12%\\nTwo new customers'}}}."}, } local function withPresentation(name: string, endpoint: Endpoint, args: Options): any if string.find(endpoint.path, "{presentationId}", 1, true) then args.presentationId = docsId(args.presentationId, "presentation", "presentationId") else assert(args.presentationId == nil, name .. " assigns the presentationId") end return invoke(name, endpoint, args) end for name, endpoint in endpoints do if name ~= "getThumbnail" then export(name, endpoint.access, function(input: any): any return withPresentation(name, endpoint, options(input)) end, endpoint.help) end end -- Only PNG exists, so thumbnails take just a size, under a plain name. local SIZES = table.freeze({SMALL = true, MEDIUM = true, LARGE = true, WIDTH2000_PX = true}) export("getThumbnail", nil, function(input: any): any local args = options(input) assert(args["thumbnailProperties.thumbnailSize"] == nil, "getThumbnail received an unknown option") assert(args.thumbnailSize == nil or SIZES[args.thumbnailSize], "thumbnailSize must be SMALL, MEDIUM, LARGE or WIDTH2000_PX") args["thumbnailProperties.thumbnailSize"], args.thumbnailSize = args.thumbnailSize, nil return withPresentation("getThumbnail", endpoints.getThumbnail, args) end, endpoints.getThumbnail.help) local NONE: {any} = table.freeze({}) local function shapeText(content: any): string local parts: {string} = {} for _, element in (content and content.textElements) or NONE do local run = element.textRun or element.autoText if run and type(run.content) == "string" then table.insert(parts, run.content) end end return (string.gsub(table.concat(parts), "\v", "\n")) end -- Appends the text of page elements in stacking order: shapes as written, groups element by element, -- and table rows as lines of tab-separated cells. local function collect(elements: any, out: {string}) for _, element in elements or NONE do if element.shape then table.insert(out, shapeText(element.shape.text)) elseif element.table then for _, row in element.table.tableRows or NONE do local cells: {string} = {} for _, cell in row.tableCells or NONE do local cellText = string.gsub(shapeText(cell.text), "\n+$", "") table.insert(cells, (string.gsub(cellText, "[\t\n]", " "))) end table.insert(out, table.concat(cells, "\t") .. "\n") end elseif element.wordArt and type(element.wordArt.renderedText) == "string" then table.insert(out, element.wordArt.renderedText .. "\n") elseif element.elementGroup then collect(element.elementGroup.children, out) end end end local function notes(slide: any): string local page = slide.slideProperties and slide.slideProperties.notesPage local id = page and page.notesProperties and page.notesProperties.speakerNotesObjectId for _, element in (page and page.pageElements) or NONE do if id ~= nil and element.objectId == id and element.shape then return shapeText(element.shape.text) end end return "" end -- Only the text-bearing fields of each element, through two levels of nested groups; deeper groups come whole. local RUNS = "text.textElements(textRun.content,autoText.content)" local ELEMENT = "shape." .. RUNS .. ",table.tableRows.tableCells." .. RUNS .. ",wordArt.renderedText" local TEXT_FIELDS = "presentationId,title,revisionId,slides(objectId,pageElements(" .. ELEMENT .. ",elementGroup.children(" .. ELEMENT .. ",elementGroup.children(" .. ELEMENT .. ",elementGroup))),slideProperties(isSkipped,notesPage(notesProperties.speakerNotesObjectId,pageElements(objectId,shape." .. RUNS .. "))))" export("getPresentationText", nil, function(input: any): Options local args = options(input) assert(args.fields == nil and args.commentsViewMode == nil, "getPresentationText received an unknown option") args.fields = TEXT_FIELDS local deck = withPresentation("getPresentationText", endpoints.getPresentation, args) local slides: {Options} = json.decode("[]") for _, slide in deck.slides or NONE do local parts: {string} = {} collect(slide.pageElements, parts) table.insert(slides, {objectId = slide.objectId, isSkipped = slide.slideProperties and slide.slideProperties.isSkipped, text = table.concat(parts), notes = notes(slide)}) end return {presentationId = deck.presentationId, title = deck.title, revisionId = deck.revisionId, slides = slides} end, "getPresentationText({presentationId}) -> {presentationId, title, revisionId?, slides=[{objectId, isSkipped?, text, notes}]}. The text of every slide in presentation order, and its speaker notes; slides is [] for an empty deck. Shapes, text boxes and groups appear in stacking order, back to front rather than by position, each ending with '\\n'; table rows are lines of tab-separated cells. Images, videos and charts are left out: read their alt text (title, description) with getPage, or look at the slide with getThumbnail. Offsets in text are not batchUpdate indexes.") local overview = { "Google Slides API v1. Operations take one named options object with Google's camelCase fields and return Google's JSON unchanged, except getPresentationText. Calls return completed values: use instance.getPresentationText(...) directly, without await.", "presentationId is the ID or the presentation's https://docs.google.com/presentation/d/<id>/edit URL; such a link's #slide=id.<pageObjectId> names the slide that was open. Links from Publish to the web (/presentation/d/e/...) carry no ID. This connector cannot search for files: ask for the URL, or find the ID with the Google Drive connector (listFiles with q=\"mimeType = 'application/vnd.google-apps.presentation' and trashed = false\"). PowerPoint files opened in Slides are refused with HTTP 400 until saved as Google Slides (File > Save as Google Slides).", "Slides, layouts, masters and notes pages are pages; the shapes, text boxes, images, tables, lines, videos, charts and groups on them are page elements, with objectIds shared across one presentation. Read the words with getPresentationText, structure and positions with getPresentation or getPage, and how a slide looks with getThumbnail.", "Every contentUrl, of thumbnails and images alike, opens without sign-in as the connected account for 30 minutes: show it only to people who may see the presentation, and never print, log or store it.", "No hidden paging or retries. Errors report the HTTP status and Google's message. Google allows about 600 reads, 60 thumbnails and 60 writes per minute per user, and 3000, 300 and 600 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 slides, their content and comments. An empty Luau table encodes as a JSON object: write an empty array as json.decode('[]'). Presentations cannot be deleted, renamed, moved or shared here: use the Google Drive connector. A failed or timed-out write may already have succeeded: check with getPresentation, adding commentsViewMode='COMMENTS_VIEW_MODE_INCLUDED' after comment writes, before repeating it, give new slides and elements your own objectId so a repeat fails with HTTP 400 instead of adding them twice, or pass writeControl={requiredRevisionId=deck.revisionId}, with deck read by getPresentation.") end exports.help = helpWith(overview) return exportshouston.json
{ "schema_version": 2, "name": "Google Slides", "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/presentations.readonly" ] }, { "if": "{{ is access.data \"write\" }}", "values": [ "https://www.googleapis.com/auth/presentations" ] } ], "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": [ "slides.googleapis.com" ], "method": [ "GET" ], "path": [ "/v1/presentations/{presentationId}", "/v1/presentations/{presentationId}/pages/{pageObjectId}", "/v1/presentations/{presentationId}/pages/{pageObjectId}/thumbnail" ], "colon_path_parameters": [ "pageObjectId" ] }, "action": { "headers": { "set": { "Authorization": "Bearer {{auth.oauth.access_token}}" } } } }, { "if": "{{ allows access.data \"write\" }}", "match": { "protocol": "http", "host": [ "slides.googleapis.com" ], "method": [ "POST" ], "path": [ "/v1/presentations", "/v1/presentations/{presentationId}:batchUpdate" ] }, "action": { "headers": { "set": { "Authorization": "Bearer {{auth.oauth.access_token}}" } } } } ] }icon.svg
README.md
--- description: Read and build Google Slides presentations. --- # Google Slides Let agents read your decks, check how each slide looks and build new ones. - Read every slide's text and speaker notes, and the presentation's comments. - See a presentation's layout and structure, and preview any slide as an image. - With **Write** access: create presentations, add, reorder, copy and delete slides, write and replace text and notes, add shapes, images and tables, format text, and comment and reply. Agents work with a presentation when you share its link. To let them search your Drive for presentations, also connect Google Drive. Read access cannot change your presentations.SETUP.md
# Connect your Google account 1. Choose the level for **Access**: - **Read** to let agents read presentations and preview slides without changing anything. - **Write** to also let agents create presentations and edit their slides, text, notes and comments. 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 presentation your Google account can open, but nothing else in your Drive; connecting Google Slides 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 presentation may be using a link from **Publish to the web** (it contains `/presentation/d/e/`). Share the presentation's normal link instead, from the address bar while it is open. - PowerPoint files stored in Drive open in Slides but cannot be read by agents. Convert one with **File > Save as Google Slides** and share the new link. - Slide previews are links that work without signing in for 30 minutes. Agents are told not to share them beyond people who may see the presentation.tests
authentication.luau
return { contract = function(m) m.authentication({ { auth = {}, config = {}, endpoint = { "GET", "https://slides.googleapis.com/v1/presentations/p1" }, 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, {presentationId = "p1", requests = {{deleteObject = {objectId = "g1"}}}}) 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].deleteObject: The object (g1) could not be found.","status":"INVALID_ARGUMENT"}}', {}, {"HTTP 400 (INVALID_ARGUMENT)", "could not be found", '"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(403, '{"error":{"code":403,"message":"Request had insufficient authentication scopes.","status":"PERMISSION_DENIED","details":[{"@type":"type.googleapis.com/google.rpc.Help"},{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"ACCESS_TOKEN_SCOPE_INSUFFICIENT","domain":"googleapis.com"}]}}', {}, {"insufficient authentication scopes. [ACCESS_TOKEN_SCOPE_INSUFFICIENT]", '"retryable":false'}) upstream(403, '{"error":{"code":403,"message":"Quota exceeded for quota metric \'Write requests per day\'.","status":"PERMISSION_DENIED","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"RATE_LIMIT_EXCEEDED"}]}}', {}, {"[RATE_LIMIT_EXCEEDED]", '"retryable":false'}) 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.getPresentation, {presentationId = "missing"}) assert(not ok and string.find(tostring(err), "NOT_FOUND", 1, true) and string.find(tostring(err), '"operation":"getPresentation"', 1, true), tostring(err)) status, payload = 429, '{"error":{"code":429,"message":"Quota exceeded for quota metric \'Expensive read requests\'","status":"RESOURCE_EXHAUSTED"}}' ok, err = pcall(c.getThumbnail, {presentationId = "p1", pageObjectId = "g1"}) assert(not ok and string.find(tostring(err), '"retryable":true', 1, true) and string.find(tostring(err), '"operation":"getThumbnail"', 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://slides.googleapis.com/v1/presentations" for _, access in { "read", "write" } do local scope = "presentations.readonly" if access == "write" then scope = "presentations" end local r = google(access, { scope }) local reads = { "GET " .. api .. "/p1", "GET " .. api .. "/1PrE_x-9?fields=presentationId%2Ctitle%2CrevisionId%2Cslides", "GET " .. api .. "/p1?commentsViewMode=COMMENTS_VIEW_MODE_INCLUDED", "GET " .. api .. "/p1/pages/g1", "GET " .. api .. "/p1/pages/q3%3Asummary", "GET " .. api .. "/p1/pages/g1/thumbnail", "GET " .. api .. "/p1/pages/SLIDES_API1_0/thumbnail?thumbnailProperties.thumbnailSize=SMALL", } m.routes(r, "Bearer fixture-token", true, reads) m.rejectOverrides(r, reads) local writes = { "POST " .. api, "POST " .. api .. "/p1:batchUpdate" } 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://slides.googleapis.com.evil.test/v1/presentations/p1", "GET https://content.googleapis.com/v1/presentations/p1", "GET https://slides.googleapis.com/v2/presentations/p1", "GET https://docs.googleapis.com/v1/documents/p1", "GET " .. api, "DELETE " .. api .. "/p1", "PATCH " .. api .. "/p1", "PUT " .. api .. "/p1", "POST " .. api .. "/p1/batchUpdate", "GET " .. api .. "/p1/pages", "POST " .. api .. "/p1/pages/g1", "POST " .. api .. "/p1/pages/g1/thumbnail", "GET " .. api .. "/p1/pages/g1/thumbnail/x", "GET " .. api .. "/p1/comments", "GET " .. api .. "/%2e%2e/p1", "GET " .. api .. "/p1%2F..%2Fx", "GET " .. api .. "/p1/pages/%2e%2e/thumbnail", "GET " .. api .. "/p1/pages/g1%2Fthumbnail", "GET " .. api .. "/p1/pages/%252e%252e", "POST https://slides.googleapis.com/batch", "POST https://slides.googleapis.com/batch/slides/v1", }) 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://slides.googleapis.com/v1/presentations/" local names = {} for name in c do table.insert(names, name) end table.sort(names) assert(table.concat(names, ",") == "getPage,getPresentation,getPresentationText,getThumbnail", table.concat(names, ",")) local function text(...) local elements = {} for _, content in {...} do table.insert(elements, {paragraphMarker = {style = {}}}) table.insert(elements, {textRun = {content = content, style = {}}}) end return {textElements = elements} end local function shape(id, content) return {objectId = id, shape = {shapeType = "TEXT_BOX", text = content}} end local deck = {presentationId = "1PrE_x-9", title = "Q3", revisionId = "r1", slides = { {objectId = "p1", pageElements = { shape("title", text("Q3 results\n")), {objectId = "pic", image = {contentUrl = "https://lh3.googleusercontent.com/x"}, title = "Chart"}, {objectId = "grp", elementGroup = {children = {shape("a", text("Revenue up\vagain\n", "Costs flat\n")), {objectId = "num", shape = {shapeType = "TEXT_BOX", text = {textElements = {{paragraphMarker = {}}, {autoText = {type = "SLIDE_NUMBER", content = "1"}}, {textRun = {content = "\n"}}}}}}}}}, {objectId = "tbl", table = {rows = 1, columns = 2, tableRows = {{tableCells = {{text = text("Region\n")}, {text = text("EU\tUS\v", "APAC\n")}, {}}}}}}, {objectId = "art", wordArt = {renderedText = "WOW"}}, shape("empty", nil), }, slideProperties = {notesPage = {notesProperties = {speakerNotesObjectId = "n1"}, pageElements = { shape("n0", text("Slide image\n")), shape("n1", text("Mention the EU launch\n")), }}}}, {objectId = "p2", pageElements = {}, slideProperties = {isSkipped = true, notesPage = {notesProperties = {speakerNotesObjectId = "n2"}, pageElements = {}}}}, {objectId = "p3"}, }} local fields = url.encode("presentationId,title,revisionId,slides(objectId,pageElements(shape.text.textElements(textRun.content,autoText.content),table.tableRows.tableCells.text.textElements(textRun.content,autoText.content),wordArt.renderedText,elementGroup.children(shape.text.textElements(textRun.content,autoText.content),table.tableRows.tableCells.text.textElements(textRun.content,autoText.content),wordArt.renderedText,elementGroup.children(shape.text.textElements(textRun.content,autoText.content),table.tableRows.tableCells.text.textElements(textRun.content,autoText.content),wordArt.renderedText,elementGroup))),slideProperties(isSkipped,notesPage(notesProperties.speakerNotesObjectId,pageElements(objectId,shape.text.textElements(textRun.content,autoText.content)))))") responses = {json.encode(deck), '{"presentationId":"p1","title":"Empty"}'} local read = c.getPresentationText({presentationId = "https://docs.google.com/presentation/d/1PrE_x-9/edit#slide=id.p1"}) assert(requests[1].url == API .. "1PrE_x-9?fields=" .. fields, requests[1].url) assert(read.presentationId == "1PrE_x-9" and read.title == "Q3" and read.revisionId == "r1" and #read.slides == 3) assert(read.slides[1].objectId == "p1" and read.slides[1].text == "Q3 results\nRevenue up\nagain\nCosts flat\n1\nRegion\tEU US APAC\t\nWOW\n", read.slides[1].text) assert(read.slides[1].notes == "Mention the EU launch\n" and read.slides[1].isSkipped == nil, read.slides[1].notes) assert(read.slides[2].text == "" and read.slides[2].notes == "" and read.slides[2].isSkipped == true) assert(read.slides[3].objectId == "p3" and read.slides[3].text == "" and read.slides[3].notes == "") local empty = c.getPresentationText({presentationId = "https://docs.google.com/presentation/u/1/d/p1/edit"}) assert(empty.title == "Empty" and json.encode(empty.slides) == "[]" and requests[2].url == API .. "p1?fields=" .. fields, requests[2].url) responses = {json.encode(deck), '{"presentationId":"p1"}', '{"objectId":"g1","pageType":"SLIDE","pageElements":[]}', '{"objectId":"g1","comments":[{"commentId":"c1"}]}', '{"width":800,"height":450,"contentUrl":"https://lh7-us.googleusercontent.com/t"}', '{"width":200,"height":113,"contentUrl":"https://lh7-us.googleusercontent.com/s"}', '{"width":2000,"height":1125,"contentUrl":"https://lh7-us.googleusercontent.com/w"}'} assert(c.getPresentation({presentationId = "1PrE_x-9"}).slides[1].objectId == "p1" and requests[3].url == API .. "1PrE_x-9", requests[3].url) local none = c.getPresentation({presentationId = "https://docs.google.com/a/example.com/presentation/d/p1/edit", fields = "presentationId,slides.objectId", commentsViewMode = "COMMENTS_VIEW_MODE_INCLUDED"}) assert(none.slides == nil, "getPresentation changed Google's JSON") assert(requests[4].url == API .. "p1?commentsViewMode=COMMENTS_VIEW_MODE_INCLUDED&fields=presentationId%2Cslides.objectId", requests[4].url) assert(c.getPage({presentationId = "p1", pageObjectId = "g1"}).pageType == "SLIDE" and requests[5].url == API .. "p1/pages/g1", requests[5].url) assert(c.getPage({presentationId = "p1", pageObjectId = "g1", commentsViewMode = "COMMENTS_VIEW_MODE_INCLUDED"}).comments[1].commentId == "c1") assert(requests[6].url == API .. "p1/pages/g1?commentsViewMode=COMMENTS_VIEW_MODE_INCLUDED", requests[6].url) local thumbnail = c.getThumbnail({presentationId = "p1", pageObjectId = "g1"}) assert(thumbnail.width == 800 and thumbnail.contentUrl == "https://lh7-us.googleusercontent.com/t" and requests[7].url == API .. "p1/pages/g1/thumbnail", requests[7].url) c.getThumbnail({presentationId = "p1", pageObjectId = "SLIDES_API1_0", thumbnailSize = "SMALL"}) assert(requests[8].url == API .. "p1/pages/SLIDES_API1_0/thumbnail?thumbnailProperties.thumbnailSize=SMALL", requests[8].url) assert(c.getThumbnail({presentationId = "p1", pageObjectId = "q3:summary", thumbnailSize = "WIDTH2000_PX"}).width == 2000) assert(requests[9].url == API .. "p1/pages/q3%3Asummary/thumbnail?thumbnailProperties.thumbnailSize=WIDTH2000_PX", requests[9].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 = { {}, {presentationId = ""}, {presentationId = ".."}, {presentationId = "p/1"}, {presentationId = "p1 x"}, {presentationId = "https://docs.google.com/presentation/d/e/2PACX-1vS/pub?start=false"}, {presentationId = "https://docs.google.com.example.com/presentation/d/p1/edit"}, {presentationId = "https://example.com/?u=https://docs.google.com/presentation/d/p1"}, {presentationId = "https://docs.google.com/document/d/d1/edit"}, {presentationId = "https://docs.google.com/presentation/#d/p1"}, {presentationId = "p1", key = "api-key"}, } for _, args in invalid do assert(not pcall(c.getPresentation, args), "getPresentation accepted " .. json.encode(args)) assert(not pcall(c.getPresentationText, args), "getPresentationText accepted " .. json.encode(args)) end assert(not pcall(c.getPresentation, "p1")) assert(not pcall(c.getPresentationText, {presentationId = "p1", fields = "title"}), "getPresentationText chooses its fields") assert(not pcall(c.getPresentationText, {presentationId = "p1", commentsViewMode = "COMMENTS_VIEW_MODE_INCLUDED"})) assert(not pcall(c.getPage, {presentationId = "p1"}), "getPage requires pageObjectId") assert(not pcall(c.getPage, {presentationId = "p1", pageObjectId = ".."})) assert(not pcall(c.getPage, {presentationId = "p1", pageObjectId = "g1/thumbnail"})) assert(not pcall(c.getThumbnail, {presentationId = "p1", pageObjectId = "g1", thumbnailSize = {"SMALL", "LARGE"}}), "thumbnailSize repeated") assert(not pcall(c.getThumbnail, {presentationId = "p1", pageObjectId = "g1", thumbnailSize = "HUGE"})) assert(not pcall(c.getThumbnail, {presentationId = "p1", pageObjectId = "g1", ["thumbnailProperties.thumbnailSize"] = "LARGE"}), "dotted size is not an option") assert(not pcall(c.getThumbnail, {presentationId = "p1", pageObjectId = "g1", ["thumbnailProperties.mimeType"] = "PNG"})) assert(not pcall(c.getThumbnail, {presentationId = "p1", pageObjectId = "g1", extra = true})) assert(not pcall(c.getThumbnail, {presentationId = "p1/x", pageObjectId = "g1"})) assert(not pcall(c.getPage, {presentationId = "https://docs.google.com/presentation/d/e/2PACX-1vS/pub", pageObjectId = "g1"})) assert(not pcall(c.getThumbnail, {presentationId = "p1", pageObjectId = "g1", thumbnailSize = {size = "SMALL"}})) assert(not pcall(c.getThumbnail, {presentationId = "p1", pageObjectId = "g1", mimeType = "JPEG"}), "PNG is the only thumbnail type") 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://slides.googleapis.com/v1/presentations" local names = {} for name in c do table.insert(names, name) end table.sort(names) assert(table.concat(names, ",") == "batchUpdate,createPresentation,getPage,getPresentation,getPresentationText,getThumbnail", 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 = {'{"presentationId":"new","title":"Q3","revisionId":"r1","slides":[{"objectId":"p"}]}', '{"presentationId":"untitled"}'} local created = c.createPresentation({title = "Q3"}) assert(created.presentationId == "new" and created.slides[1].objectId == "p") sent(API, {title = "Q3"}) assert(c.createPresentation().slides == nil) assert(requests[#requests].body == "{}", requests[#requests].body) responses = {'{"presentationId":"p1","replies":[{"createSlide":{"objectId":"q3_summary"}},{}],"writeControl":{"requiredRevisionId":"r2"}}'} local edits = { {createSlide = {objectId = "q3_summary", slideLayoutReference = {predefinedLayout = "TITLE_AND_BODY"}, placeholderIdMappings = {{layoutPlaceholder = {type = "TITLE"}, objectId = "q3_summary_title"}}}}, {insertText = {objectId = "q3_summary_title", text = "Q3 results"}}, } local reply = c.batchUpdate({presentationId = "https://docs.google.com/presentation/d/p1/edit#slide=id.g1", requests = edits, writeControl = {requiredRevisionId = "r1"}}) assert(reply.replies[1].createSlide.objectId == "q3_summary" and reply.writeControl.requiredRevisionId == "r2") sent(API .. "/p1:batchUpdate", {requests = edits, writeControl = {requiredRevisionId = "r1"}}) responses = {'{"presentationId":"p1","replies":[{"insertComment":{"commentThread":{"commentId":"c1","anchorId":"a1"}}}],"commentUpdateState":"ALL_SAVED"}'} local comment = {{insertComment = {content = "Update this chart", objectId = "g1"}}} assert(c.batchUpdate({presentationId = "p1", requests = comment}).commentUpdateState == "ALL_SAVED") sent(API .. "/p1:batchUpdate", {requests = comment}) -- Google's system parameters stay out of the URL; Google rejects them as unknown body fields. responses = {'{"presentationId":"p1","replies":[{}]}'} local clear = {{deleteText = {objectId = "g1", textRange = {type = "ALL"}}}} c.batchUpdate({presentationId = "p1", requests = clear, key = "k", access_token = "t", alt = "media", fields = "x"}) sent(API .. "/p1:batchUpdate", {requests = clear, key = "k", access_token = "t", alt = "media", fields = "x"}) local count = #requests assert(not pcall(c.createPresentation, "Q3")) assert(not pcall(c.createPresentation, {presentationId = "p1", title = "Copy"}), "createPresentation assigns the presentationId") assert(not pcall(c.batchUpdate, {presentationId = "p1"}), "batchUpdate requires requests") assert(not pcall(c.batchUpdate, {presentationId = "p1", requests = {}})) assert(not pcall(c.batchUpdate, {presentationId = "p1", requests = "x"})) assert(not pcall(c.batchUpdate, {presentationId = "p1", requests = {deleteObject = {objectId = "g1"}}})) assert(not pcall(c.batchUpdate, {requests = clear}), "batchUpdate requires presentationId") assert(not pcall(c.batchUpdate, {presentationId = "p/1", requests = clear})) assert(not pcall(c.batchUpdate, {presentationId = "https://docs.google.com/presentation/d/e/2PACX-1vS/pub", requests = clear})) assert(#requests == count, "invalid input reached Google") assert(#responses == 0) end, }