On this page

Identify your users with PLuG

Once you have installed PLuG, all your users who interact with the widget are created as anonymous users in the DevRev app with a random name since there is no information about the user.

For users who are logged on to your website, you can identify them on PLuG so that they can see their past conversations. Identifying your users also enables more personalized engagement with your users.

In this flow, you have to generate a session token for every user who visits your website. The session token identifies the customer when they interact with the widget. The session token is generated using the application access token and customer information. It should be generated on your website's back end since the app token needs to be kept hidden.

You can identify logged-in users by following these steps.

Generate an application access token

  1. In DevRev, go to Settings > Support > PLuG Tokens through the settings icon on the top-left corner.
  2. Click New token and copy the token that's displayed.
icon

Copy your access token at this step as you won’t be able to see it again.

Generate a session token

icon

For security reasons, this call should be made from the server side so that your AAT isn't exposed.

You can generate a session token in the following ways:

  • Using rev user_id:
1 curl --location 'https://api.devrev.ai/auth-tokens.create' \ --header
2 'Content-Type: application/json' \ --header
3 "Authorization: $AAT" \ --data
4 '{
5 "grant_type" : "urn:devrev:params:oauth:grant-type:token-issue",
6 "subject_token" : "<<subject token>>",
7 "subject_token_type" : "urn:devrev:params:oauth:token-type:userinfo",
8 "requested_token_type" : "urn:devrev:params:oauth:token-type:session"
9 } '
Config optionTypeRequiredDescription
grant_typestringYesSpecifies the process of obtaining a token.
subject_tokenstringYesRepresents the entity that requests the token. Not required when requesting an application access token (AAT).
subject_token_typestringYesThe type of the subject token.
requested_token_typestringYesThe type of the requested token.
  • Using rev_info:
1 curl --location 'https://api.devrev.ai/auth-tokens.create' --header 'Authorization: "<<Application Access Token>>"'
2 --header 'Content-Type: application/json' --data-raw
3 '{
4 "rev_info": {
5 "user_ref": "<<123456789>>",
6 "org_ref": "<<org-org>>",
7 "user_traits": {
8 "email": "<<user@example.org>>",
9 "display_name": "<<user>>",
10 "full_name": "<<User Name>>"
11 },
12 "org_traits": {
13 "display_name": "<<example>>",
14 "domain": "<<example.com>>"
15 }
16 }
17 }'
Config optionTypeRequiredDescription
user_refstringYesA unique user reference that the DevRev app uses for identifying your users.
org_refstringNoA unique ID for the organization of the user.
emailstringNoThe email address of the customer. It's used for sending email notifications of any support messages.
display_namestringNoThe name of the user that's shown on the widget.
full_namestringNoThe full name of the customer.
display_namestringNoThe display name of the organization on the PLuG widget.
domainstringNoThe domain name of the organization that the user belongs to.

Passing the session token

While initializing the PLuG widget you pass the session token for DevRev to identify this user and thereby make the widget more customized for the user and their context.

1 // You can generate this session token using the above API in your backend
2 const sessionToken = '<SESSION_TOKEN>'
3 <script type="text/javascript" src="https://plug-platform.devrev.ai/static/plug.js"></script>
4 <script>
5 (() => {
6 window.plugSDK.init({
7 app_id: '<your_unique_app_id>',
8 session_token: sessionToken
9 })})();
10 </script>