Webhook Calling & User Verification

Widget Installation

First of all we have to setup our site with “Acquire” chat widget. You can get the “chat widget code” from “Installation” option under “Settings” menu.

To identify every visitor, we have to put Visitor Authentication functionality with widget code. Authentication code will produce HMAC Code, that verify the identity of that visitor i.e. visitor_id. HMAC code will be assigned with an attribute, named as user_hash. Find more details on this link: https://developer.acquire.io/js-api/js-live-chat-api/user-verification.

Additional Setup

First of all, we create a hidden field in “chat form”, it will store visitor’s information, that will be helpful to identify that user. In screenshot we setup hidden field with name v_id.

Then after we open our website where Acquire’s chat widget is enabled, and provide visitor’s info with it. We made a blank php page and provide visitor’s id along with URL.

URL: /chat_widget.php?id=35

We use this id and build a hash_hmac value from this id. Then resultant value will be push to acquire object. Like: user_hash: ‘<?php echo $hashVal ?>’

Important : Use HMAC only Server side not use client side and Keep your secret key safe!

Now our chat widget is fully set up. Let's make a webhook now.

Webhook Creation

Now we make a webhook API, i.e. Get premium amount, Get expiry date & etc. Whenever we call this webhook API, we will get huge data about visitor in body of that particular API. Like: hash, visitor_id, chat_id, visitor’s name, visitor’s email, browser details, custom fields value, other misc details.

We can use v_id and hash in our webhook. Again we can make hash value $new_hash from $v_id by use of your secret key and match it with $init_hash . If it matched with it then we able to know that this visitor is authenticated.

Now we add link of this webhook in Bot’s Webhook APIs Library with a variable name. Make sure you make variable name as you used in webhook. For example: we create a webhook API with response { ‘premium_amount’ : ’Your premium amount is 5410 rs.’ } then in below popup box, we have to make variable name as premium_amount. You can find this at “Chatbot > Setting > Webhook APIs”.

Now our webhook variable is set up.

Use of Webhook

Now we add a question in Support Bot like:

We will use webhook variable as answer of bot. So whenever we ask this question to bot then bot call that webhook and replace this variable with API response. See widget image on next page.