What it does
Normally a visitor types their name and email address before the chat with your team starts. That address isn't verified: anyone can type any address. So in Bugalou such a visitor always gets their own contact, and for a known address you see Possibly the same customer as… with a Link to button.
When the visitor is logged in to your website or store, your site can confirm that. Then:
- the visitor doesn't have to type their name and email (the form shows Signed in as …, and with no other questions the chat starts straight away);
- the conversation goes straight to the existing contact, with earlier conversations and orders next to it;
- nobody can pose as that customer: Bugalou only trusts what your store or your own server confirms.
Shopify and WooCommerce: automatic
- Shopify: with the Bugalou app in your store, a logged-in customer is recognised automatically. Nothing to set up.
- WooCommerce: with the Bugalou for WooCommerce plugin (version 1.8 or newer), the chat switched on in the plugin and your store connected to Bugalou. Bugalou checks the customer with your store through that connection.
Your own website with a login
Does your site have its own login (for example a custom-built store or a customer portal)? Then your server passes the logged-in user to the chat, with a hash: a signature only your server can make.
Step 1: turn on verification
- Go to Channels → Website chat → Installation.
- Under Recognise logged-in visitors, click Turn on verification. Only owners and admins can do this.
- Copy the secret key (starts with
bgl_) and put it in your server's settings, for example as the environment variableBUGALOU_SECRET.
The key belongs on your server only. Never put it in the page, in JavaScript or in a public repository.
Step 2: make the hash on your server
The hash is the HMAC-SHA256 of the user's email address, with the secret key. One line of code:
PHP
$hash = hash_hmac('sha256', $user->email, BUGALOU_SECRET);
Node.js
const crypto = require('crypto');
const hash = crypto.createHmac('sha256', process.env.BUGALOU_SECRET)
.update(user.email).digest('hex');
Python
import hmac, hashlib, os
hash = hmac.new(os.environ['BUGALOU_SECRET'].encode(),
user.email.encode(), hashlib.sha256).hexdigest()
Step 3: put the user on the page
Put this on every page where a user is logged in, before the chat's installation code (PHP example):
<script>
window.BugalouWidget = window.BugalouWidget || {};
window.BugalouWidget.user = {
email: <?php echo json_encode($user->email); ?>,
name: <?php echo json_encode($user->name); ?>,
hash: <?php echo json_encode(hash_hmac('sha256', $user->email, BUGALOU_SECRET)); ?>
};
</script>
When nobody is logged in, just leave this block out: the chat then works as always. The name is optional.
Chat only for logged-in visitors
Want to offer the chat to your own customers only, for example in a customer portal? Under Recognise logged-in visitors, switch on Chat only for logged-in visitors.
- Visitors who aren't logged in don't see the chat button.
- Bugalou also refuses new chats, tickets and AI questions without valid proof, so the chat can't be used through a back door.
- The switch works with your own site's verification and with a connected Shopify or WooCommerce store. Without one of those you can't switch it on, so you can't hide the chat from everyone by accident.
Good to know
- Key leaked? Click New key. The old one stops working right away; put the new one on your server immediately.
- Bugalou accepts the hash of the email address as you store it, and of its lower-case version.
- The proof is valid for 30 minutes and the chat refreshes it by itself.
- The contact gets the confirmed email address. If a contact with that address already exists, the conversation goes there.
- If you turn verification off, logged-in visitors of your own site are no longer recognised. Without a connected store, Chat only for logged-in visitors goes off too.
Not working?
- The visitor still has to type name and email: the hash doesn't match. Check that you use the current key and hash exactly the email address that's in
email. - Nothing happens: is
window.BugalouWidget.userbefore the installation code, and areemailandhashboth filled in? - Nobody sees the chat any more: is Chat only for logged-in visitors on while your site doesn't pass the user yet? Switch it off until step 3 is done.