Solving a Webhook Integration Challenge for Dental Practices

{{brizy_dc_image_alt entityId=

Solving a Webhook Integration Challenge for Dental Practices

At Freshspace, we often say that the smallest technical details can make the biggest difference. A recent project with a dental practice using DenGro, a CRM designed for patient enquiries, highlighted exactly that. What looked like a simple mismatch between a form field and DenGro’s expected data format became an opportunity to build a robust, maintainable integration that will serve the practice for years to come.

The Problem: Labels vs Slugs

The practice’s WordPress website we built used WPForms to capture patient enquiries. One of the key fields asked patients to select a treatment, with options like Check ups, Whitening, or Orthodontics.

WPForms’ webhook addon sent the label chosen by the patient (e.g. Check ups). But DenGro expected the slug version (e.g. check-ups). This mismatch meant enquiries weren’t being mapped correctly inside DenGro.

Why WPForms Alone Wasn’t Enough

WPForms’ webhook addon is great for simple integrations, but it doesn’t allow you to transform field values before sending them. That meant we needed a custom solution: intercept the form submission, rewrite the values and send the payload ourselves.

Our Solution: Custom PHP Webhook

We disabled the WPForms webhook addon and rebuilt the integration in PHP using WordPress’ wp_remote_post(). This gave us full control over the payload, headers and field mapping.

Step 1: Map Labels to Slugs


$slug_map = [
'Check ups'             => 'check-ups',
'Emergency appointments'=> 'emergency-appointments',
'Orthodontics'          => 'orthodontics',
'Whitening'             => 'whitening',
'White fillings'        => 'white-fillings',
'Cosmetic Dentistry'    => 'cosmetic-dentistry',
'Smile Makeover'        => 'smile-makeover',
'Implants'              => 'implants',
'Dentures'              => 'dentures',
'Crowns'                => 'crowns',
'Hygienist Services'    => 'hygienist-services',
];

Step 2: Correctly Map Field IDs

Every WPForms field has a unique ID. We audited the form and matched each ID to DenGro’s expected keys:


$payload = [
'FirstName' => $fields[21]['value'] ?? '',
'LastName' => $fields[19]['value'] ?? '',
'EmailAddress' => $fields[1]['value'] ?? '',
'PhoneNumber' => $fields[3]['value'] ?? '',
'AreYou' => $fields[4]['value'] ?? '',
'HowCanWeHelp' => $fields[5]['value'] ?? '',
'DentalTreatment' => $slug_map[ $fields[22]['value'] ] ?? sanitize_title( $fields[22]['value'] ),
'WhichDay' => $fields[8]['value'] ?? '',
'WhatTime' => $fields[9]['value'] ?? '',
'YourMessage' => $fields[2]['value'] ?? '',
'GDPR' => $fields[17]['value'] ?? '',
'MarketingConsent' => $fields[18]['value'] ?? '',
];

Step 3: Send the Payload to DenGro


$response = wp_remote_post(
'https://hooks.dengro.com/capture/44eb60e5-3c57-49e0-8d43-032d12d11277',
[
'body' => $payload,
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
'Secret' => 'bca4099e-9113-44e6-95ca-2ab2dca42351',
],
'method' => 'POST',
]
);

Adding Reliability: Logging and Fallbacks

We don’t just stop at “it works.” Reliability matters. To ensure no enquiry is ever lost:

  • Debug Logging: We log the payload locally for quick troubleshooting.

error_log( print_r( $payload, true ) );
  • Email Fallback: If DenGro’s endpoint fails, we send the payload to the practice by email.

if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ) {
wp_mail(
'practice@example.com',
'DenGro Webhook Failed',
'Payload: ' . print_r( $payload, true )
);
}

The Outcome

With this integration:

  • DenGro now receives treatment names in the correct slug format.
  • All fields align perfectly with their system.
  • The practice has peace of mind knowing enquiries won’t be lost, even if the webhook fails.

Why This Matters

This project highlights Freshspace’s approach:

  • Technical precision: auditing IDs, mapping slugs and matching formats.
  • Maintainability: using clear arrays and reusable code.
  • Reliability: adding logging and fallbacks for client confidence.

Sometimes the difference between a working integration and a broken one is just a hyphen. By digging into the details, we turned a frustrating mismatch into a robust, future‑proof solution.