Author picture Fongang Rodrique

How to Receive and Replay External Webhooks in Google Cloud Functions with Hookdeck


Webhooks play a crucial role in modern application development as they enable real-time communication and data transfer between different systems. In building event-driven architectures in the Google Cloud environment, efficiently receiving and handling webhooks is crucial.

Hookdeck is a webhook management platform that helps developers reliably receive webhooks, manage events and troubleshoot any issues quickly. By integrating Hookdeck with Google Cloud Functions, you can enhance the reliability and management of your webhook events, ensuring smooth integration with external systems.

In this article, we will explore how to receive and replay external webhooks in Google Cloud Functions using Hookdeck.

Create a Google Cloud function

Before we dive into receiving webhooks, let's set up a Google Cloud function to handle incoming webhook events. Google Cloud Functions offer a serverless execution environment that allows you to build and connect cloud services through event-driven functions.

This example assumes you have a Google Cloud account and a project with billing enabled, and that you are familiar with creating Google Cloud Functions using the Google Cloud console.

To create a Google Cloud function:

  • Log in to your Google Cloud Console and create or select an existing project.
  • Click on the hamburger menu by the left then APIs and services > Enabled APIs and services.

Create Google Cloud Function

  • Select and enable the Cloud Functions API and Cloud Build APIs for your project.
  • Open the Cloud Functions page and Create function on the Google Cloud console, by navigating the Console menu.

Create function on Cloud console

  • Configure the properties of your function and then click Next.
    • Choose 2nd gen for the environment
    • Provide a name for your function, such as "webhook-handler"
    • In the Trigger field, select HTTP
    • In the Authentication field, select Allow unauthenticated invocations

Google Cloud Function authentication

  • Choose your desired language runtime from the Runtime dropdown (ex. Node.js 20).
  • In the Source code field, select Inline editor and replace the content of the editor with the following example code:
const functions = require("@google-cloud/functions-framework");

functions.http("webhookHandler", (req, res) => {
  if (req.method !== "POST") {
    res.status(405).send("Only POST requests allowed");

  // Process webhook payload
  const payload = req.body;

  // Log payload
  console.log("Webhook received:", payload);

  res.status(200).send("Webhook processed successfully");
  • Rename the entry point to match the function name and Deploy.

After deployment, the function icon will turn into a green check mark, indicating successful deployment. Note the URL provided, as it is needed below.

Deploy Cloud Function

Replay webhooks

Using Hookdeck as a bridge between your source platform's webhooks and Google Cloud Functions, you can replay any failed event that didn't reach your Cloud function properly.

Follow these steps to create a webhook connection with Hookdeck in order to replay an event.

Create a Hookdeck connection

  1. Sign up or log in to your Hookdeck dashboard.
  2. Click on Connections in the side panel, then click +Create Connection to add a new connection.
  3. Fill in the necessary information in the right sidebar:
    • Source: Specify the source platform or application you want to receive webhooks from.
    • Destination: Enter the URL of your Google Cloud function.
  4. Save the connection.

Save Cloud Function Hookdeck connection

Hookdeck will provide you with a URL that you can use on the source platform to send webhook events.

Receive webhook events

You can utilize the Hookdeck Console to simulate example webhooks from popular webhook sources.

Imagine your webhook source is GitHub. When an event is triggered, you can monitor it both on the Hookdeck dashboard and in your Google Cloud function logs.

From your Hookdeck dashboard, go to the Events tab in the side panel. Filter the events based on the connection you created earlier. This displays the activities of events on that connection.

Cloud Function Hookdeck Event

In your Google Cloud Console, navigate to the Cloud function you deployed. Check the logs to see the incoming events and their processing status.

Google Cloud Console logs

Replaying error or failed webhooks

Hookdeck offers the valuable feature of webhook replay. This comes in handy when a webhook event fails to execute correctly in your Google Cloud function.

To replay a failed webhook event:

  1. From the Hookdeck Event panel, locate the failed event. Click on the kebab menu (three vertical dots) across from it.
  2. Choose Retry from the menu. This will attempt to resend the event to your Google Cloud function, giving it another opportunity to process the event successfully.

Replay Google Cloud Function

Now you know how to receive and replay webhook events for your Google Cloud Functions using Hookdeck. Through utilizing Hookdeck's capabilities such as security, routing, and analytics, you can effectively manage and troubleshoot webhook events from various external platforms.

By integrating Hookdeck with Google Cloud Functions, you can build robust event-driven architectures that ensure seamless communication and data transfer between your cloud services. Explore Hookdeck's documentation for further insights into its features and functionalities.