Show logged-in members' real names in AckReply: visitor identification and signing (PHP, Node and more)
Pass your logged-in members' names to the AckReply inbox, sign their user ID on your server with HMAC-SHA256 (PHP, Node.js and 11 more stacks), and move from tawk.to.
On this page
If your website has logged-in members, AckReply can show their real name and email in the inbox instead of “Visitor 1234”. Your page passes the member’s details to the widget. For full protection, your server also signs the member’s ID with a secret, so nobody can pose as another member, and the member sees the same chat history on every device.
Everything here is set up in Settings > Widget > Members’ names (https://app.ackreply.com/settings/widget), which has copy-ready snippets with your workspace ID filled in.
What do I get from identifying members?
- Real names for your team. The member’s name and email show in the inbox list, the conversation header and the visitor panel.
- One history on every device (verified only). A member who chats on their phone and later on a laptop sees the same conversations.
- No impersonation (verified only). Without a valid signature AckReply rejects the call, so nobody can open another member’s chats by sending their ID.
The AI agent does not read the member’s name. Names are for your team in the inbox.
Quick setup or verified: which one do I need?
There are two levels:
| Quick setup | Verified members | |
|---|---|---|
| Server code | None | Your server signs the member’s user_id |
| Identity secret | Not created | Created in Members’ names |
| Inbox shows | Name and email, marked Not verified | Name and email, marked Verified, plus the User ID |
| Chats on other devices | Not linked | Linked: the member sees earlier chats |
| Someone posing as another member | Possible (they can edit the details in their browser) | Rejected |
Start with the quick setup if you only want names in the inbox today. Turn on verification as soon as your team relies on those names. This is the standard approach: Intercom, Chatwoot, Crisp, tawk.to and Chatbase all ask your server to sign the logged-in user the same way.
Important: once a secret exists, every identify call must carry a user_id and a valid user_hash. Names or emails without a signed user_id, including the quick setup snippet, are rejected. Have your server code (steps 2 and 3 below) ready before you create the secret.
Quick setup (no secret)
On pages where a member is logged in, put this above your normal AckReply install tag. Your page fills in the values:
<script>
window.AckReplySettings = {
user: {
user_id: "MEMBER_ID", // your member's ID (optional here)
name: "MEMBER_NAME", // shown to your team in the inbox
email: "MEMBER_EMAIL" // optional
}
};
</script>
<script src="https://app.ackreply.com/widget/loader.js" data-workspace-id="YOUR_WORKSPACE_ID" async></script>
Pages for visitors who are not logged in keep just the install tag. Without a secret, AckReply saves the name and email on that browser’s visitor only. It does not link devices.
How do I set up verified members?
1. Create your identity secret
An Owner or Admin opens Settings > Widget > Members’ names, clicks Set up verification under Verify members, and in step 1, Create your identity secret, clicks Generate secret, then confirms with Create secret. Copy the secret into your server’s configuration, for example an environment variable named ACKREPLY_IDENTITY_SECRET.
Keep the secret on your server. Never put it in page HTML, JavaScript or a mobile app: anyone who has it can sign in as any member. Other team members cannot see the secret.
2. Sign the member’s ID on your server
The signature (user_hash) is the HMAC-SHA256 of the member’s user_id, keyed with your secret, written as lowercase hex (64 characters). Sign exactly the string you send as user_id. Only the ID is signed, not the name or email.
All the examples below give the same result. With the secret test_secret_123 and the ID 1001, the hash is:
5e254b9c347147942cc852ef15bbdd6c6256a8233ed7e9c073909d8b934133bb
Use that to test your code.
PHP
$userId = (string) $member->id; // must match user_id, as a string
$userHash = hash_hmac('sha256', $userId, getenv('ACKREPLY_IDENTITY_SECRET'));
Laravel
// config/services.php
'ackreply' => ['identity_secret' => env('ACKREPLY_IDENTITY_SECRET')],
// In a controller or view composer
$userId = (string) auth()->id();
$userHash = hash_hmac('sha256', $userId, config('services.ackreply.identity_secret'));
WordPress
// wp-config.php
define('ACKREPLY_IDENTITY_SECRET', 'your-secret');
// Your theme's functions.php or a small plugin
add_action('wp_head', function () {
$user = wp_get_current_user();
if (!$user->exists()) {
return; // not logged in: keep the normal install tag
}
$userId = (string) $user->ID;
$settings = [
'user' => ['user_id' => $userId, 'name' => $user->display_name, 'email' => $user->user_email],
'user_hash' => hash_hmac('sha256', $userId, ACKREPLY_IDENTITY_SECRET),
];
echo '<script>window.AckReplySettings = ' . wp_json_encode($settings) . ';</script>';
}, 1);
Node.js / Express
const crypto = require('crypto');
function ackreplyUserHash(userId) {
return crypto
.createHmac('sha256', process.env.ACKREPLY_IDENTITY_SECRET)
.update(String(userId)) // must match user_id, as a string
.digest('hex');
}
// For single-page apps: return the signed details to the logged-in member
app.get('/ackreply-identity', requireLogin, (req, res) => {
const userId = String(req.user.id);
res.json({
user: { user_id: userId, name: req.user.name, email: req.user.email },
user_hash: ackreplyUserHash(userId),
});
});
Next.js (App Router route)
// app/api/ackreply-identity/route.ts
import { createHmac } from 'node:crypto';
import { getCurrentUser } from '@/lib/auth'; // your own login helper
export async function GET() {
const member = await getCurrentUser();
if (!member) return Response.json({ error: 'Not logged in' }, { status: 401 });
const userId = String(member.id);
const userHash = createHmac('sha256', process.env.ACKREPLY_IDENTITY_SECRET!)
.update(userId)
.digest('hex');
return Response.json({
user: { user_id: userId, name: member.name, email: member.email },
user_hash: userHash,
});
}
Python
import hashlib
import hmac
import os
def ackreply_user_hash(user_id: str) -> str:
secret = os.environ["ACKREPLY_IDENTITY_SECRET"]
return hmac.new(secret.encode(), str(user_id).encode(), hashlib.sha256).hexdigest()
Django
# settings.py
ACKREPLY_IDENTITY_SECRET = os.environ["ACKREPLY_IDENTITY_SECRET"]
# views.py
import hashlib, hmac
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.http import JsonResponse
@login_required
def ackreply_identity(request):
user_id = str(request.user.pk)
user_hash = hmac.new(
settings.ACKREPLY_IDENTITY_SECRET.encode(), user_id.encode(), hashlib.sha256
).hexdigest()
return JsonResponse({
"user": {"user_id": user_id, "name": request.user.get_full_name(), "email": request.user.email},
"user_hash": user_hash,
})
Flask
import hashlib, hmac, os
from flask import jsonify
from flask_login import current_user, login_required
@app.get("/ackreply-identity")
@login_required
def ackreply_identity():
user_id = str(current_user.id)
user_hash = hmac.new(
os.environ["ACKREPLY_IDENTITY_SECRET"].encode(), user_id.encode(), hashlib.sha256
).hexdigest()
return jsonify(user={"user_id": user_id, "name": current_user.name, "email": current_user.email},
user_hash=user_hash)
Ruby on Rails
# app/helpers/ackreply_helper.rb
require "openssl"
module AckreplyHelper
def ackreply_user_hash(user)
OpenSSL::HMAC.hexdigest("SHA256", ENV.fetch("ACKREPLY_IDENTITY_SECRET"), user.id.to_s)
end
end
<%# app/views/layouts/application.html.erb, above the AckReply tag %>
<% if current_user %>
<script>
window.AckReplySettings = <%= raw({
user: { user_id: current_user.id.to_s, name: current_user.name, email: current_user.email },
user_hash: ackreply_user_hash(current_user)
}.to_json) %>;
</script>
<% end %>
Go
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"os"
)
func ackreplyUserHash(userID string) string {
mac := hmac.New(sha256.New, []byte(os.Getenv("ACKREPLY_IDENTITY_SECRET")))
mac.Write([]byte(userID))
return hex.EncodeToString(mac.Sum(nil))
}
Java
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.util.HexFormat; // Java 17+
static String ackreplyUserHash(String userId) throws Exception {
Mac mac = Mac.getInstance("HmacSHA256");
byte[] key = System.getenv("ACKREPLY_IDENTITY_SECRET").getBytes(StandardCharsets.UTF_8);
mac.init(new SecretKeySpec(key, "HmacSHA256"));
return HexFormat.of().formatHex(mac.doFinal(userId.getBytes(StandardCharsets.UTF_8)));
}
C# / .NET
using System.Security.Cryptography;
using System.Text;
static string AckreplyUserHash(string userId)
{
var key = Encoding.UTF8.GetBytes(Environment.GetEnvironmentVariable("ACKREPLY_IDENTITY_SECRET")!);
var hash = HMACSHA256.HashData(key, Encoding.UTF8.GetBytes(userId)); // .NET 6+
return Convert.ToHexString(hash).ToLowerInvariant(); // AckReply expects lowercase hex
}
Elixir
def ackreply_user_hash(user_id) do
secret = System.fetch_env!("ACKREPLY_IDENTITY_SECRET")
:crypto.mac(:hmac, :sha256, secret, to_string(user_id))
|> Base.encode16(case: :lower)
end
The examples that return JSON (Express, Next.js, Django, Flask) are for single-page apps: your page fetches them after login and passes the result to identify(). For pages your server renders, print the values into AckReplySettings as in step 3.
3. Add the member’s details to your pages
On pages where a member is logged in, put this above your normal AckReply install tag. Your server fills in the values:
<script>
window.AckReplySettings = {
user: {
user_id: "1001", // your member ID: required, as a string
name: "Andi Pratama", // shown to your team
email: "andi@example.com", // optional
custom: { level: "VIP" } // optional extra details
},
user_hash: "SIGNATURE_FROM_STEP_2"
};
</script>
<script src="https://app.ackreply.com/widget/loader.js" data-workspace-id="YOUR_WORKSPACE_ID" async></script>
In PHP, print the values with json_encode() so quotes and special characters in names are escaped:
<script>
window.AckReplySettings = {
user: <?= json_encode(['user_id' => $userId, 'name' => $member->name, 'email' => $member->email]) ?>,
user_hash: <?= json_encode($userHash) ?>
};
</script>
<script src="https://app.ackreply.com/widget/loader.js" data-workspace-id="YOUR_WORKSPACE_ID" async></script>
Single-page apps
If members log in without a page reload, call identify() with the signature from your server. You can call it before the chat window finishes loading; AckReply sends it as soon as the widget is ready.
const res = await fetch('/ackreply-identity'); // your endpoint from step 2
const { user, user_hash } = await res.json();
window.AckReply.identify(user, user_hash);
4. Log out
When a member logs out, call logout(). The widget starts a new anonymous session and hides the member’s conversations in that browser.
window.AckReply.logout();
How do I check that identification works?
- Log in as a test member, open the chat and send a message. The inbox shows the member’s name, marked Verified, with their User ID in the visitor panel.
- Settings > Widget > Members’ names counts identified and verified visitors for the last 7 days, and shows the last rejected call with its reason.
- Open the same page in a second browser, logged in as the same member. The earlier conversation is listed in the widget.
- In your browser’s developer tools (Network tab), the request to
/v1/widget/identifyreturns 200. The browser console logs why a call was rejected.
| Response | Code | What it means |
|---|---|---|
| 403 | user_id_required | A secret is set, and the page sent a name or email without a user_id and user_hash. |
| 403 | user_hash_required | A secret is set, and the page sent a user_id without user_hash. |
| 403 | invalid_user_hash | The hash didn’t match. Check that your server signs exactly the user_id string the page sends, with the current secret. |
| 422 | invalid_identify_data | A field is invalid or too long (see the limits below). |
| 429 | rate_limited | More than 10 identify calls per minute from one visitor. Call it once per page load, not in a loop. |
Good to know
- Only the ID is verified. The name and email are what your page sends. A member could change their own shown name in their browser, but cannot take over another member’s ID or history.
- Numbers are fine.
user_id: 1001is accepted and treated as the string"1001". Sign that same string. - Rotating the secret: click Rotate next to the secret in Members’ names. Hashes made with the old secret stop working right away, and members show as anonymous visitors until your server signs with the new secret.
- The
data-workspace-idinstall tag is enough.AckReplySettings.useranduser_hashare picked up by the normal install tag, as long asAckReplySettingsis set above it.
| Field | Limit |
|---|---|
user_id | 255 characters; required when a secret is set |
name | 100 characters |
email | A valid email address, 254 characters |
avatar_url | An http(s) link, 2,048 characters |
custom | An object of extra details, 32 KB |
Coming from tawk.to
AckReply works the same way with different names. The main difference: tawk.to’s Secure Mode signs the member’s email with your tawk.to API key; AckReply signs the member’s ID with your AckReply identity secret.
| tawk.to | AckReply |
|---|---|
Tawk_API.visitor = { name, email } | window.AckReplySettings = { user: { name, email } } (quick setup) |
Tawk_API.visitor = { name, email, hash } | window.AckReplySettings = { user: { user_id, name, email }, user_hash } |
Tawk_API.setAttributes({ name, email, hash }) | AckReply.identify({ user_id, name, email }, user_hash) |
| hash = HMAC-SHA256 of the email, keyed with the tawk.to API key | user_hash = HMAC-SHA256 of the user_id, keyed with the identity secret |
Other attributes in setAttributes | custom: { ... } inside user |
Tawk_API.onLoad | Not needed: set AckReplySettings before the tag, or call identify() any time |
Tawk_API.logout() | AckReply.logout() |
Tawk_API.maximize() / minimize() | AckReply.open() / AckReply.close() |
Coming from Chatwoot: setUser(identifier, { name, email, identifier_hash }) maps to identify({ user_id, name, email }, user_hash). Keep your server code and swap in AckReply’s secret. From Crisp: user:email and user:nickname become email and name; Crisp signs the email, AckReply signs the member’s ID.
Related articles
Was this article helpful?
Thanks for letting us know.
Sorry about that. Tell us what was missing and we’ll fix the article.