APIs & Integrations

LukaszWiktor
Participant

How to identify a contact in the chat?

SOLVE

Hi,

how can I identify a visitor in the chat box? I've tried the identify API

 var _hsq = window._hsq = window._hsq || []; 
_hsq.push(["identify", { email: "${email}" }]);

but it didn't work. New chat conversations still appear as "Uknown Visitor"

I'd appreciate your help.

Thanks,
Lukasz

1 Accepted solution
tilly
Solution
HubSpot Product Team
HubSpot Product Team

How to identify a contact in the chat?

SOLVE

The Visitor Identification API is now in public beta! You can read more about it and get started here. This is open to all Pro+ portals as of now, no need to be ungated. 

 

The new Visitor Identification API enables you to provide details about visitors' identities to the chat widget after they've been authenticated by an external login system. So, if a visitor logs in (by providing their email address), the Visitor Identification API can send their identity to HubSpot's chat widget.

 

This API also works automatically with HubSpot's private content membership for CMS Hub or Knowledge Base, no additional setup required!

 

Please let me know if you have any questions or feedback. This API is still in beta, by using this API you agree to our developer beta terms.

View solution in original post

115 Replies 115
TrangBui97
Member

How to identify a contact in the chat?

SOLVE

This solution for this.

1. Follow this link to update identify visitor:

https://developers.hubspot.com/docs/api/conversation/visitor-identification

window.hsConversationsSettings = {
   identificationEmail: "visitor-email@example.com",
   identificationToken: "<TOKEN FROM STEP 1>"
};

2. Call  clear function to refresh chatbox identify.

https://developers.hubspot.com/docs/api/conversation/chat-widget-sdk

window.HubSpotConversations.clear({resetWidget:true});

It work perfert for me, hoping helpful to you.

PTamrakar
Participant

How to identify a contact in the chat?

SOLVE

Hi,

We are using it in SPA angular 7 app
We want that chatbox should be available to visitor as guest and as soon as user logs in to the system it should identify as user

We are able to generate new token with user's email and we are setting it to window.hsConversationsSettings 

But user continue to detected as unknow users

We have tried to make use of 

window.HubSpotConversations.widget.refresh();
window.HubSpotConversations.clear({resetWidget:true});

But still on same issue unknow user 

Flow
User visit the site -> Unknow user
User login to the site -> Token generated and saved-> window.hsConversationsSettings -> console.log we can see new data -> Still unknow user

2nd flow
User visit the site -> we explicitily  set 1 known user (Myuser1) with valid tolen in index.html window.hsConversationsSettings -> know user detected as Myuser1
User login to the site -> Token generated and saved-> window.hsConversationsSettings -> console.log we can see new data -> Still Myuser1

Any one lucky enough in last 2 year that this unknown user solved in Single page application ?

Thanks 





0 Upvotes
kimmi
Participant

How to identify a contact in the chat?

SOLVE

@PTamrakar Have you tried to use 

window.HubSpotConversations.resetAndReloadWidget()?
 
0 Upvotes
gregtappero
Participant

How to identify a contact in the chat?

SOLVE

Rectification, it does work on the Hubbspot Conversations Inbox.
The issue is the slack alert that does show `HubSpotAPP Unknown visitor started a conversation`.

Maybe the slack notification is triggered before the User assignment is resolved? 

gregtappero
Participant

How to identify a contact in the chat?

SOLVE

I am also seeing the same issue:

We get the proper token (JWT) and base64 decode shows proper content.
The user does exist on Hubspot.

Yet we get Unknown visitor

gregtappero_1-1614800243661.png

 

 

0 Upvotes
John3212
Participant

How to identify a contact in the chat?

SOLVE

