,

Send WPForms Submission Notifications to Google Chat Using a Webhook

Send WPForms Submission Notifications to Google Chat Using a Webhook

Would you like to receive an automatic Google Chat notification whenever someone submits a form on your WordPress website?

Using WPForms, a Google Chat webhook and a small PHP snippet, you can send notifications directly to a Google Chat space without installing additional integration plugins or using third-party automation services.

This example sends a simple notification containing the WPForms entry ID and submission date and time. It works with any WPForms form that supports entry storage.

How the Integration Works

  • A visitor completes and submits a WPForms form.
  • WPForms validates and processes the submission.
  • A WordPress action hook runs after successful processing.
  • A PHP function sends a message to a Google Chat webhook.
  • The message appears in the designated Google Chat space.

The notification is separate from the normal WPForms processing. If Google Chat is unavailable, the form submission should still complete normally.

Requirements

  • A WordPress website running WPForms.
  • WPForms entry storage enabled, such as with WPForms Pro, if you want a usable entry ID.
  • A Google Workspace account with Google Chat webhook permissions.
  • A Google Chat space where notifications will appear.
  • A way of adding PHP code, such as the Code Snippets plugin.

Google Chat incoming webhooks require an eligible Google Workspace account. Personal Gmail accounts cannot normally create webhooks directly. However, personal Gmail users can participate in a Workspace-created space when external collaboration is permitted.

Step 1. Create a Google Chat Space

  1. Sign into Google Chat using your Google Workspace account.
  2. Create a new space, or open an existing one.
  3. Give the space a suitable name, such as Form Notifications.
  4. Add any other users who need to receive notifications.

If you want people using personal Gmail accounts to participate, ensure that external access is permitted when creating the space and by your Workspace administrator.

Step 2. Create the Incoming Webhook

  1. Open your Google Chat space.
  2. Click the space name at the top.
  3. Select Apps & integrations.
  4. Click Add webhooks.
  5. Enter a name such as WPForms Notifications.
  6. Optionally supply a publicly accessible avatar image URL.
  7. Click Save.
  8. Use the three-dot menu beside the webhook to select Copy link.

Keep this webhook URL private. It contains a secret token that allows messages to be posted to your Google Chat space.

If webhook management is restricted, your Google Workspace administrator may need to enable incoming webhooks.

Step 3. Find Your WPForms Form ID

In the WordPress dashboard, open WPForms and select All Forms. Each form has a unique numerical ID, which is also visible in its shortcode.

For example, a shortcode containing an ID of 123 identifies form 123. We will use that number to restrict notifications to one particular form.

Step 4. Add the PHP Snippet

Create a new PHP snippet using Code Snippets or a similar method. The following code sends a notification after a successful submission.

/**
* Send a Google Chat notification when a WPForms
* submission is successfully completed.
*
* Sends the entry ID and submission date/time.
*/
function wpforms_google_chat_notification( $fields, $entry, $form_data, $entry_id ) {
// Configuration.
$form_id = 123;
$webhook = 'PASTE_YOUR_WEBHOOK_URL_HERE';
// Only process the selected form.
if ( absint( $form_data['id'] ) !== $form_id ) {
return;
}
try {
// Check the webhook URL.
if ( ! wp_http_validate_url( $webhook ) ) {
error_log( 'Google Chat: Invalid webhook URL.' );
return;
}
// Create the notification.
$message = "New WPForms submission received\n";
$message .= "Entry ID: #" . absint( $entry_id ) . "\n";
$message .= "Date: " . current_datetime()->format( 'd/m/Y H:i:s' );
// Send without waiting for a response.
$response = wp_remote_post( $webhook, array(
'headers' => array(
'Content-Type' => 'application/json',
),
'body' => wp_json_encode( array(
'text' => $message,
) ),
'timeout' => 2,
'blocking' => false,
) );
// Log immediate connection errors.
if ( is_wp_error( $response ) ) {
error_log(
'Google Chat: ' . $response->get_error_message()
);
}
} catch ( Throwable $e ) {
// Prevent notification exceptions
// from interrupting form processing.
error_log(
'Google Chat exception: ' . $e->getMessage()
);
}
}
// Run after successful WPForms submissions.
add_action(
'wpforms_process_complete',
'wpforms_google_chat_notification',
10,
4
);

The code does not require an opening PHP tag when entered into a PHP snippet in Code Snippets.

Step 5. Configure the Snippet

There are just two settings to change:

  • Form ID: Replace 123 with the numerical ID of your WPForms form.
  • Webhook URL: Replace PASTE_YOUR_WEBHOOK_URL_HERE with the URL copied from Google Chat.

Save and activate the snippet. Configure it to run everywhere so that it can respond to public form submissions.

Step 6. Test the Integration

  1. Open the page containing your WPForms form.
  2. Complete the required fields.
  3. Click the Submit button.
  4. Check that the form submission completes successfully.
  5. Open the Google Chat space and look for the notification.

A typical Google Chat message will look like this:

New WPForms submission received
Entry ID: #12345
Date: 03/11/2026 09:30:15

The timestamp uses the timezone configured in WordPress under Settings > General. If the timezone is set to London, WordPress will automatically account for GMT and British Summer Time.

Error Handling and Website Reliability

An external notification service should never be essential to the successful processing of a website form. The PHP snippet includes several safeguards to minimise the impact of webhook failures.

  • Runs after successful processing: The WPForms completion hook runs after form validation, entry saving and notification processing.
  • Checks the form ID: Only the selected WPForms form triggers the integration.
  • Validates the URL: Avoids attempting to send messages to an invalid webhook address.
  • Non-blocking HTTP request: WordPress does not wait for Google Chat to return its response.
  • Short timeout: Limits how long the request can spend attempting to connect.
  • Exception handling: Catches unexpected PHP exceptions or errors raised within the notification function.
  • Error logging: Records immediate failures without displaying technical error messages to the visitor.

These safeguards reduce the risk of disrupting form processing, although no PHP integration can guarantee that an external request will never cause a delay or failure.

Because the request is non-blocking, WordPress cannot confirm that Google Chat received the message. This is suitable for supplementary notifications where WPForms remains the primary record of submissions.

Important Considerations

Entry IDs and WPForms Lite

WPForms may return an entry ID of zero if entry storage is unavailable or disabled, including with WPForms Lite. A stored entry ID requires a configuration that supports saving entries.

Protecting Your Webhook URL

Never publish your actual Google Chat webhook URL in a public tutorial, shared source repository or website page. For a more permanent deployment, consider storing the URL in a configuration constant outside the snippet.

External Google Chat Members

Members using personal Gmail accounts may be able to view notifications in a shared Workspace-created space, provided external collaboration is enabled. In some cases, these users may see the sender as Unknown user rather than the webhook’s configured name. The message content should still be visible.

Useful Documentation

Summary

Connecting WPForms to Google Chat is a straightforward way to receive submission notifications without introducing another automation platform.

Once the webhook is configured, the integration requires only a small PHP function. Each successful submission can generate a message containing the entry ID and submission timestamp, giving everyone in the shared Google Chat space a convenient way to monitor incoming form activity.

Comments

Leave a Reply