Ha Tang Chat plugin for WordPress
The Ha Tang Chat plugin adds the Ha Tang chat widget to every page of your WordPress site, so your team answers website visitors from the same inbox as Zalo, Messenger, Instagram, TikTok, WhatsApp, Telegram and email. It loads the regular web widget through wp_enqueue_script and adds settings for position, language and logged-in users.
Plugin 0.2.1 · WordPress 6.0+ · PHP 7.4+ · GPLv2 or later · wordpress.org · Changelog
Before you start
- A Ha Tang account with a website channel. You need its Site ID (
site_...): in the dashboard, open Support → Channels, pick your website and copy the id from the install snippet. - A WordPress user who can manage plugins and settings (an administrator).
Install the plugin
- In WordPress, go to Plugins → Add New, search for "Ha Tang Chat", then install and activate it. You can also upload the plugin zip with Plugins → Add New → Upload Plugin.
- Go to Settings → Ha Tang Chat, paste the Site ID and click Save Changes.
- Open any page of your site. The chat bubble appears, and the website in the Ha Tang dashboard shows that the widget is installed.
The widget only loads on the public side of the site, never in wp-admin. If the Site ID is empty, the plugin loads nothing.
Settings
All settings are on Settings → Ha Tang Chat and are stored in one option, hatang_chat.
| Setting | Values | Default |
|---|---|---|
| Site ID | The website's id from the Ha Tang dashboard | empty (widget off) |
| Widget host | Where widget.js is loaded from | https://chat.hatang.dev |
| Position | Bottom right, Bottom left | Bottom right |
| Language | Follow the WordPress language (per page), Visitor's browser language, Tiếng Việt, English | Follow the WordPress language (sites installed before 0.2.0 keep the browser language) |
| Logged-in users | "Send the user's name and email to the inbox" | On |
- Follow the WordPress language reads the language of the page being served (
determine_locale()), so it works page by page with Polylang and WPML. A locale starting withvigives Vietnamese; any other gives English. - Visitor's browser language lets the widget decide: the visitor's browser, or the default language set for the site in the Ha Tang dashboard.
- Everything else (colors, office hours, greeting, offline form) comes from the website's settings in the Ha Tang dashboard. For options the plugin does not expose, such as
offsetorhideLauncher, add your ownwindow.HATANG_CONFIGbefore the widget script, or use the JavaScript API from your theme.
Logged-in users
With Logged-in users on, the plugin calls identify for a logged-in visitor with their WordPress display name and email. The inbox shows them as information the visitor gave, not as a verified identity.
To have the inbox mark the user as verified and merge the conversation with that person's earlier sessions (including your mobile app), return a signature from the hatang_chat_identity_hash filter. The signature is the HMAC-SHA256 of the WordPress user id with the site's identity secret. Get the secret in the Ha Tang dashboard: Support → Channels → your website → Identity secret → Rotate & reveal. Keep it in wp-config.php, never in a theme file others can read.
define( 'HATANG_IDENTITY_SECRET', 'your-identity-secret' );
add_filter( 'hatang_chat_identity_hash', function ( $hash, $user ) {
return hash_hmac( 'sha256', (string) $user->ID, HATANG_IDENTITY_SECRET );
}, 10, 2 );
When the filter returns a value, the plugin adds userId (the WordPress user id as a string) and hash to the identify call. What a signature means, how sessions merge and the privacy notes are in Identity verification.
Filters for developers
| Filter | Arguments | Return |
|---|---|---|
hatang_chat_locale | $locale ("vi", "en" or null), $setting ("wp", "", "vi" or "en") | "vi", "en", or null to let the widget decide |
hatang_chat_identity_hash | $hash (null), $user (WP_User) | The HMAC-SHA256 hex string, or null for an unverified identity |
Force English on one page, whatever the setting:
add_filter( 'hatang_chat_locale', function ( $locale, $setting ) {
return is_page( 'en' ) ? 'en' : $locale;
}, 10, 2 );
What the plugin sends to Ha Tang
The widget script loads from chat.hatang.dev on the public pages of your site. When a visitor opens a page, it sends the page URL and title, the visitor's browser language and, if you turned it on, the name and email of a logged-in user. See the Terms and the Privacy policy.
Admin translation
The settings page is translated into Vietnamese (languages/hatang-chat-vi.po). WordPress picks the translation from the admin language.
Uninstall
Deactivate and delete the plugin from Plugins. The plugin has no uninstall routine, so its settings stay in the hatang_chat option; remove it with wp option delete hatang_chat if you want a clean database. Conversations stay in your Ha Tang account until you delete them there.
Changelog
- 0.2.3: the author link points to hatang.dev; the readme links the setup guide and this developer guide and answers which conversations share the inbox.
- 0.2.2: the plugin is called Ha Tang Chat (Hạ Tầng in Vietnamese); its homepage is the help article at hatang.dev/help/integrations/wordpress; the settings page and readme name Customer Support → Channels.
- 0.2.1: the settings page and readme point to Support → Channels, where the Ha Tang dashboard now lists your websites; the readme lists every channel that shares the inbox.
- 0.2.0: the language can follow the WordPress language of each page (works with Polylang and WPML); new
hatang_chat_localefilter; settings page translated into Vietnamese. - 0.1.1: the widget loads through
wp_enqueue_script. - 0.1.0: first release: widget snippet, position and language settings, logged-in user identification.
Next steps
- Web widget and JS API: commands, events and
HATANG_CONFIG. - Identity verification: signed identities and session merging.
- Install the widget: other platforms, or WordPress without the plugin.