LogoLogo
WebsiteGuide & TutorialBlogBook a Demo
1.0.0
1.0.0
  • Acquire Developers Hub
  • Acquire
    • Acquire Build Requirement
      • Requirement For Acquire
      • Acquire Speedtest
  • JS API
    • JS Live Chat API
      • Description
      • Installation
      • Visitor
      • Thread
      • Conversation
      • User Verification
    • Quick Link Support
      • One Click Button
      • Social Media Share
    • Backend JS SDK
      • Setup Backend JS SDK
      • Demo Backend SDK
    • Advanced
      • Widget UI
      • Reference
  • Co Browse APIs
    • Acquire Co Browse
      • Co Browse API
  • Acquire API Events
    • WebRTC Related Events
  • iOS
    • SDK Setup Guide
      • Getting Started
      • Integration Guide (Core)
      • Integration Guide (Lite)
      • Manual Setup iOS
      • Acquire Account ID
    • SDK Configuration Example
    • iOS Cobrowse
    • Theme Setting
    • iOS Push Notifications
    • Verify your users
  • Android
    • Getting Started
      • Integration Guide (Core)
      • Integration Guide (Lite)
      • Start using Acquire
    • Acquire APIs
    • Acquire Delegates
    • Custom UI/widget
    • Cross Platform Integrations
  • Webhook API
    • Webhooks Basic
      • Introduction
      • Webhook Integrate Steps
      • Webhook Format
    • Webhook Events
      • On Chat Start
      • On Chat Accept
      • On Chat Message
      • On Chat Close
  • REST APIs
    • OAuth
      • Authorization
      • Tracklog
    • Profiles API
      • Profile List
      • Thread
      • Feedback
      • Profile Details
      • Message
      • Tags
      • Profile Agents
      • Campaigns
      • Profile Add Update
      • Profile Delete
      • Profile Visit History
      • Sender Emails
    • Chat
      • Chat Notes
    • Analytics
      • Chat Statistics
      • Team Analytics
      • Conversion Rate
      • Chat Tag
      • Co browsing
    • Agent
      • Agents List
      • Agent add
      • Edit / Get-agent
      • Update
    • Trigger
      • Triggers List
      • Triggers Detail
    • Operating Hours
      • Save Operating Hours
      • Get Operating Hours
    • Cobrowse
  • Chatbot API
    • Chat Bot
      • Integrate Your Chatbot
      • Dialog Flow V1 Chat-Bot
      • Dialog Flow V2 Chat-Bot
      • Dialog Flow Fulfillment & Custom Response
      • IBM Watson Integration
      • Amazon Lex Bot
      • Azure's QnA Maker
      • Webhook Calling & User Verification
      • Webhook For Reset Password
  • Knowledge Base APIs
    • Help Docs Setup
      • Get FAQ Categories
      • Get Setup Details
      • Get Side List
      • Get Article
      • Get Recent Article
      • Get Categorized Articles
      • Get Suggestion
  • Errors
    • API Error Handling
      • HTTP Responses
Powered by GitBook
On this page
  • Visitor Authentication
  • Logout visitor
  1. JS API
  2. JS Live Chat API

User Verification

PreviousConversationNextQuick Link Support

Last updated 6 years ago

Make sure your users are who they claim to be with identity verification. Enforce identity verification to prevent other from pretend to be (third party) for entertainment or fraud logged-in users.

Generate an HMAC with SHA256 whenever a user logs into your app. Most web frameworks will have a method or library to help you do this. You'll need your app’s secret key and the email of the currently logged-in user.

Secret Key

[YOUR_SECRET_KEY]

Then, choose the server-side language or framework you are using:

Your code to generate an HMAC for your app is:

hash_hmac(
  'sha256', // hash function
  $user->email, // user's id
  '' // secret key (keep safe!)
);

Your code to generate an HMAC for your app is:

OpenSSL::HMAC.hexdigest(
  'sha256', # hash function
  '', # secret key (keep safe!)
  current_user.email # user's email
)

Your code to generate an HMAC for your app is:

import hmac
import hashlib

hmac.new(
  '', # secret key (keep safe!)
  request.user.email, # user's email
  digestmod=hashlib.sha256 # hash function
).hexdigest()

For example, in Ruby on Rails we can generate our HMAC using a method called OpenSSL::HMAC.hexdigest(), where the first parameter is the name of a hash function (we use SHA256), the second is your secret key, and the third is your user’s user_email.

OpenSSL::HMAC.hexdigest(
  'sha256', # hash function
  '', # secret key (keep safe!)
  current_user.email # user's email
)

Note: Keep your secret key safe! Never commit it directly to your repository, client-side code, or anywhere a third party can find it.

Visitor Authentication

For visitor authentication you can use this run following code asap you load acquire init.js script or before that, and add a new attribute user_hash and assign the HMAC code along with user's email or any other details to cofing object.

To get HMAC code, login acquire dashboard and open this: and Chat widget code in Choose Visitor authentication.

Important : Use HMAC only Server side not use client side and Keep your secret key safe! Never commit it directly to your repository.

<script type="text/javascript">
	window.acquire=window.acquire||[];
	acquire.push({
		user_hash:'INSERT_HMAC_VALUE_HERE',
		userDetails:{
			email:'customer@example.com', //EMAIL
		}
	});
</script>

Logout visitor

If you have set visitor hash (HMAC digest) and visitor just logged out from account and need to manage user integrity with agent, call method logoutVisitor() to remove all acquire data from your app related to visitorHash. This must call method to logout from acquireIO support:

acquireIO.logoutVisitor()

Once you've called logout visitor, it will destroy current user's session and start again guest user's session as it was before.

in case you've already started acquire widget and guest visitor is already started its session, that case you can still use above code or also following function to make user login back.

acquireIO.loginVisitor('USER_HASH',{email:'user@example.com'})
https://app.acquire.io/widget/customize