Identify signed-in visitors

Tell the chat who is signed in on your site so the agent greets them by name and the Inbox shows whose conversation it is, with optional verification.

Your website knows who is signed in; the chat doesn't until you tell it. Once you do, the agent greets people by name, stops asking for details it has, and each conversation shows who it belongs to.

There are two parts:

  1. Identify: your page passes the person's details to the chat.
  2. Verify (recommended): your server adds a signature made with a secret key, so nobody can pretend to be someone else. Verified conversations show a Verified identity badge.

The widget must already be installed.

Identify the visitor

On pages where someone is signed in:

<script>
  window.FetchplyWidget = window.FetchplyWidget || { q: [] };
  window.FetchplyWidget.q.push(['identify', {
    userId: '42',
    name: 'Jane Doe',
    email: '[email protected]',
    userHash: 'SIGNATURE_FROM_YOUR_SERVER', // optional
    issuedAt: 1764000000                    // the second the signature was made
  }]);
</script>

On pages where nobody is signed in, and in your sign-out handler:

<script>
  window.FetchplyWidget = window.FetchplyWidget || { q: [] };
  window.FetchplyWidget.q.push(['logout']);
</script>

logout forgets the person, clears chats saved in that browser, and starts fresh, so the next person on a shared computer can't read the last conversation. If a different person signs in, the chat starts a new conversation by itself.

Shopify themes: paste this before </body> in layout/theme.liquid. A theme can't sign, so use Accept without proof.

<script>
  window.FetchplyWidget = window.FetchplyWidget || { q: [] };
  {% if customer %}
    window.FetchplyWidget.q.push(['identify', {
      userId: {{ customer.id | json }},
      name: {{ customer.name | json }},
      email: {{ customer.email | json }}
    }]);
  {% else %}
    window.FetchplyWidget.q.push(['logout']);
  {% endif %}
</script>

Fields

FieldRequiredNotes
userIdYesYour stable ID for the person. Without it, everything else is ignored
nameNoUp to 200 characters
emailNoAlso matches the person to existing contacts
phoneNoUp to 60 characters
avatarUrlNoMust start with https://
attributesNoUp to 20 extras such as { plan: 'pro' }. Keys: lower-case letters, numbers, and underscores, starting with a letter
userHashRecommendedThe signature from your server
issuedAtWith userHashThe Unix time in seconds the signature was made

Verify with a signature

  1. Open Widget customizer → Install → Signed-in visitors and select Generate secret. Keep the key on your server only.
  2. On your server, sign three lines with HMAC-SHA256 and send the result as lowercase hex:
<userId>\n<email, trimmed and lower-cased, or empty>\n<issuedAt in seconds>
// Node.js
const { createHmac } = require('node:crypto');
const issuedAt = Math.floor(Date.now() / 1000);
const userHash = createHmac('sha256', process.env.FETCHPLY_IDENTITY_SECRET)
  .update(`${user.id}\n${(user.email ?? '').trim().toLowerCase()}\n${issuedAt}`)
  .digest('hex');
// PHP
$issuedAt = time();
$payload = $user->id . "\n" . strtolower(trim($user->email)) . "\n" . $issuedAt;
$userHash = hash_hmac('sha256', $payload, getenv('FETCHPLY_IDENTITY_SECRET'));

A signature works for 24 hours after issuedAt, so make it each time the page is served. Rotate secret makes a new key and keeps the old one working for 24 hours.

How strictly to check

Under When a visitor arrives:

  • Accept without proof (default): details are used either way; only signed ones are verified.
  • Require proof: visitors without a valid signature stay anonymous.
  • Off: sign-in details are ignored.

A signature that doesn't match is always refused.

Troubleshooting

The agent still asks for their name. Check the snippet runs on the page and includes userId. Details attach when the visitor sends a message.

It says Unverified identity. No signature was sent, or it didn't match. Sign exactly the three lines above with this agent's key, and send the same issuedAt you signed.

It broke after rotating the key. The old key stops working 24 hours after rotation. Put the new key on your server.

A cached page showed the wrong person. Never put a signed-in person's details on a cached page. Exclude signed-in visitors from your page cache.