PASSING CUSTOM USER DATA TO WEBSITE CHATBOT

Written by Hasan Rizvi
Posted On Jun, 01, 2018
The purpose of this tutorial is create website chatbot user, based on current logged in user on your site rather than creating random named user or ask to login again on website chatbot.

So, let’s start the tutorial:

For this tutorial we have assumed that you have already pasted the website chatbot code in your website.

Now copy the code provided below and paste it under the website chatbot code:

Code Based Webbot:

<script>
 function setParams(){
  var params = {
   'user_name':"<?php echo (isset($_GET['name'])) ? $_GET['name'] : ''; ?>",
   'user_email':"<?php echo (isset($_GET['email'])) ? $_GET['email'] : ''; ?>", //optional
   'uid':"<?php echo (isset($_GET['uid'])) ? $_GET['uid'] : ''; ?>"
  };
  setBotsifyParams(params);
 }
</script>

Iframe Based Webbot:

<script>
 function setParams(){
  var params = {
   'user_name':"<?php echo (isset($_GET['name'])) ? $_GET['name'] : ''; ?>",
   'user_email':"<?php echo (isset($_GET['email'])) ? $_GET['email'] : ''; ?>", //optional
   'uid':"<?php echo (isset($_GET['uid'])) ? $_GET['uid'] : ''; ?>"
  };
  return params;
 }
</script>
The above example is based on PHP code but you can replace the PHP code with the code your website is developed.

After pasting the code and replacing the values, call setParams function on body load. For example:

<body onload="setParams()">

</body>