# How to Integrate Help.Center Chat Widget with WHMCS

This guide shows you how to seamlessly integrate the Help.Center
[https://help.center] live chat widget into your WHMCS site and personalize the
experience for your logged-in clients.


WHAT THIS INTEGRATION DOES

 * Embeds the Help.Center chat widget on all WHMCS client pages.

 * Automatically fills in client name, email, and ID when logged in.

 * Keeps data private by not exposing anything to logged-out visitors.


STEP-BY-STEP INSTALLATION

1. Access Your WHMCS Files

Log in to your hosting environment and navigate to the following folder in your
WHMCS installation:

/includes/hooks/

2. Create a New File

Create a file named:

helpcenter_userdata.php

3. Add the Following Code

Paste this code into the file:

<?php
add_hook('ClientAreaFooterOutput', 1, function($vars) {
    // Always load the Help.Center widget
    $script = '<script id="hc-widget" src="https://chat.help.center/launcher.js" data-domain="your-domain" async></script>';

    // Add client info if user is logged in
    if ($vars['loggedin']) {
        $clientEmail = addslashes($vars['clientsdetails']['email']);
        $clientName = addslashes($vars['clientsdetails']['fullname']);
        $clientId = addslashes($vars['clientsdetails']['id']);

        $script .= <<<HTML
<script>
window.helpcenter = window.helpcenter || {};
window.helpcenter.ready = function() {
  window.helpcenter.setUserData({
    email: "{$clientEmail}",
    name: "{$clientName}",
    userId: "{$clientId}"
  });
};
</script>
HTML;
    }

    return $script;
});

Please remember to replace your-domain with the actual subdomain of your
help.center, e.g., if your domain is hosting.help.center your data-domain value
will be "hosting".


RESULT

 * When a client logs in, the chat widget appears and is pre-filled with their
   details.

 * When no one is logged in, the widget still appears, but without any user
   data.

 * This makes it easy for your team to assist users more efficiently.


SECURITY & PRIVACY

 * Client data is only used on the frontend and never exposed to unauthorized
   users.

 * The script loads asynchronously so that it won’t slow down your page.


NEED HELP?

If you run into any issues, feel free to reach out to the Help.Center support
team.