SDK
GCP Functions Adapter
Configure Better Webhook with Google Cloud Functions (Gen 1 and Gen 2).
GCP Functions Adapter
Install
npm install @better-webhook/gcp-functionsBasic usage (Gen 2)
import { http } from "@google-cloud/functions-framework";
import { ragie } from "@better-webhook/ragie";
import { document_status_updated } from "@better-webhook/ragie/events";
import { toGCPFunction } from "@better-webhook/gcp-functions";
const webhook = ragie().event(document_status_updated, async (payload) => {
console.log(`Document ${payload.document_id} is now ${payload.status}`);
});
http("webhookHandler", toGCPFunction(webhook));Basic usage (Gen 1)
import { ragie } from "@better-webhook/ragie";
import { document_status_updated } from "@better-webhook/ragie/events";
import { toGCPFunction } from "@better-webhook/gcp-functions";
const webhook = ragie().event(document_status_updated, async (payload) => {
console.log(`Document ${payload.document_id} is now ${payload.status}`);
});
export const webhookHandler = toGCPFunction(webhook);Raw body behavior
Functions Framework usually provides req.rawBody automatically. The adapter checks, in order:
req.rawBody- Buffer body
- String body
JSON.stringify(req.body)fallback
If your setup does not preserve raw body, signature verification can fail.
Deployment example
gcloud functions deploy webhookHandler \
--gen2 \
--runtime nodejs20 \
--trigger-http \
--allow-unauthenticated \
--entry-point webhookHandler \
--set-env-vars RAGIE_WEBHOOK_SECRET=your-secretCanonical reference: Adapters