Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Google Workspace      Palantir Foundry

Gmail Compute Module for Foundry

Send emails through Gmail API using domain-wide delegation in Foundry


Important

You need admin access to both Google Workspace and Foundry to set this up.

Quick Start

  1. Setup Google Workspace

    • Enable Gmail API in Google Cloud Console
    • Create service account with domain delegation
    • Grant https://www.googleapis.com/auth/gmail.send scope
    • Create/Download service account credentials as JSON
  2. Prepare Credentials

    echo "$(cat service_account.json)" | base64
    => ewogICJ0...

    [!TIP] Base64 encoding helps handle the complex JSON cleanly in Foundry's secrets

  3. Configure Foundry

    • Create REST API Data Connection
    • Set egress policies for Gmail API
    • Import the compute module
    • Add base64 credentials as secret

Detailed Setup Guide

Click to expand step-by-step instructions with screenshots

1. Google Workspace Setup

Create Service Account
Service Account Setup

2. Foundry Configuration

Data Connection

Create Connection Configure Domain

Module Setup

Enable exports Set import rules Name your API
Exports Rules Name API

Secret Configuration

Store Service Account
Store Secret

Build & Deploy

Create compute module Choose Functions mode
Create Module Functions
Import data connection Build function
Import Build

Deploy & Verify

Create artifact Deploy container
Artifact Deploy
Update configuration Verify deployment
Config Verify

Final Steps

Import Function Test Email
Import Function Test Email

Usage

Whatever you called your namespace in compute module config is how you import the module in code: @<namespace>/computemodules

import { sendEmail } from "@gmail/computemodules"; 

await sendEmail({
  recipients: ['user@domain.com'],
  subject: 'Hello from Foundry!',
  message: '<h1>It works!</h1><p>Email sent via Gmail API.</p>'
});

Tip

Supports HTML formatting in email messages

Development

Warning

Due to the limitations of importing the Foundry Data Connection source locally the project has a test.js feature and some Compute Module initialization logic that only runs once you deploy the module. (likely chance this was just a 'me' problem)

# Local testing
npm run test

# Expected output:
Starting email test...
[Email Module] Processing email request: {...}
Test completed successfully!

Troubleshooting

Important

Common issues:

  • Check service account delegation
  • Verify OAuth scopes
  • Confirm egress policies
  • Validate base64 credentials

Security

Caution

  • Never commit credentials -- if you test locally name the 'secret' service_account.json
  • Ensure .gitignore and .dockerignore are up to date
  • Rotate keys regularly
  • Monitor API usage
  • Limit permissions

🚀 Part of Codestrap CommsForge

Watch Demo

Part of CommsForge - Open source for Palantir Developers (Q2 2025)

Ontology is all you need.