-
Notifications
You must be signed in to change notification settings - Fork 1
Add incoming webhook custom starter demo #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sqrrrl
wants to merge
2
commits into
googleworkspace:main
Choose a base branch
from
sqrrrl:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| # Sqlite | ||
| *.sqlite | ||
| *.sqlite-shm | ||
| *.sqlite-wal | ||
|
|
||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| lerna-debug.log* | ||
|
|
||
| # Diagnostic reports (https://nodejs.org/api/report.html) | ||
| report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
|
||
| # Runtime data | ||
| pids | ||
| *.pid | ||
| *.seed | ||
| *.pid.lock | ||
|
|
||
| # Directory for instrumented libs generated by jscoverage/JSCover | ||
| lib-cov | ||
|
|
||
| # Coverage directory used by tools like istanbul | ||
| coverage | ||
| *.lcov | ||
|
|
||
| # nyc test coverage | ||
| .nyc_output | ||
|
|
||
| # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
| .grunt | ||
|
|
||
| # Bower dependency directory (https://bower.io/) | ||
| bower_components | ||
|
|
||
| # node-waf configuration | ||
| .lock-wscript | ||
|
|
||
| # Compiled binary addons (https://nodejs.org/api/addons.html) | ||
| build/Release | ||
|
|
||
| # Dependency directories | ||
| node_modules/ | ||
| jspm_packages/ | ||
|
|
||
| # Snowpack dependency directory (https://snowpack.dev/) | ||
| web_modules/ | ||
|
|
||
| # TypeScript cache | ||
| *.tsbuildinfo | ||
|
|
||
| # Optional npm cache directory | ||
| .npm | ||
|
|
||
| # Optional eslint cache | ||
| .eslintcache | ||
|
|
||
| # Optional stylelint cache | ||
| .stylelintcache | ||
|
|
||
| # Optional REPL history | ||
| .node_repl_history | ||
|
|
||
| # Output of 'npm pack' | ||
| *.tgz | ||
|
|
||
| # Yarn Integrity file | ||
| .yarn-integrity | ||
|
|
||
| # dotenv environment variable files | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # parcel-bundler cache (https://parceljs.org/) | ||
| .cache | ||
| .parcel-cache | ||
|
|
||
| # Next.js build output | ||
| .next | ||
| out | ||
|
|
||
| # Nuxt.js build / generate output | ||
| .nuxt | ||
| dist | ||
| .output | ||
|
|
||
| # Gatsby files | ||
| .cache/ | ||
| # Comment in the public line in if your project uses Gatsby and not Next.js | ||
| # https://nextjs.org/blog/next-9-1#public-directory-support | ||
| # public | ||
|
|
||
| # vuepress build output | ||
| .vuepress/dist | ||
|
|
||
| # vuepress v2.x temp directory | ||
| .temp | ||
|
|
||
| # Sveltekit cache directory | ||
| .svelte-kit/ | ||
|
|
||
| # vitepress build output | ||
| **/.vitepress/dist | ||
|
|
||
| # vitepress cache directory | ||
| **/.vitepress/cache | ||
|
|
||
| # Docusaurus cache and generated files | ||
| .docusaurus | ||
|
|
||
| # Serverless directories | ||
| .serverless/ | ||
|
|
||
| # FuseBox cache | ||
| .fusebox/ | ||
|
|
||
| # DynamoDB Local files | ||
| .dynamodb/ | ||
|
|
||
| # Firebase cache directory | ||
| .firebase/ | ||
|
|
||
| # TernJS port file | ||
| .tern-port | ||
|
|
||
| # Stores Visual Studio Code versions used for testing Visual Studio Code extensions | ||
| .vscode-test | ||
|
|
||
| # pnpm | ||
| .pnpm-store | ||
|
|
||
| # yarn v3 | ||
| .pnp.* | ||
| .yarn/* | ||
| !.yarn/patches | ||
| !.yarn/plugins | ||
| !.yarn/releases | ||
| !.yarn/sdks | ||
| !.yarn/versions | ||
|
|
||
| # Vite files | ||
| vite.config.js.timestamp-* | ||
| vite.config.ts.timestamp-* | ||
| .vite/ | ||
|
|
||
| # Astro generated types | ||
| .astro/ | ||
|
|
||
| # Turbo Repo | ||
| .turbo | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Google Workspace Studio: Incoming Webhook Bridge Starter | ||
|
|
||
| This repository is a starter demo that demonstrates how to build an incoming webhook trigger for **Google Workspace Studio**. | ||
|
|
||
| It serves as a bridge between external services and your automated Workspace workflows. When an external tool (such as GitHub, Stripe, a monitoring service, or your own backend) sends an HTTP POST request to the webhook URL, this bridge receives the payload and triggers the corresponding workflow in Google Workspace Studio. | ||
|
|
||
| --- | ||
|
|
||
| ## What It Does | ||
|
|
||
| - **Provides a Webhook Endpoint**: Generates a dedicated webhook URL for each workflow you configure. | ||
| - **Connects External Systems**: Listens for incoming HTTP notifications and events from third-party tools. | ||
| - **Triggers Workspace Studio**: Validates incoming requests and immediately kicks off your Workspace Studio workflow with the event payload. | ||
|
|
||
| --- | ||
|
|
||
| ## What This Demo Demonstrates | ||
|
|
||
| - **Custom Triggers in Workspace Studio**: How to create and register custom triggers (like *"When a webhook is received"*) that appear natively in the Workspace Studio workflow builder. | ||
| - **Interactive Configuration Cards**: How to build in-editor cards where users can configure trigger options, authorize their account, and copy their generated webhook URL. | ||
| - **Account Authorization & Delegation**: How to handle Google authorization so the bridge can securely invoke Workspace Studio workflows on behalf of the user. | ||
| - **Optional Webhook Security**: How to support optional secret keys or API keys so only authorized callers can trigger the workflow. | ||
|
|
||
| --- | ||
|
|
||
| ## Getting Started | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - [Node.js](https://nodejs.org/) (v20 or higher recommended) | ||
| - `npm` (comes with Node.js) | ||
|
|
||
| ### 1. Install Dependencies | ||
|
|
||
| ```bash | ||
| npm install | ||
| ``` | ||
|
|
||
| ### 2. Database Generation & Setup | ||
|
|
||
| This demo uses SQLite to store trigger configurations and user credentials. Run the following commands to generate and push the database schema: | ||
|
|
||
| ```bash | ||
| # Generate database migration files from schema | ||
| npm run db:generate | ||
|
|
||
| # Push schema changes to initialize your local SQLite database | ||
| npm run db:push | ||
| ``` | ||
|
|
||
| ### 3. Build the Project | ||
|
|
||
| Compile the TypeScript code to JavaScript: | ||
|
|
||
| ```bash | ||
| npm run build | ||
| ``` | ||
|
|
||
| ### 4. Run the Project | ||
|
|
||
| - **Development Mode** (with auto-reload on file changes): | ||
| ```bash | ||
| npm run dev | ||
| ``` | ||
| - **Production Mode** (after running `npm run build`): | ||
| ```bash | ||
| npm run start | ||
| ``` | ||
| - **Run Tests**: | ||
| ```bash | ||
| npm test | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Registering the Add-on (`deployment.json`) | ||
|
|
||
| The file `deployment.json` is a **deployment manifest template** used to register this add-on with Google Workspace: | ||
|
|
||
| 1. **Host the application**: Deploy your server to a publicly reachable HTTPS host (such as Cloud Run, or use a tunneling tool like ngrok for local testing). | ||
| 2. **Update the manifest template**: Open `deployment.json` and replace `DEPLOYED_HOST_NAME` with your actual domain (e.g., `https://your-service-url.run.app`). | ||
| 3. **Register in Google Cloud**: Use this manifest when creating or updating your Google Workspace Add-on deployment in the Google Cloud Console. | ||
|
|
||
| Once deployed and installed, the webhook trigger will appear as an available starting step inside Google Workspace Studio. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| { | ||
| "oauthScopes": [ | ||
| "openid", | ||
| "https://www.googleapis.com/auth/script.locale", | ||
| "https://www.googleapis.com/auth/workspace.studio.trigger" | ||
| ], | ||
| "addOns": { | ||
| "common": { | ||
| "name": "Generic Incoming Webhook Bridge", | ||
| "logoUrl": "https://www.gstatic.com/images/icons/material/system/2x/webhook_black_48dp.png", | ||
| "useLocaleFromApp": true | ||
| }, | ||
| "studio": { | ||
| "flows": { | ||
| "workflowElements": [ | ||
| { | ||
| "id": "incoming_webhook_starter", | ||
| "state": "ACTIVE", | ||
| "name": "When a webhook is received", | ||
| "description": "Triggers the workflow when an arbitrary HTTP POST payload (up to 1 KB) is sent to your unique obfuscated webhook URL.", | ||
| "workflowTrigger": { | ||
| "onConfigFunction": "https://DEPLOYED_HOST_NAME/studio/on-config", | ||
| "onManageFunction": "https://DEPLOYED_HOST_NAME/studio/on-manage", | ||
| "inputs": [ | ||
| { | ||
| "id": "instanceId", | ||
| "description": "Internal instance correlation UUID generated on configuration card load.", | ||
| "cardinality": "SINGLE", | ||
| "dataType": { | ||
| "basicType": "STRING" | ||
| } | ||
| }, | ||
| { | ||
| "id": "requireApiKey", | ||
| "description": "Whether incoming webhook requests must provide an Authorization: ApiKey <secret> header.", | ||
| "cardinality": "SINGLE", | ||
| "dataType": { | ||
| "basicType": "BOOLEAN" | ||
| } | ||
| } | ||
| ], | ||
| "outputs": [ | ||
| { | ||
| "id": "rawPayload", | ||
| "description": "The raw UTF-8 payload string posted to the webhook URL (maximum 1 KB).", | ||
| "cardinality": "SINGLE", | ||
| "dataType": { | ||
| "basicType": "STRING" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { defineConfig } from 'drizzle-kit'; | ||
|
|
||
| export default defineConfig({ | ||
| schema: './src/db/schema.ts', | ||
| out: './drizzle', | ||
| dialect: 'sqlite', | ||
| dbCredentials: { | ||
| url: process.env.DATABASE_URL || './webhook-bridge.sqlite', | ||
| }, | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/db/index.tsimports{ DatabaseSync } from 'node:sqlite', which was introduced in Node.js v22.5.0 and does not exist in Node 20 (running on Node 20 fails immediately withERR_UNKNOWN_BUILTIN_MODULE: node:sqlite).Please update this prerequisite to Node.js v22.5.0 or higher (and consider adding
"engines": { "node": ">=22.5.0" }topackage.json).Also,
package.jsonrunsnode --env-file .envand.gitignorehas!.env.example, but there is no.env.examplein the repo andREADME.mddoesn't document the required environment variables (GOOGLE_OAUTH_CLIENT_ID,GOOGLE_OAUTH_CLIENT_SECRET,GOOGLE_ADDON_SERVICE_ACCOUNT_EMAIL,GOOGLE_ADDON_CLIENT_ID,COOKIE_SECRET,PUBLIC_BASE_URL). Could we add a.env.examplefile and an environment setup section here?