Trigger Workspace Studio Workflows from Anywhere
Workspace Studio recently launched support for custom starters. These are Google Workspace Add-ons that can send events to and trigger a workflow run. Ever since getting my hands on Studio, I’ve been craving this feature along with custom steps. Together, they make workflows a lot more powerful.
The very first starter I wanted is a simple one—an incoming webhook that I can post from anywhere. Simple webhooks are amazingly useful. Anything that can send a webhook becomes an event source. Shell scripts with a single curl command become event sources. Pretty much anything with an HTTP client is, you guessed it, an event source.
They’re so useful that you might think Studio would support them out of the box.
It doesn’t. So I built my own—a proof of concept, at least.
Building it turned out to be a great way to learn some of the subtleties of how custom starters work. It also made me question: “Do I really need this, or is there a simpler option available?”
Sometimes “no” is the right answer
Truth is, you don’t always need to write a custom starter to trigger your workflows from other systems. There’s a good chance that the information you need to start your workflow is already sitting in your inbox—or maybe already quietly archived and unread thanks to a filter you set up years ago. (And maybe I’m projecting a wee bit.)
Either way, lots of systems send notification emails, and these are great for triggering workflows. The When I get an email starter works best when it’s given a specific filter, like a sender or text pattern to match. This works well for most notifications from GitHub, issue trackers, HR systems, and so on. Often those emails contain enough information to be actionable, and you can use the Extract step to ask Gemini to pull out the details needed for the rest of the workflow.

