Skip to content

Black Friday

Annual Pro is $90 for the first year, normally $120. Or start monthly at $6 for two months, then $12.

Ends Dec 4, 11:59 PM PT.

Create an account
← Public packages

@kentcdodds/google

Google helpers for Gmail, Calendar, Drive, People, YouTube (including upload), and Analytics.

FollowFork

IntegrationsTopics: google, gmail, calendar, drive, people, youtube, oauth, multi-account

Version
0.6.1
License
MIT
Published
November 8, 2026
Pinned commit
c05fa88
Rating
No ratings yet
Forks
0
Adaptation effort
—

README

Agent docs

@kentcdodds/google

Intent

Account-aware Google product helpers for Kent's Kody workflows. Centralizes explicit account selection (personal, business, youtube-brand, youtube-plus), OAuth integration routing, shared API error handling, and dry-run guards for Gmail, Calendar, Drive, People, YouTube, and YouTube Analytics. Use cal-com for Cal.com booking pages and lifecycle, not this package.

What it does

  • Read or mutate Gmail, Google Calendar, Drive, and People with the correct Google account
  • Download binary Drive files (PDFs, images, video) as raw bytes with downloadFile, and copy a Drive file or folder into Dropbox with the resumable, verified scripts/copy-drive-to-dropbox.mjs box script
  • Reply to Gmail with createReplyDraft (quotes original + threading headers)
  • Turn a Gmail web link (or a thread or message id) into compact, read-only thread context with getEmailContext: subject, participants, label names, and each message's date, sender, recipients, plain-text body, and attachment list
  • Call YouTube Data / Analytics on Kent's main (youtube-brand) or plus (youtube-plus) channel, including uploadVideo / updateVideo
  • Post, edit, and list YouTube comments as the channel itself (insertCommentThread / updateComment / listVideoCommentThreads from ./youtube-comments, all with dryRun)
  • Look up contacts reliably with findContacts: give a name, nickname, email, or phone and it tries Google's contact search, then "other contacts", then a fuzzy scan of all saved contacts (so spelling variants and common nicknames still match). Results are compact (names, emails, phones, addresses), stay under the agent response size limit, and say which strategy found them
  • listConnections returns a compact, size-capped page by default and can filter by name, email, or phone, reporting truncated plus a resume cursor when there is more
  • Errors from Google name the helper, the account, the HTTP status, Google's reason, and a concrete next step (wrong account, missing scope, reconnect)
  • Resolve which account alias to use when a task mentions personal Gmail, Workspace calendar, or a specific YouTube channel
  • Find open time slots across both Google accounts in one read-only call with findFreeSlots: give a slot length, any mix of dates and date ranges, and a daily hours window, and get back free slots in local time. Dates already past are skipped, daylight saving time is handled per date, and if one account cannot be read the result says so instead of reporting that time as free
  • listEventsAcrossCalendars returns within a 20 second budget (60 second cap) and sets truncated when it stops early, instead of paging every calendar until the caller times out

Prerequisites / setup

Connect OAuth integrations at /connect/oauth (tokens are managed by Kody, not raw access-token secrets):

Account aliasOAuth integrationTypical use
personalgooglePersonal Gmail, Drive, default YouTube reads
businessgoogle-businessWorkspace Calendar and Gmail (me@kentcdodds.com)
youtube-brandgoogle-youtube-brandMain Kent C. Dodds YouTube channel
youtube-plusgoogle-youtube-pluskentcdodds-plus / BEPE channel

Account names are forgiving: case does not matter, and the integration name (google, google-business, ...) works as well as the alias. A few friendly synonyms also work, for example default or me for personal and work or workspace for business. An unknown name fails right away with a list of the valid names instead of reaching Google.

Gmail, Calendar, Drive, and YouTube helpers still require an explicit account so nothing is sent or changed from the wrong mailbox. The read-only People (contacts) helpers default to personal when account is left out. Use dryRun: true before Gmail sends or Calendar mutations. Agents: see AGENTS.md for import paths and smoke checks.

Contact search uses the contacts.readonly scope on the google integration. Searching "other contacts" (people you emailed but never saved) needs the extra contacts.other.readonly scope; without it findContacts skips that step and says so.

Gmail self-send trap (read this)

Replying to a message you already sent is the common footgun. Gmail's From is you; a naive "Reply-To else From" default puts To: you, and Kent emails himself.

createReplyDraft detects own-outbound mail (From is this mailbox) and defaults To to the original recipient(s) instead. Omit to unless you truly need an override. Composed createDraft / sendMessage refuse when to is only the mailbox unless you pass allowSelfSend: true.

createReplyDraft closes the quoting gap that raw createDraft leaves open: pass the message id being replied to plus the reply text, and it derives the recipient, subject, In-Reply-To, References, threadId, and the quoted original from the fetched message. Replies go out as multipart/related wrapping multipart/alternative (same shape mail clients produce). Pass cc / bcc when needed; they are not inferred. Pass dryRun: true to preview the assembled MIME without creating anything.

Do not set to to Kent's own address on a reply to his outbound mail; that is the self-send trap.

Kent publishes to two YouTube channels: main (youtube-brand, Better with Kent) and plus (youtube-plus, BEPE / legacy Chats with Kent). Resolve the channel before upload or analytics work.

Gmail draft Unicode / BCC (agents: read AGENTS.md)

Do not add Bcc (or rewrite a draft) by atob → edit → btoa on Gmail message.raw. Bare atob is Latin-1-per-byte and corrupts UTF-8 en-dashes from clients like Mimestream. Use updateDraftHeaders from kody:@kentcdodds/google/gmail for header-only changes, or the UTF-8-safe Base64 helpers (decodeUtf8Base64 / encodeUtf8Base64) when the body must change. Details and snippets: AGENTS.md.

Done when

  • Needed OAuth integrations are connected at /connect/oauth
  • An explicit account is passed on every Gmail, Calendar, Drive, and YouTube call (People helpers may omit it)
  • Contact lookups use findContacts and report which strategy found a match
  • findFreeSlots results with partial: true are treated as incomplete (an account or calendar could not be checked)
  • Gmail / Calendar mutations are previewed with dryRun: true before live use
  • Replies to Kent's own outbound mail do not To-only-self without allowSelfSend: true

Reliable file transfers

The included Drive-to-Dropbox script requires Kody CLI 3.33.1+ and resumes from private local checkpoints. It verifies content hashes instead of assuming same-sized files match. Missing source validators or uncertain completion stop for reconciliation rather than silently duplicating work. No new credentials or permissions are needed.

Report this listing

Log in to report this listing.