I`ve been checking everytime in the chrome dev console to see if the mail and the token are set in the window.hsConversationsSettings object, and they are always set there, i just tried again:
T1r4in6



0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

How to identify a contact in the chat?

SOLVE

Hi, @John3212.

 

@dennisedson will be able to help you out here.

 

Based on your description of the issue, I suspect that the identificationEmail and identificationToken may not be set every time the page loads for an authenticated visitor. Per Step 3 in the documentation:


This context will not be carried across page loads automatically if these parameters are no longer set. Tokens are temporary and will expire after 12 hours.

Isaac Takushi

Associate Certification Manager
0 Upvotes
Sheamus
Participant

How to identify a contact in the chat?

SOLVE

Isaac ( @IsaacTakushi ),

 

A couple questions on this:

1. We are already doing this for tracking:

_hsq.push([ 'identify', {
firstName,
lastName,
email,
role, // hopefully, this works...
company: tenant
}]);

What is the relationship between this an the call to setting up Chat?

 

2. Is the only way to get the identificationToken via a seperate API call? Can it be combined with the tracking identify shown above?

 

3. Unfortunately, our appliacation is not a SPA. So lots of requests. I would prefer not to add an API call on every page request. I assume the only way to manage this is to add another cookie on our end to track when we get the identification token and then if has been more than 12 hours get a new one?

 

4. Is there a way to get an identification token without creating a contact? I dont' want to create a contact unless they actually start a chat.

 

Thanks,
~Shea M

0 Upvotes
John3212
Participant

How to identify a contact in the chat?

SOLVE

Hello @tilly @IsaacTakushi 

I followed the steps from the api docs here:
https://developers.hubspot.com/docs/api/conversation/visitor-identification
but we still see users coming in inbox as  Unknown Visitors, even after setting the required params in the "window.hsConversationsSettings" object


window.hsConversationsSettings = {
  loadImmediately: false,

  identificationEmail: "visitor-email@example.com",

  identificationToken: "tokenId"

};

and then we load the widget: 

window.HubSpotConversations.widget.load();
 

I think we had like 1 or 2 persons identified with their mail, and after some logouts/logins they also started appearing as Unknown Visitors. 

Can someone provide some solution for this?

0 Upvotes
tilly
HubSpot Product Team
HubSpot Product Team

How to identify a contact in the chat?

SOLVE

Hi @mark_cf! The chat widget can also identify visitors based on existing cookies or submitted email addresses, which does not require a Pro subscription. The Visitor Identification API as a method of identifying chat visitors does require a Pro subscription. Let me know if you have additional questions!

0 Upvotes
Tomtomtom1
Member

How to identify a contact in the chat?

SOLVE

@tilly, I'm a small business just getting started.  I can't afford to pay $800/month but hate to ask my visitors for their email when I already know it.  It's just a bad user experience for my visitors.  Seems odd that HubSpot doesn't give all users access to basic API features like this.  Are there any other ways to identify visitors without asking them for their email in the chat?  Does this code still work? https://legacydocs.hubspot.com/docs/methods/tracking_code_api/identify_visitor

mark_cf
Member

How to identify a contact in the chat?

SOLVE

@tilly is it the case that to reliably identify a user in HubSpot Live Chat we need to take out a Pro level subscription?

0 Upvotes
tilly
HubSpot Product Team
HubSpot Product Team

How to identify a contact in the chat?

SOLVE

Hi @avichopra - Thanks for the tag. The Visitor Identification API should work from the KB, but it sounds like we may need additional specifics to get to the root cause. I recommend reaching out to our support team for next steps in troubleshooting the behavior you are seeing.

 

Hi @jpw_andy - At this time, the Visitor Identification API will work with any Pro level subscription across any Hub (Marketing, Sales, Service, or CMS) but is not available for an individual upgrade. Thank you for this feedback!

avichopra
Contributor | Partner
Contributor | Partner

How to identify a contact in the chat?

SOLVE

@tilly any update about my comment above?

0 Upvotes
tilly
Solution
HubSpot Product Team
HubSpot Product Team

How to identify a contact in the chat?

SOLVE

The Visitor Identification API is now in public beta! You can read more about it and get started here. This is open to all Pro+ portals as of now, no need to be ungated. 

 

The new Visitor Identification API enables you to provide details about visitors' identities to the chat widget after they've been authenticated by an external login system. So, if a visitor logs in (by providing their email address), the Visitor Identification API can send their identity to HubSpot's chat widget.

 

This API also works automatically with HubSpot's private content membership for CMS Hub or Knowledge Base, no additional setup required!

 

Please let me know if you have any questions or feedback. This API is still in beta, by using this API you agree to our developer beta terms.

SSasidharan
Participant

How to identify a contact in the chat?

SOLVE

Hey @tilly ,

 I am using the new Visitor Identification API to add a new contact from our system, I see token generated from this API response. but I don't see the contact's being added in hubspot.

 

can someone help with this?

0 Upvotes
jpw_andy
Participant

How to identify a contact in the chat?

SOLVE

Hi @tilly  My company started using Hubspot this year and we're on the starter plan. We were pretty jazzed about being able to use the chat widget in our intranet to provide support to our agents, but as a result of not having automatic user identification we've had very low engagement.

 

Is there a way for me to purchase or unlock access to the new visiter identification API without upgrading my whole plan?

0 Upvotes
patroqueeet
Member

How to identify a contact in the chat?

SOLVE

Good Morning,

 

just tried it without an app, but API/Token only. Got error complaining about missing scopes:

 

{"status":"error","message":"This app hasn't been granted all required scopes to make this call. Read more about required scopes here: https://developers.hubspot.com/scopes.","correlationId":".....","errors":[{"message":"All of the following scopes are required.","context":{"requiredScopes":["conversations.visitor_identification.tokens.create"]}}],"links":{"scopes":"https://developers.hubspot.com/scopes"},"category":"MISSING_SCOPES"}

linking to dead url:

https://developers.hubspot.com/scopes

 

Pls. advice

IsaacTakushi
HubSpot Employee
HubSpot Employee

How to identify a contact in the chat?

SOLVE

Hi, @patroqueeet.

 

I'll look into this. Could you share your app ID and the scopes you are currently requiring?

 

I've learned that @tilly helped you uncover the issue directly.

 

Here are links to the most updated OAuth documentation (mentions scopes) and the older but still relevant scopes documentation.

 

For others reading this, make sure to add the conversations.visitor_identification.tokens.create scope in your app definition's Auth tab, as shown below:

 

conversations.visitor_identification.tokens.create scope.jpg

Isaac Takushi

Associate Certification Manager
0 Upvotes
cl77
Participant

How to identify a contact in the chat?

SOLVE

It seems the visitor identification API does only create a contact, when the customer sends a chat message. Is this the intended behaviour?

 

We're sending email, firstName, lastName to get a token. Contacts should be created then if not stored at HS. 

0 Upvotes