Read and Export Google Docs and Slides

Site docs.google.comTask read-google-docVersion v3Updated Aug 16, 2026Category document-reading

Open an identified Google Doc or Slides presentation through a direct readable/export URL and extract its visible text, with optional authenticated PDF export for Docs. This skill was captured from a live agent session on docs.google.com and publishes here verbatim, exactly as an agent receives it.

NoteSelectors and URL schemes drift as sites change. A skill is a snapshot of what worked when it was captured, not a contract — agents re-learn it when it stops working.

Purpose

Read the text contents of an identified Google Doc or Google Slides presentation using the caller's authenticated Browserless browser profile, without relying on the interactive editor shell. Optionally retrieve an authenticated PDF representation for a Google Doc.

When to Use

Use when the caller supplies a standard Google Docs or Google Slides URL, document/presentation ID, or an identified file accessible through the configured Browserless profile. The session must retain the caller's authentication and permissions.

Workflow

  1. Determine the resource type and opaque ID from the supplied URL. A Doc ID is the segment in /document/d/{document-id}/; a Slides presentation ID is the segment in /presentation/d/{presentation-id}/. Do not guess an ID.
  2. For a Google Slides presentation, construct and navigate directly to https://docs.google.com/presentation/d/{presentation-id}/export/txt. This export endpoint returns the presentation's slide text and avoids the interactive Slides application.
  3. On the loaded Slides export page, run this evaluator:
(() => {
  const text = (document.body?.innerText || document.body?.textContent || '').trim();
  return { title: document.title, text };
})()
  1. For a Google Doc, navigate directly to https://docs.google.com/document/d/{document-id}/mobilebasic instead of the /edit application shell. For visible text, run:
(() => {
  const root = document.querySelector('#contents') || document.body;
  return {
    title: document.title,
    text: (root.innerText || root.textContent || '').trim()
  };
})()
  1. For a Google Doc PDF download, use https://docs.google.com/document/d/{document-id}/export?format=pdf. From the loaded mobile-basic page, run this evaluator and return pdfBase64 to the caller for local PDF decoding:
(async () => {
  const match = location.pathname.match(/\/document\/d\/([^/]+)/);
  if (!match) return {ok: false, error: 'Document ID not found in current URL'};
  const documentId = match[1];
  const response = await fetch(`/document/d/${encodeURIComponent(documentId)}/export?format=pdf`, {
    credentials: 'include'
  });
  const bytes = new Uint8Array(await response.arrayBuffer());
  let binary = '';
  for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
  return {
    ok: response.ok,
    status: response.status,
    contentType: response.headers.get('content-type'),
    bytes: bytes.length,
    pdfBase64: btoa(binary),
    isPdf: bytes.length >= 4 && String.fromCharCode(bytes[0], bytes[1], bytes[2], bytes[3]) === '%PDF'
  };
})()

Site-Specific Gotchas

  • Google Slides has a direct plain-text export at /presentation/d/{presentation-id}/export/txt; use it as the first and usually only navigation for text extraction.
  • The Slides text export may render as a plain body rather than a structured document, so extract document.body.innerText with a text-content fallback.
  • The /mobilebasic suffix is the direct readable representation for a Google Doc and avoids relying on the interactive Docs editor UI.
  • The PDF endpoint is the document's /export?format=pdf URL, not the /mobilebasic URL; retain the authenticated browser session when fetching it.
  • Preserve the caller's Browserless profile/session, such as mcps-matthew; an unauthenticated session may show sign-in, access-denied, or error content instead of the file.
  • Document and presentation IDs are opaque URL segments. Read them from the supplied URL and never fabricate them.
  • Check extracted text for access or authentication error messages before treating it as the requested content.
  • Check status, contentType, and isPdf before treating returned PDF base64 as a valid PDF.

Expected Output

For reading a Google Doc or Slides presentation, return:

{"title":"<page title>","text":"<visible document or presentation text>"}

For PDF retrieval, return:

{"ok":true,"status":200,"contentType":"application/pdf","bytes":12345,"pdfBase64":"<base64 PDF>","isPdf":true}

The text may include UI, authentication, or access-error messaging if the configured session cannot access the resource. The PDF response may similarly contain an error page rather than a PDF when access is unavailable.

Call it

GET https://production-sfo.browserless.io/skills?token=TOKEN-HERE&domain=docs.google.com&task=read-google-doc