User identification & verification
You can tell the Evercom widget who the current user is by passing a user object. This lets a returning user continue the same conversation.
The id field must be your internal user ID. Do not use a random value if you want the same user to return to the same conversation.
<script>
window.EvercomWidget = {
user: {
id: 'user-123',
email: 'user@example.com',
name: 'John Doe'
}
}
</script>
<script src="https://widget.evercom.app/a3f2b1c9.js" async></script>
User verification
If user verification is enabled for your account, pass a user_token alongside the user object. The token is an HMAC-SHA256 of user.id generated with the secret key from your widget settings.
Generate the token only on your server. Never send the secret key to the browser. The user.id used to generate the HMAC must match the user.id passed to the widget.
Node.js:
const crypto = require('crypto')
const token = crypto
.createHmac('sha256', SECRET)
.update(userId)
.digest('hex')
Python:
import hmac
import hashlib
token = hmac.new(
SECRET.encode(),
user_id.encode(),
hashlib.sha256
).hexdigest()
PHP:
$token = hash_hmac('sha256', $userId, $SECRET);
Pass the generated token to the widget:
<script>
window.EvercomWidget = {
user_token: 'TOKEN_FROM_YOUR_SERVER',
user: {
id: 'user-123',
email: 'user@example.com',
name: 'John Doe'
}
}
</script>
<script src="https://widget.evercom.app/a3f2b1c9.js" async></script>