Unable to Identify Users

Hi everyone,

I am using the below code but the users info is not passing into Hubspot CRM and my users are still showing as unknown visitor. how do i make it automatically create a contact so when responding to my website chats through the hubspot portal i know which user i am talking to by first name without them having to give the bot the first name?

 <script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/<?php echo $hubspotID; ?>.js"></script>
 <script type="text/javascript">
 function onConversationsAPIReady() {
 var _hsq = window._hsq = window._hsq || [];
 _hsq.push(["identify",{
 email: "<?php echo $userEmail; ?>",
 firstname: "<?php echo $userFN; ?>",
 lastname: "<?php echo $userLN; ?>",
 user_id: "<?php echo $userID; ?>",
 project_id: "<?php echo $userProject; ?>"
 }]);
 _hsq.push(['trackPageView']);
 setTimeout( () => {
 window.HubSpotConversations.widget.refresh();
 }, 1000)
 }

 function sendIdentify(){
 window.HubSpotConversations.on('conversationClosed', payload => {
 });
 }

 if (window.HubSpotConversations) {
 onConversationsAPIReady();
 sendIdentify();
 } else {
 window.hsConversationsOnReady = [onConversationsAPIReady, sendIdentify];
 }
 </script>

Hey @anupbalfour,

It is currently working as expected that if you’re using theidentify, trackPageView, and HubSpotConversations.widget.refresh() methods and are still seeing chats coming in as “Unknown Visitors”.

This is further explained by Isaac here: https://community.hubspot.com/t5/APIs-Integrations/How-to-identify-a-contact-in-the-chat/m-p/272830/highlight/true#M24773 (The accepted solution post).