It works, and Gmail acts as a natural queuing mechanism. It’s a little noisy, but that’s easily addressed by archiving or deleting notifications as part of the workflow. Still, not every system sends emails—or maybe you’re triggering a workflow from a custom script, a CI/CD job, or an internal service where setting up an outbound mail server just to fire a workflow is complete overkill.
Before moving on, there’s one other hack worth mentioning, even though it turned out to be a dead end. Could the When I get a chat message starter be used? After all, Chat supports webhooks too! Create a space, enable webhooks, and you now have an instant incoming webhook endpoint you can trigger workflows from! Sadly, no. The Chat starter ignores messages received from webhooks. Would have been a fun hack if it worked!
Custom starter it is.
Building a universal starter
I have a few requirements for my incoming webhook starter (source):
- The webhook URL must be stable, unique, and unguessable for a workflow.
- Authentication is optional, and when enabled, uses a shared secret.
- Callers can post anything (up to 1 KB of raw UTF-8 text or JSON, passed into the workflow as a
rawPayloadstring output variable).
Easy enough—it’s a classic webhook, albeit with weaker guarantees than more modern techniques that sign payloads, such as Standard Webhooks.
Design challenges (and how to solve them)
While the concept of an incoming webhook is straightforward, bridging external HTTP requests into Workspace Studio’s trigger lifecycle surfaced a few interesting design challenges:
Subscription IDs aren’t stable across edits: Workspace Studio doesn’t update existing trigger subscriptions in place—it only creates and deletes them. Every time a user edits and saves their workflow, Studio mints a brand-new triggerId. If we based our webhook URL on Studio’s triggerId, the user’s webhook URL would change every time they tweaked their workflow!
To keep the webhook URL stable, we declare an instanceId input on the starter in deployment.json and render it as a hidden textInput widget (visibility: "HIDDEN") on the configuration card. The first time /studio/on-config loads, we seed it with a random UUID if one isn’t already set. Because Studio persists starter inputs across edits, this UUID stays tied to that starter instance for the life of the workflow—and pre-seeding it means we can display the copy-ready webhook URL (/webhook/:instanceId) and a sample curl command immediately in the card before the user even saves the flow.
There’s a small catch. When a user saves changes to an already-running workflow, Studio calls /studio/on-manage to create the new trigger subscription (triggerCreation) before it deletes the old one (triggerDeletion). That means for a brief window, two active subscriptions exist in our database with the same instanceId. To handle this cleanly, triggerId is the primary key in our subscriptions table rather than instanceId, and we record updatedAt timestamps on every row. When a webhook arrives for an instanceId, we query ORDER BY updated_at DESC LIMIT 1 so the newest subscription always wins.
Offline OAuth & refresh tokens: Firing a Studio starter asynchronously via its notifyUri (https://workspacestudio.googleapis.com/v1/triggers/{triggerId}:fire) requires an OAuth token with the https://www.googleapis.com/auth/workspace.studio.trigger scope. Google Workspace Add-ons provides a token, but it’s a short short-lived access token that an add-on normally receives during a card interaction only lasts for an hour. When an external webhook arrives days or weeks later, the user isn’t in the loop at all.
To get a credential that lasts indefinitely, the configuration card includes an Authorize Account button that opens a popup overlay (openAs: "OVERLAY", onClose: "RELOAD") to run a standard OAuth 2.0 Web App flow with access_type=offline and prompt=consent. If a user tries to turn on the workflow before completing this step, /studio/on-manage blocks activation and returns an actionable returnElementErrorAction instructing them to authorize first.
Read-once secrets in a constrained Card UI: API keys and webhook secrets aren’t values we want stored in plain text as standard starter inputs where anyone inspecting the workflow configuration can read them back. Instead, I designed secrets as “live” settings tied to the instanceId. When a user toggles on Require API Key or clicks Add Secret, the server generates a random whsec_... key, stores only its SHA-256 hash and a masked label (like Prod Key (whsec_1a2b...8e9f)) in the database, and uses Studio’s partial card updates (modifyOperations with replaceSection) to reveal the raw key in a copyable field once. On subsequent card loads, only the masked label and a delete button are shown. And because secrets are keyed by instanceId, they survive workflow edits and are only garbage-collected when the last subscription for that instanceId is deleted.
Rate limits and backpressure: Workflows are rate limited. Rate limits aren’t anything new and something all apps have to deal with when calling remote APIs. The two main tools we have are queueing and back pressure. Queuing decouples the sender and receiver is a very common pattern. Queuing alone, though, isn’t enough. At some point you need to tell the producer to slow down — that’s back pressure.
Since this is a proof of concept and the use cases I had in mind are low volume, I opted for a direct path, no queueing. The Workspace Studio API handles rate limiting for us, returning the expected 429 error if we’re pushing too hard. These errors are propagated through to the producer, giving us proper back pressure.
Architecture
The proof-of-concept is a lightweight Node.js and TypeScript web application built with Express, Drizzle ORM, and SQLite (better-sqlite3). It exposes three distinct route groups alongside a local SQLite store:

- Studio Add-on endpoints (
/studio/*): Handles card configuration (/studio/on-config), interactive card callbacks for toggling and managing API keys (/studio/on-toggle-api-key,/studio/on-add-secret,/studio/on-delete-secret), and subscription lifecycle events (/studio/on-manage). Every request is authenticated with dual JWT checks verifying both Google’s system token and the end user’s ID token. - OAuth 2.0 Web App endpoints (
/auth/*): Serves the popup authorization flow (/auth/start,/auth/initiate, and/auth/callback) protected by signed CSRF cookies and PKCE (S256) to obtain and store long-lived offline refresh tokens keyed by the user’s immutable Google Account ID (sub). - Webhook ingestion endpoint (
POST /webhook/:identifier): A public endpoint backed by a strict 1 KB raw body parser. It resolves the active subscription, performs a constant-time hash comparison if an API key is required, refreshes or reuses the owner’s cached OAuth access token, and dispatches aFireTriggerRequestto Studio. - SQLite database (
src/db/schema.ts): Three tables:users(storesrefresh_tokenand cachedaccess_tokenwith expiry),subscriptions(maps Studio’strigger_idand cardinstance_idtonotify_uri), andsecrets(stores SHA-256 hashes of optional API keys).
What I’d do differently
As I said, it’s a proof-of-concept. Not at all production hardened, and there are a few implementation details and features I’d rethink in a second pass.
Support signed payloads: We already have a shared secret, and signing payloads adds security by avoiding sending the key itself over the wire while ensuring the integrity of the message. The trade-off is that we lose some universality, since signing requires custom logic on the sender side. Adopting a specification like standardwebhooks.com helps here, and would likely also mean supporting secrets provided by the sender rather than only generating them as well as supporting asymmetric keys for signatures. It also means we’d need to store raw keys, not just the hashes, and we’d want to encrypt those and store our encryption keys in a service like GCP’s Secret Manager.
Split the implementation into separate apps: For this POC I built a single monolithic app. There’s nothing wrong with that—monoliths have rightfully regained popularity as companies recover from their microservice hangover. The main reason I’d split this one in production is that the three endpoint groups have very different security profiles. If the add-on endpoints (/studio/*) live in their own service, we can leverage Google Cloud’s built-in Cloud Run IAM / IAP security to verify the request came from Google at the infrastructure layer instead of manually verifying the system JWT in application code, whereas the OAuth (/auth/*) and webhook (/webhook/*) endpoints are more open..
Queuing: While I opted for a direct pass through on the webhook path, if this were to scale up more queueing would be the better path. We’d still want back pressure when the number of queued messages approaches unsustainable levels, but queueing lets us handle short bursts of requests gracefully.
Dynamic resources support for structured info: Passing a single rawPayload string requires users to add an extra step (like Gemini’s Extract step) to pull out structured fields, which isn’t ideal for usability. Workflow add-ons can dynamically define structured output resources at configuration time.
Going fully bespoke
I’m on the fence about adding user-defined dynamic schema support. I tried it before, and reality is it’s hard to do well. The UI constraints of cards and limited schema flexibility compared to arbitrary JSON payloads presents a lot of challenges. Very simple cases work OK, but the edge cases, like the inability to nest resources, come fast and the solutions aren’t great. Shoving a nested object into a JSON string means the user still has to use Gemini to extract values.
The better solution is that if you have a system where a lot of users are going to trigger workflows from, a bespoke custom trigger may be in order. This also gives you a lot more flexibility over how events are captured in the first place. Instead of web hooks, you might be using Cloud Pub/Sub. Or it’s a legacy system that doesn’t support events at all and requires polling. For complex payloads, you can pair the trigger with additional actions to look up related records or details that are used less often, or ones to make updates to the system of record.
How complex, and how custom depends largely on the audience. Since this was more scratching a personal itch, I wanted to keep it as simple as possible. But it’s a solid start that can easily be adapted for a variety of use cases.
The full code is available on GitHub at googleworkspace/devrel-demos/studio/incoming-webhook-starter for anyone who wants to take it for a spin or take it the last mile.