work-email. This guide uses a viewer-mode connection: each person supplies their own Gmail account on the hosted slate. It shows local and hosted setup separately because they save different assignments.
Before you start, sign in to the CLI as described in Installation and work from a private slate’s checkout. If your personal Owner already has a connected Gmail account, skip account authorization and go straight to assignment.
Add work-email to the app’s existing connections object in public/slate.json. Keep its other declarations. For a starter app that still uses the notes database, the result is:
public/slate.json
work-email is the connection slug the app passes to tools.call. gmail identifies the provider toolkit, and viewer selects the acting person’s account on the hosted slate. See Owner mode and viewer mode for the alternative of using one shared account.
Connect the account
The local workflow below uses an account connected for your personal Owner. If you are configuring an owner-mode connection for an organization instead, select that organization when connecting the account; see Personal and organization Owners.Assign it in local development
Assign the account to the connection
From the checkout root, assign a connected Gmail account to Choose the Gmail account you authorized from the interactive picker. The CLI offers your personal accounts for the connection’s toolkit and saves the selected account ID in the checkout’s ignored
work-email:.contextlayer/connections.json. Use npx @usecontextlayer/cli connections --help for noninteractive assignment and other targets.Assign it on the hosted slate
Commit and push the connection declaration, then wait for the hosted app to deploy; see Deploy. Hosted assignments use pushed declarations and are saved in ContextLayer. The local assignment file is not uploaded. Use the hosted app’s chrome, the ContextLayer header and configuration tray, to select the account. You can reuse the personal account you already connected without repeating provider authorization.Choose the account
Open the connection’s settings and select your connected Gmail account.If the account is not listed, select Connect account. The authorization opens in a new tab. When you have connected the account, refresh the slate and choose it.The chrome connects the account for the connection’s Owner: you for a viewer-mode connection, the slate’s Owner for an owner-mode connection.
Personal and organization Owners
An Owner is either personal (one user) or an organization. Every account belongs to one Owner, independently of any slate. Slates use an account through assignments; an assignment stores the account’s ID, never its credentials. Theaccounts command acts for your personal Owner by default and can act for an organization you are a member of; its --help shows how. Any member of an organization can connect and manage the organization’s accounts. An account a member connects for the organization belongs to the organization.
Owner mode and viewer mode
Each declared connection has a mode. It selects whose account the hosted slate uses.- Owner mode: the slate’s Owner’s account. Every user of the slate uses this one account. Assigning it requires managing the slate: being its owning user or a member of its owning organization.
- Viewer mode: each user’s own personal account. Each viewer connects and assigns their own in the chrome; see Use a slate.
Use the connection in app code
Once the assignment is saved, the app can call Gmail throughwork-email. This excerpt demonstrates a loader call, not a complete route or email interface. Merge the call into your route without removing its existing data or rendered component, and validate the provider result before using it:
app/routes/home.tsx