Login Visitor
​
Using the following method, you can load the conversation history of authenticated visitors (visitors who have logged in to your system). To do this, first get the user ID using the getVisitorId function and then save it in your database.
And then on your login page using JWT (HS256) encryption method and with the authentication key that you can copy from this page, encrypt the user ID as below
User authentication key is a private key, please do not share it with third parties and be sure to implement the following process on the back-end of your service
node.js
php
1
const jwt = require('jsonwebtoken');
2
const contact_hash = jwt.sign({contactId: visitorId}, identityVerificationKey);
Copied!
1
$contact_hash = JWT::encode($contactId, $identityVerificationKey);
Copied!
Then send the encrypted value (contact_hash) to your client and load the desired visitor using the following code before loading the imber widget.
HTML
1
<script>
2
window.IMBER_AUTH = {
3
contact_id: visitorId,
4
contact_hash: contact_hash
5
};
6
</script>
Copied!
Note that for ease in the process of loading the visitor history of the conversation after encryption and generation of the hash, Set into client-side storage like localStorage or cookies and use it with every refresh.
Last modified 5mo ago
Copy link