# Connectors

Connect Google, Microsoft Entra, GitHub, Apple, ChatGPT, Zoom and meeting importers to your Alim workspace. Replace `https://alim.example.com` below with your `PUBLIC_URL`.

For a self-hosted workspace without social OAuth, see [Sign in without Google](/docs/self-hosting.md#sign-in-without-google).

| Feature                                                    | App registration                             | Callback path                   | Where to connect                                          |
| ---------------------------------------------------------- | -------------------------------------------- | ------------------------------- | --------------------------------------------------------- |
| Social sign-in (Google, Microsoft, GitHub, Apple, ChatGPT) | Matching OAuth client env vars               | `/api/oauth2-redirect`          | Sign-in page or Settings                                  |
| Google Calendar, Meet links, invitations & Gmail           | Google OAuth web client                      | `/api/oauth/google/callback`    | Calendar, Create meeting or Emails                        |
| Google Drive files                                         | Google OAuth web client and a Picker API key | `/api/oauth/google/callback`    | Settings or the Files tab of a meeting, person or project |
| Outlook Calendar & Mail                                    | [Microsoft Entra Web app](#microsoft-entra)  | `/api/oauth/microsoft/callback` | Calendar or Emails → Mailboxes → Add Outlook              |
| Zoom meeting links & calendar                              | [Zoom user-managed General app](#zoom)       | `/api/oauth/zoom/callback`      | Calendar or Create meeting                                |

## Google

Calendar sync uses the name a provider supplies for a guest. If it supplies only an address, you can still find it in email suggestions.

Alim uses one Google OAuth web client for sign-in and optional Calendar, Meet, invitation, Gmail and Drive connections.

| Step                                                     | Console page                                                                              | You get                                                          |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [1. Create a project](#1-create-a-project)               | [Project create](https://console.cloud.google.com/projectcreate)                          | A project only for Alim                                          |
| [2. Enable APIs](#2-enable-apis)                         | [API library](https://console.cloud.google.com/apis/library/calendar-json.googleapis.com) | Calendar reads allowed                                           |
| [3. Fill in branding](#3-fill-in-branding)               | [Branding](https://console.cloud.google.com/auth/branding)                                | The consent screen                                               |
| [4. Choose the audience](#4-choose-the-audience)         | [Audience](https://console.cloud.google.com/auth/audience)                                | Who can sign in                                                  |
| [5. Add scopes](#5-add-scopes)                           | [Data access](https://console.cloud.google.com/auth/scopes)                               | The identity, Calendar, Meet, invitation, Gmail and Drive scopes |
| [6. Create the OAuth client](#6-create-the-oauth-client) | [Clients](https://console.cloud.google.com/auth/clients)                                  | `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET`                    |

### 1. Create a project

Use a dedicated Google Cloud project. A project has one consent screen, so sharing it with another app mixes names, logos and scope reviews.

```bash
gcloud projects create your_project_id --name="Alim"
gcloud config set project your_project_id
```

### 2. Enable APIs

```bash
gcloud services enable calendar-json.googleapis.com
```

Sign-in needs no extra API. Enable `meet.googleapis.com` for Meet link creation, `gmail.googleapis.com` if you offer Gmail sync, and `drive.googleapis.com` with `picker.googleapis.com` if you offer [Google Drive](#optional-google-drive).

### 3. Fill in branding

| Field              | Value                                                                                                   |
| ------------------ | ------------------------------------------------------------------------------------------------------- |
| App name           | `Alim`                                                                                                  |
| User support email | Your admin email                                                                                        |
| App logo           | Optional. A `120×120` PNG export of `/oauth-logo.png`. A logo on a production app triggers brand review |
| Home page          | `https://alim.example.com/`                                                                             |
| Privacy policy     | `https://alim.example.com/privacy/`                                                                     |
| Authorized domains | Your root domain, like `example.com`. Not `localhost`                                                   |

### 4. Choose the audience

Pick **External** if anyone will connect a personal `@gmail.com` account. **Internal** allows only accounts inside your Google Workspace organization.

| Publishing status | Who can sign in          | Calendar and mail tokens |
| ----------------- | ------------------------ | ------------------------ |
| Testing           | Up to 100 listed testers | Expire after 7 days      |
| In production     | Any Google account       | Persistent               |

> [!TIP]
> Use **In production**. Until Google verifies your Calendar, Meet and invitation scopes, people see **Google hasn't verified this app** when they connect a calendar, create a Meet link or send invitations, and continue with **Advanced → Go to example.com**. Sign-in itself shows no warning.

### 5. Add scopes

| Scope                                                            | Requested when                                      | Used for                                                     |
| ---------------------------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------ |
| `openid`                                                         | Sign-in and every Google connection                 | Account identity                                             |
| `.../auth/userinfo.email`                                        | Sign-in and every Google connection                 | Account email                                                |
| `.../auth/userinfo.profile`                                      | Sign-in and every Google connection                 | Name and avatar                                              |
| `https://www.googleapis.com/auth/calendar.events.owned.readonly` | Connecting Google Calendar                          | Reading events on calendars you own with `events.list`       |
| `https://www.googleapis.com/auth/meetings.space.created`         | Optional, choosing **Google Meet** while scheduling | [Creating a Meet link](#optional-meet-link-creation)         |
| `https://www.googleapis.com/auth/calendar.events.owned`          | Optional, sending invitations or an update | [Creating or updating an event you organize](#change-a-scheduled-event)         |
| `https://www.googleapis.com/auth/gmail.readonly`                 | Optional, adding a Gmail mailbox                    | [Reading mail with saved contacts](#optional-gmail)          |
| `https://www.googleapis.com/auth/drive.file`                     | Optional, connecting Google Drive                   | [Reading files picked in the Picker](#optional-google-drive) |
| `https://www.googleapis.com/auth/drive.readonly`                 | Optional, connecting Drive with search allowed      | [Searching Drive from Alim](#optional-google-drive)          |

Add only the scopes for the features you offer. Submit sensitive scopes in the [Verification Center](https://console.cloud.google.com/auth/verification) with a justification and a demo video showing each scope in use to remove the unverified-app warning.

### 6. Create the OAuth client

Create a **Web application** client named `Alim Web` with only these two redirect URIs per origin:

| Field                                      | Production                                           | Local                                             |
| ------------------------------------------ | ---------------------------------------------------- | ------------------------------------------------- |
| Authorized JavaScript origin               | `https://alim.example.com`                           | `http://127.0.0.1:8090`                           |
| Redirect URI for sign-in                   | `https://alim.example.com/api/oauth2-redirect`       | `http://127.0.0.1:8090/api/oauth2-redirect`       |
| Redirect URI for Calendar, Gmail and Drive | `https://alim.example.com/api/oauth/google/callback` | `http://127.0.0.1:8090/api/oauth/google/callback` |

Copy the client ID and secret into `.env` or your deploy secrets:

```dotenv
PUBLIC_URL=https://alim.example.com
GOOGLE_CLIENT_ID=1234567890123-your_client_id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your_client_secret
```

On every start the server writes these into the PocketBase Google provider with PKCE enabled, so you never paste them into the PocketBase admin UI. Restart and confirm `GET /api/config` returns `"oauth_providers": { "google": true, ... }`.

### Optional Meet link creation

Enable the [Google Meet REST API](https://console.cloud.google.com/apis/library/meet.googleapis.com) in the same project and add `https://www.googleapis.com/auth/meetings.space.created` in **Data access**. Alim requests this scope only when a user chooses to generate a Meet link while scheduling. Creating a Meet space returns the link without adding a Calendar event or emailing guests.

### Optional Gmail

Synced mail is readable while [project matching](/docs/people-and-projects.md#how-threads-match) catches up.

Hosted Gmail is limited to designated reviewers during restricted-scope verification. Self-hosted servers offer Gmail by default. To restrict self-hosted Gmail to a private beta, set `OPENSCRIBE_GMAIL=off` and list eligible Alim account emails in `OPENSCRIBE_GMAIL_REVIEWERS` separated by commas. An empty list disables Gmail for everyone.

1. Enable the [Gmail API](https://console.cloud.google.com/apis/library/gmail.googleapis.com) in the same project (`gcloud services enable gmail.googleapis.com --project YOUR_PROJECT_ID`).
2. Confirm `https://alim.example.com/api/oauth/google/callback` is registered on `Alim Web` under **Clients**.
3. Add `https://www.googleapis.com/auth/gmail.readonly` under **Data access**. For an app in Testing, add a controlled test mailbox under **Audience → Test users**.
4. Choose **Add Gmail** in the [Mailboxes chooser](/docs/people-and-projects.md#connect-a-mailbox) and complete consent.

`gmail.readonly` is a restricted scope. Operators distributing an external OAuth client must follow [Google's restricted-scope verification requirements](https://support.google.com/cloud/answer/9110914), including any required security assessment.

### Optional Google Drive

Drive access is read only and never writes to Drive.

| Scope                        | Lets people                                                           | Who gets it                                                                                                                                                                               |
| ---------------------------- | --------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `drive.file`, non-sensitive  | Pick files with the Google Picker                                     | Every user                                                                                                                                                                                |
| `drive.readonly`, restricted | Search Drive from Alim and read pasted Drive file links automatically | Off until you set `OPENSCRIBE_DRIVE_SEARCH=on` or list Alim account emails in `OPENSCRIBE_DRIVE_REVIEWERS`. The hosted server offers it only to reviewers until Google verifies the scope |

1. Enable the [Google Drive API](https://console.cloud.google.com/apis/library/drive.googleapis.com) and the [Google Picker API](https://console.cloud.google.com/apis/library/picker.googleapis.com) (`gcloud services enable drive.googleapis.com picker.googleapis.com --project YOUR_PROJECT_ID`).
2. Under [Credentials](https://console.cloud.google.com/apis/credentials), create an API key. Restrict it to **Websites** with `https://alim.example.com/*` (and `http://127.0.0.1:8090/*` for local use), and to the **Google Picker API** only.
3. Copy the project number from the [dashboard](https://console.cloud.google.com/home/dashboard). The Picker uses it as the app ID, so picked files are shared with this OAuth client.
4. Add `https://www.googleapis.com/auth/drive.file` under **Data access**, and `https://www.googleapis.com/auth/drive.readonly` only if you offer search.
5. Set the key and number, then restart:

   ```dotenv
   GOOGLE_PICKER_API_KEY=your_browser_api_key
   GOOGLE_CLOUD_PROJECT_NUMBER=123456789012
   ```

6. Open **Settings → Files → Google Drive → Connect**, or click **+ Add** on the **Files** tab of a meeting, person or project and choose **Google Drive** (alongside **Upload** and **Paste link**).

| File type              | What Alim saves                                   |
| ---------------------- | ------------------------------------------------- |
| Google Docs and Slides | Plain text, up to `32,000` characters             |
| Google Sheets          | The first sheet as CSV, up to `32,000` characters |
| Plain text files       | The text, up to `32,000` characters               |
| PDFs and other files   | Name, type and link only                          |

Meeting Ask, summaries and Workspace Chat read the saved text of linked files and cite them.

> [!IMPORTANT]
> Saving file text requires `OPENSCRIBE_PII_URL`. Text passes through the private redaction service before it is saved. If `OPENSCRIBE_PII_URL` is unset or unreachable, Alim withholds the text, alongside its financial keyword checks.

Alim detects Google Drive file and folder links pasted in **+ Add → Paste link**, meeting notes or person and project links:

| Connection scope | Pasted file link                                                                    | Pasted folder link                                                                  |
| ---------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `drive.readonly` | Read automatically                                                                  | A preview opens to confirm up to 20 files                                           |
| `drive.file`     | Saved as a link until you click **Allow Alim to read** and pick it in Google Picker | Saved as a link until you click **Allow Alim to read** and pick it in Google Picker |

`drive.readonly` is a restricted scope. Operators distributing an external OAuth client must follow [Google's restricted-scope verification requirements](https://support.google.com/cloud/answer/9110914), including any required security assessment.

### How calendar connection works

![Connecting a Google Calendar account](/docs/assets/calendar-oauth-flow.svg)

The callback accepts a request only when all of these hold:

- **Signed state**: the `state` value carries an HMAC-SHA256 signature and expires after 15 minutes
- **Same browser**: the `alim_calendar_oauth_bind` (or `alim_email_oauth_bind` for Gmail and `alim_drive_oauth_bind` for Drive) cookie matches the one set when the flow started
- **One use**: the stored nonce is deleted before the code exchange, so a replayed callback fails
- **PKCE**: the code exchange sends the S256 verifier

If a connection expires or fails, start **Connect** again in the same browser. The callback clears its one-use browser cookie, so reloading the old callback cannot finish the connection.

Google shows the account chooser (`prompt=consent select_account`) so users can connect multiple accounts. When `login_hint` is supplied, Google uses `prompt=consent` and skips the chooser.

> [!WARNING]
> Start a test from **Connect Google Calendar** or `POST /api/calendar/connect`. A handcrafted callback URL like `?code=test&state=test` fails (`400` JSON for `Accept: application/json`, or a `302` redirect to `/?oauth_error=failed` in a browser).

### Schedule a meeting

1. In **Calendar**, click **+** (**Create meeting**).
2. Enter a title, date, time and optional time zone, then add participant emails. The length menu offers 15, 30, 45, 60 and 90 minutes or any custom number of minutes.
3. Under **Where**, choose **Google Meet** or **Zoom** to create a link when you save, choose **Microsoft Teams** and paste its meeting link, or type any other link or a place such as a room. Alim cannot create Teams links.
4. Save:

| Button                    | Result                                                                                        |
| ------------------------- | --------------------------------------------------------------------------------------------- |
| **Save meeting** or **Create and invite** | Saves your plan. **Create and invite** sends invitations from the selected Google account. |
| **Save without inviting** | Stores the meeting in Alim and emails nobody                                                  |

### Change a scheduled event

Click an event's title in **Calendar** to open its event page. Tap a value to change it:

| Row        | How to change it                                                                                             |
| ---------- | ------------------------------------------------------------------------------------------------------------ |
| Title      | Rename it in place                                                                                           |
| Day        | Pick a date, or **Today**, **Tomorrow** or **Next Monday**                                                   |
| Time       | Type a start time or change the time zone. The length stays the same                                         |
| Length     | Pick a preset or type a whole number of minutes                                                              |
| Where      | **Google Meet** or **Zoom** creates a new link. **Microsoft Teams** takes a pasted link. Other text is a place |
| Guests     | Add people by name or email, or remove them                                                                  |
| Notes      | Text guests see in the calendar event                                                                        |

The day schedule beside the rows lists your other events. Click a free opening to move the meeting there with the same length. Openings that would overlap another event are not offered. **Describe a change** reads a sentence such as "Friday at 10, 45 min, invite Lena", shows each change for you to keep or skip, and applies them when you press Enter or click **Apply**. In a new meeting, **Describe the event** fills the draft before you create it.

Every change saves in Alim at once and **Undo** reverses it. Guests hear nothing until you click **Send update** (or **Send invitations** for a meeting nobody was invited to yet) and confirm. Alim then updates the Google Calendar event, and Google emails the guests. A change to one occurrence of a recurring event updates only that occurrence. Only the organizer can change an event. Events you were invited to, and events from Outlook or Zoom calendars, open read-only or keep their guests' copy unchanged. A linked attendee’s name opens their person page. **Back to event** returns to the same event.

### Google troubleshooting

| Symptom                                                                 | Cause                                                           | Fix                                                                                              |
| ----------------------------------------------------------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `redirect_uri_mismatch`                                                 | Callback missing from the active OAuth client                   | Compare `oauth_providers.google` and `public_url` in `/api/config` with the Cloud Console client |
| Gmail connects but Sync reports API disabled                            | `gmail.googleapis.com` is disabled in the client's project      | Enable the Gmail API in that project and retry Sync                                              |
| **Google Drive** in **+ Add** shows no Picker or an invalid key error   | Picker API disabled, or the key's website or API restriction    | Enable `picker.googleapis.com` and allow your origin and the Picker API on the key               |
| A picked file returns "not shared with Alim"                            | `GOOGLE_CLOUD_PROJECT_NUMBER` is not the OAuth client's project | Use the number of the project that holds `Alim Web`                                              |
| `403 access_denied`, app is being tested                                | Account is not a test user                                      | Add it under **Audience → Test users**, or publish to **In production**                          |
| Calendar sync turns `error` after 7 days                                | App is still in **Testing**                                     | Publish to **In production**, then reconnect the calendar                                        |
| Calendar sync shows `error`                                             | Calendar API disabled or token encryption key changed           | Enable the API and reconnect the calendar                                                        |
| Connect returns `400`, OAuth not configured                             | Client ID or secret missing                                     | Set `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET`, then restart                                  |
| Callback rejects browser binding (`400` JSON or `/?oauth_error=failed`) | Browser opened `localhost` while `PUBLIC_URL` uses `127.0.0.1`  | Open the app at the exact `PUBLIC_URL` origin                                                    |

## Microsoft Entra

Connect Microsoft sign-in, Outlook Calendar and Outlook Mail with one Microsoft Entra Web app registration.

1. **Register the application** in **Microsoft Entra → App registrations → New registration**:

   | Field                          | Value                                                                                                                                                                            |
   | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
   | Name                           | `Alim`                                                                                                                                                                           |
   | Supported account types        | **Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant) and personal Microsoft accounts**                                                       |
   | Redirect URI, platform **Web** | `https://alim.example.com/api/oauth/microsoft/callback`                                                                                                                          |
   | Extra redirect URIs            | `http://127.0.0.1:8090/api/oauth/microsoft/callback` for local runs. For sign-in, `https://alim.example.com/api/oauth2-redirect` and `http://127.0.0.1:8090/api/oauth2-redirect` |

2. **Add Microsoft Graph delegated permissions**: under **API permissions → Add a permission → Microsoft Graph → Delegated permissions**, add `User.Read` and `offline_access` (used by both connections), `Calendars.Read` (Outlook Calendar) and `Mail.Read` (Outlook Mail).
3. **Fill in branding and properties**: optionally upload a `215×215` app logo, set Home page URL to `https://alim.example.com/` and set Privacy statement URL to `https://alim.example.com/privacy/`.
4. **Create a client secret and configure Alim**: under **Certificates & secrets**, create a secret and store both values in `.env` or your deploy secrets:

   ```dotenv
   MICROSOFT_CLIENT_ID=your_application_client_id
   MICROSOFT_CLIENT_SECRET=your_client_secret_value
   ```

5. Restart Alim, then test Outlook Calendar (**Calendar**) and Outlook Mail (**Emails → Mailboxes → Add Outlook**) separately with a test Microsoft account.

## Zoom

Connect Zoom to create scheduled Zoom meeting links and optionally sync your primary Zoom calendar.

1. Open [Zoom App Marketplace](https://marketplace.zoom.us/user/build), accept the Marketplace Terms of Use, choose **Build App → General App → User-managed**, and name the app `Alim`.
2. Set both **OAuth Redirect URL** and **OAuth Allow Lists** to `https://alim.example.com/api/oauth/zoom/callback`. Zoom requires an HTTPS `PUBLIC_URL`.
3. Under **Scopes**, add `user:read:user` and `meeting:write:meeting` (required for creating meeting links). To offer Zoom calendar sync, also add `calendar:read:list_calendar_lists` and `calendar:read:list_events` as optional scopes. Calendar sync requires [Zoom Calendar Service](https://support.zoom.com/hc/en/article?id=zm_kb&sysparm_article=KB0060807) enabled on the connected account.
4. Copy the client credentials into `.env` or your deploy secrets:

   ```dotenv
   ZOOM_CLIENT_ID=your_zoom_client_id
   ZOOM_CLIENT_SECRET=your_zoom_client_secret
   ```

5. Restart Alim and test both link creation and calendar sync.

> [!NOTE]
> Use your Zoom app's **Development** credentials while testing on your own Zoom account. Before offering the Zoom connector to external Zoom accounts, complete Zoom Marketplace publishing review and switch to **Production** credentials.

## Meeting imports

### Tactiq

[Import from Tactiq](/docs/mac-and-chrome.md#import-from-tactiq) with the Chrome extension. For a self-hosted server, [approve your site](/docs/mac-and-chrome.md#approve-a-self-hosted-site) first.

If a meeting has no transcript yet, it stays in Tactiq. For new transcripts, manual and daily imports follow the checks below.

![Transcripts with one to seven nonempty turns import directly. Longer transcripts are skipped only if two checks find widespread garbling and no clear exchange.](/docs/assets/tactiq-caption-check.svg)

- Open a saved transcript while the rest of the batch imports.
- For a skipped source, choose **View in Tactiq**. Changed captions can be checked again. Alim receives text only and cannot verify the spoken language.

### tldv

1. Enter your tldv API key on the **Imports** page.
2. The server encrypts the key for your workspace and checks daily for new calls.

Disconnecting removes the saved key.
