diff --git a/.dev.vars.example b/.dev.vars.example index f0c881b3..730d8b5d 100644 --- a/.dev.vars.example +++ b/.dev.vars.example @@ -1,3 +1,19 @@ # Cloudflare Access (required in production). TEAM_DOMAIN may be the base Access URL or the full /cdn-cgi/access/certs URL. POLICY_AUD=your-access-policy-audience-tag TEAM_DOMAIN=https://your-team.cloudflareaccess.com +# Optional Google Drive import. Share selected files with this service account. +GOOGLE_SERVICE_ACCOUNT_EMAIL=service-account@example.iam.gserviceaccount.com +GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----\\n" +# Optional Microsoft Graph app-only OneDrive import. +MICROSOFT_TENANT_ID=your-tenant-id +MICROSOFT_CLIENT_ID=your-app-client-id +MICROSOFT_CLIENT_SECRET=your-app-client-secret +ONEDRIVE_USER_ID=person@example.com +# Microsoft OAuth (required for the Outlook connector) +MICROSOFT_TENANT_ID=common +MICROSOFT_CLIENT_ID= +MICROSOFT_CLIENT_SECRET= +MICROSOFT_REDIRECT_URI=http://localhost:5173/auth/microsoft/callback +APP_ORIGIN=http://localhost:5173 +# Generate a separate random value for production token encryption. +TOKEN_ENCRYPTION_KEY= diff --git a/README.md b/README.md index e1e2eb72..065b1424 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ https://github.com/cloudflare/agentic-inbox/issues/4#issuecomment-4269118513 - **Built-in AI agent** — Side panel with 9 email tools for reading, searching, drafting, and sending - **Auto-draft on new email** — Agent automatically reads inbound emails and generates draft replies, always requiring explicit confirmation before sending - **Configurable and persistent** — Custom system prompts per mailbox, persistent chat history, streaming markdown responses, and tool call visibility +- **Evidence-backed memory** — Markdown/file memory with keyword and optional semantic retrieval, source provenance, confirmed facts, Google Drive imports, and operator-visible drafting context ## Stack @@ -62,6 +63,55 @@ npm run dev 1. Set your domain in `wrangler.jsonc` 2. Create an R2 bucket named `agentic-inbox`: `wrangler r2 bucket create agentic-inbox` +### Optional cloud-drive memory imports + +Configure `GOOGLE_SERVICE_ACCOUNT_EMAIL` and `GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY` as Worker secrets, then share selected Drive files with that service account. In Memory, choose **Google Drive** and paste the selected file IDs. Imports are mailbox-scoped, deduplicated by Drive file ID, converted to Markdown-compatible text, chunked, and indexed through the same pipeline as uploaded files. + +For Microsoft OneDrive, configure `MICROSOFT_TENANT_ID`, `MICROSOFT_CLIENT_ID`, `MICROSOFT_CLIENT_SECRET`, and `ONEDRIVE_USER_ID` as Worker secrets. Grant the Microsoft Entra app the least-privilege Microsoft Graph application permission needed to read the configured user drive, then choose **Microsoft OneDrive** in Memory and paste selected file IDs. OneDrive imports use the same normalization, chunking, provenance, deduplication, and fact-review pipeline. + +### Outlook + Power Automate workflows + +The recommended no-Premium workflow uses standard Outlook email actions and the existing Cloudflare Email Routing receiver: + +``` +Outlook: When a new email arrives (V3) + -> Forward an email (V2) to the Agentic Inbox address +Cloudflare Email Routing + -> Agentic Inbox Worker receives and stores the message + -> EmailAgent + Workers AI create an Agentic Inbox draft + -> Operator reviews and sends from Agentic Inbox +``` + +This path does not require Microsoft OAuth tokens in Cloudflare, OneDrive, or the Premium HTTP connector. Configure the forwarding destination as a mailbox already created in Agentic Inbox, for example `ai@example.com`, and ensure Cloudflare Email Routing forwards that address to this Worker. + +#### Optional Premium HTTP bridge + +The separately deployed bridge is available at: + +```text +https://outlook-ai-bridge.shorlol.workers.dev/integrations/power-automate/outlook +``` + +It accepts an authenticated JSON POST and returns parsed `classification`, `priority`, `draftSubject`, `draftBodyHtml`, and `confidence` fields. It is intended for Power Automate's Premium **HTTP** action and does not persist messages or send mail: + +```text +Outlook trigger -> Premium HTTP POST -> Workers AI JSON -> Outlook Create draft +``` + +Configure its secret with `npx wrangler secret put BRIDGE_SECRET --name outlook-ai-bridge`. Do not use the Office 365 Users or Office 365 Outlook **Send an HTTP request** actions as substitutes: those actions are Microsoft Graph-specific, not general external HTTP clients. + +#### Outlook Drafts without Premium HTTP + +Putting the AI result into the Outlook Drafts folder without Premium HTTP requires a second email relay that is not yet part of the Worker: + +```text +Outlook -> standard Forward action -> Agentic Inbox + Workers AI + -> Worker sends a structured [Agentic Draft] result email + -> Outlook trigger -> Parse JSON -> Draft an email message +``` + +The required backend addition is a Worker result-email step containing the original recipient, generated subject, and generated HTML body. The second standard Outlook flow can then create the real Outlook draft and optionally delete the temporary result email. Until that relay is implemented, AI drafts are available in Agentic Inbox only. + ### Deploy ```bash diff --git a/add-in/manifest.xml b/add-in/manifest.xml new file mode 100644 index 00000000..411f508a --- /dev/null +++ b/add-in/manifest.xml @@ -0,0 +1,132 @@ + + + + c4ae0c81-89f5-40d3-b8f8-e1eaaef82f66 + 1.0.0.0 + Cloudflare + en-US + + + + + + + https://YOUR-ADDIN-HOST.example.com + + + + + + + + + + +
+ + + 320 + +
+
+ + + 320 + +
+
+ ReadWriteItem + + + + + false + + + + + + + + + + + + + + +