Identify a contact in a chat widget

SOLVE
Regular Contributor

We're trying to structure a chat flow so that it picks up the name and email of our users in the client interface. Can you advise please?

1 Accepted solution

Accepted Solutions
HubSpot Moderator

Hi, all.

 

If you've implemented theidentifytrackPageView, and HubSpotConversations.widget.refresh() methods outlined above but are still seeing some chats come in as "Unknown Visitors," I can confirm that it is currently expected behavior.

 

Theidentify method critical to the approach HubSpot Developer Support  has heretofore positioned on the Community only directly updates the hubspotutk cookie with the visitor's identity.

 

The conversations (live chat) tool uses a different cookie — messagesUtk— to populate visitor names. If this cookie is not associated with any identity information, a chat will come in under an "Unknown Visitor."

 

HubSpot currently has a back end process which associates the hubspotutk identity information with themessagesUtk cookie, but calling theidentifymethod does not always trigger this process.

 

As such, there is currently no way to guarantee that a chat won't come in under an "Unknown Visitor," even with the method outlined above, which works much of the time.

Our team is working on a dedicated solution for this use case but we currently can't offer a concrete timeframe. Please subscribe to the API Changelog to be notified of the update when it is released.

Apologies for the confusion and thank you in advance for your understanding.

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
7 Replies 7
HubSpot Moderator

Hi, @kporteus.

 

To clarify, are you seeking to identify users with information from your web app before they open a chat?

 

If so, you can accomplish this by triggering the Tracking Code API's identify method, then trackPageView, and then refreshing the chat widget. See @cbarley's example code in this related discussion:

 

function onConversationsAPIReady() {
    var _hsq = window._hsq = window._hsq || [];
    console.log("ready")
    _hsq.push(["identify",{
    	email: "test@testing.com"
    }]);
    _hsq.push(['trackPageView']);
    setTimeout( () => {
      console.log("refresh")
      window.HubSpotConversations.widget.refresh();
    }, 1000)
  }

  function sendIdentify(){
    if (window.HubSpotConversations) {
     onConversationsAPIReady();
    } else {
      window.hsConversationsOnReady = [onConversationsAPIReady];
    }

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Regular Contributor

Hi Isaac, thanks.

 

We'd like our chatbot to say 'Hi NAME' when they're logged into our web app - as opposed to collecting their name and email address each time.

 

Is this the way to do it?

 

 

 

Reply
0 Upvotes
HubSpot Moderator

Hi, @kporteus.

 

Yes and no.

 

You can use the identify method to avoid asking for the user's name and email each time, but HubSpot chat welcome messages (the first message in a flow) cannot use personalization tokens, like {{ contact.firstname }}. You can call users by their name on subsequent messages, though.

 

Welcome message.jpg

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Highlighted
Regular Contributor

Ok thank you - that should work for us.

 

So just to confirm we need to use the identify method followed by the trackPageView OR just the idendify method?

 

The other thread mentions something about a hard refresh being required - Will the user only be identified if we hard refresh the conversations inbox in HubSpot?

 

We need this to happen automatically so the chat flow can direct the user to their contact owner without the need for any refresh. 

 

Please advise

 

Thanks,

Kerry

Reply
0 Upvotes
HubSpot Moderator

Hey @kporteus , I'll let Isaac continue to work with you on this, but you wouldn't need a hard refresh of the page with a new API we just released. Check out my recent comment here: https://community.hubspot.com/t5/APIs-Integrations/How-to-identify-a-contact-in-the-chat/m-p/272830#...

HubSpot Moderator

Great catch, @cbarley! I've updated my initial response to reflect this fact.

 

@kporteus, as Connor says above, you no longer need to hard refresh the page, but you do need to trigger the following in order:

  1. identify: Stores the data you define (such as name and email) in the tracker.
  2. trackPageView: Passes the data in the tracker into HubSpot so that it can be used in personalization tokens.
  3. HubSpotConversations.widget.refresh(): Refreshes the chat widget so that personalization tokens can populate with known values.

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
HubSpot Moderator

Hi, all.

 

If you've implemented theidentifytrackPageView, and HubSpotConversations.widget.refresh() methods outlined above but are still seeing some chats come in as "Unknown Visitors," I can confirm that it is currently expected behavior.

 

Theidentify method critical to the approach HubSpot Developer Support  has heretofore positioned on the Community only directly updates the hubspotutk cookie with the visitor's identity.

 

The conversations (live chat) tool uses a different cookie — messagesUtk— to populate visitor names. If this cookie is not associated with any identity information, a chat will come in under an "Unknown Visitor."

 

HubSpot currently has a back end process which associates the hubspotutk identity information with themessagesUtk cookie, but calling theidentifymethod does not always trigger this process.

 

As such, there is currently no way to guarantee that a chat won't come in under an "Unknown Visitor," even with the method outlined above, which works much of the time.

Our team is working on a dedicated solution for this use case but we currently can't offer a concrete timeframe. Please subscribe to the API Changelog to be notified of the update when it is released.

Apologies for the confusion and thank you in advance for your understanding.

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes