Skip to content

Commit d56c50b

Browse files
Atul-Butolasambhavjain9138bc-devrevgithub-actions[bot]fern-support
authored
Update identify-web-user.mdx (#188)
* Update identify-web-user.mdx no-work-item * Update identify-web-user.mdx * Update identify-web-user.mdx * Update identify-web-user.mdx * Update identify-web-user.mdx * Update user-identity.mdx * Update user-identity.mdx * update documentation * final changes * nit * nit * Update fern/docs/pages/plug-sdk/web/user-identity.mdx Co-authored-by: Ben Colborn <[email protected]> * Update fern/docs/pages/plug-sdk/web/user-identity.mdx Co-authored-by: Ben Colborn <[email protected]> * Update fern/docs/pages/plug-sdk/web/user-identity.mdx Co-authored-by: Ben Colborn <[email protected]> * Update fern/docs/pages/plug-sdk/web/user-identity.mdx Co-authored-by: Ben Colborn <[email protected]> * Update fern/docs/pages/plug-sdk/web/user-identity.mdx Co-authored-by: Ben Colborn <[email protected]> * Update fern/docs/pages/plug-sdk/web/user-identity.mdx Co-authored-by: Ben Colborn <[email protected]> * update status code and trouble shooting * address comments * Update fern/docs/pages/sdks/web/user-identity.mdx Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * nit * Update user-identity.mdx * Update user-identity.mdx * Update user-identity.mdx --------- Co-authored-by: Sambhav Jain <[email protected]> Co-authored-by: sambhav jain <[email protected]> Co-authored-by: Ben Colborn <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Fern Support <[email protected]>
1 parent 4c4e4e8 commit d56c50b

File tree

1 file changed

+88
-41
lines changed

1 file changed

+88
-41
lines changed

fern/docs/pages/sdks/web/user-identity.mdx

Lines changed: 88 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
Once you have [installed PLuG](./installation), 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.
22

3-
For users who are logged into your website, you can identify them in PLuG so they can view their past conversations. Identifying your users also enables more personalized engagement.
3+
For users who are logged into your website, you can identify them in PLuG to enable them to view their conversation history and receive more personalized engagement.
44

5-
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.
6-
7-
To identify logged-in users, follow these steps:
5+
To implement user identification, you need to generate a session token for each user who visits your website. This token is created using your application access token combined with customer information, and must be generated on your backend to keep the application token secure.
86

97
## Generate an application access token
108

11-
1. In DevRev, go to **Settings > Support > PLuG Tokens** through the settings icon on the top-left corner.
12-
2. Under the **Application access tokens** panel, click **New token** and copy the token that's displayed.
9+
1. In DevRev, go to **Settings > Support > PLuG Tokens** through the settings icon on the top-left corner.
10+
2. Under the **Application access tokens** panel, click **New token** and copy the token that's displayed.
1311

1412
<Callout intent="note">
15-
Ensure you copy your access token, as you will not be able to view it again.
13+
Ensure you copy your access token, as you cannot view it again.
1614
</Callout>
1715

1816
## Generate a session token
1917

2018
<Callout intent="note">
21-
For security reasons, this call should be made from the server side so that your AAT isn't exposed.
19+
For security reasons, this API call must be made from the server side to prevent exposing your application access token (AAT).
2220
</Callout>
2321

2422
Using the `rev_info` method, you can generate and recognize a user within the DevRev system by providing relevant user details. This method enables you to convey information systematically, ensuring alignment between your DevRev CRM and the structured data model. For information regarding terminologies, click [here](https://devrev.ai/docs/product/grow).
@@ -35,7 +33,7 @@ curl --location 'https://api.devrev.ai/auth-tokens.create' \
3533
"workspace_ref": "devrev-dev",
3634
"user_traits": {
3735
"email": "[email protected]",
38-
"display_name": "Devrev Test USer",
36+
"display_name": "Devrev Test User",
3937
"phone_numbers": ["+911122334455"],
4038
"custom_fields": {
4139
"tnt__<field1_name>": "value 1"
@@ -56,10 +54,39 @@ curl --location 'https://api.devrev.ai/auth-tokens.create' \
5654
}
5755
}
5856
}'
59-
```
57+
```
58+
59+
**Attributes for [users](https://developer.devrev.ai/public/api-reference/dev-users/product-builders-and-service-providers)**
60+
61+
| Attributes | Description | Type | Required | Unique |
62+
|---------------|-----------------------------------------------------------------------------|--------|----------|--------|
63+
| `user_ref` | A unique user reference that the DevRev app uses for identifying your users. This parameter is required. | string |||
64+
| `email` | The email address of the customer. It's used for sending email notifications of any support messages. | string ||** |
65+
| `display_name` | The name of the user that's shown on the widget. | string |* ||
66+
| `phone_numbers` | The customer's mobile number, which must adhere to the E.164 format. | array |||
67+
68+
* If nothing is specified, a system-generated name is assigned to the user.
69+
70+
** Email uniqueness is subjected to organization preferences. If organization want, it can be marked non unique. But it is not recommended.
71+
72+
**Attributes for [workspaces](https://developer.devrev.ai/public/api-reference/rev-orgs/workspaces)**
73+
74+
| Attributes | Description | Type | Required | Unique |
75+
|-----------------|--------------------------------------------------------------------------------------------------------------------|--------|----------|--------|
76+
| `workspace_ref` | A unique reference for the user's workspace. If not provided, and an account reference is passed, the user is directly attached to the account. | string |||
77+
| `display_name` | The name of the workspace that's shown on the widget. | string |||
78+
79+
**Attributes for [accounts](https://developer.devrev.ai/public/api-reference/accounts/accounts)**
80+
81+
| Attributes | Description | Type | Required | Unique |
82+
|-----------------|-------------------------------------------------------------------------------------------------------------------------|--------|----------|--------|
83+
| `account_ref` | A unique reference for the account. | string |||
84+
| `display_name` | The name of the account that's shown on the widget. | string |||
85+
| `domains` | The attribute must be unique. Use a format like `devrev.ai`. Inputs like `https://devrev.ai` or `www.devrev.ai` are invalid. | array |||
86+
| `phone_numbers` | The phone number associated with the account must be in E.164 format. | array |||
6087

6188
<Callout intent="note">
62-
Ensure that you follow the specified format when providing your phone number.
89+
Ensure that you follow the specified format when populating phone numbers and domains in the request body.
6390
</Callout>
6491

6592
## Pass custom attributes
@@ -77,32 +104,53 @@ You can pass the custom attributes that are created as shown below:
77104

78105
You can pass custom traits, as shown above, not only for `users` but also for `workspaces` and `accounts`.
79106

80-
If you prefer a two-level structure, where users are directly associated with an account instead of a workspace, you can provide the `user_ref` and details along with the `account_ref` and details.
107+
### API status codes and troubleshooting
108+
109+
| Status code| Description | Troubleshooting |
110+
|----------|----------|----------|
111+
| 200 OK | The request was successful and the session token would be returned in the response. | No troubleshooting required. |
112+
| 400 Bad Request | The request was invalid. | Check the request body for errors. For fields like domain and phone number, check on their format. |
113+
| 401 Unauthorized | The request was unauthorized. | Check if the AAT is valid and not expired. |
114+
| 403 Forbidden | The request was forbidden. | Check the authorization header for errors and make sure the token is a valid AAT. |
115+
| 404 Not Found | The requested resource could not be found. | Verify the endpoint URL is correct. |
116+
| 429 Too Many Requests | Rate limit exceeded. | Implement request throttling or wait before retrying. |
117+
| 500 Internal Server Error | Server encounters an unexpected error. | Wait and try again later. If the issue persists, contact support with the request details and timestamp. |
118+
119+
### How resolution works
120+
121+
When you send object information to DevRev, the system automatically creates or finds existing contacts, accounts, and workspaces.
122+
123+
DevRev offers three ways to structure your customer's data:
81124

82-
**Attributes for users**
125+
| Hierarchy Type | Documents Created | What to Include | Use Case |
126+
|----------------|-------------------|-----------------|----------|
127+
| **Single-level** | Contacts only | Only user information | Recommended for most B2C cases |
128+
| **Two-level** | Accounts and Contacts linked to the account | User and account information | Recommended for most B2B cases |
129+
| **Three-level** | Account with linked workspaces and contacts | User, workspace and account information | Used for B2B cases but only recommended if your business model requires workspace organization |
83130

84-
|Attributes |Description |Type |
85-
|---|---|---|
86-
|`user_ref` |A unique user reference that the DevRev app uses for identifying your users. This parameter is required. |string |
87-
|`email` |The email address of the customer. It's used for sending email notifications of any support messages. |string |
88-
|`display_name` |The name of the user that's shown on the widget. |string |
89-
|`phone_numbers` |The mobile number of the customer. |array |
131+
**What happens when you send different combinations:**
90132

91-
**Attributes for workspaces**
133+
User reference:
134+
- A user reference is mandatory, ensuring its constant presence.
135+
- If a user with the provided reference doesn't exist, the system automatically creates the user.
92136

93-
|Attributes |Description |Type |
94-
|---|---|---|
95-
|`workspace_ref` |A unique reference for the user's workspace. If not provided, and an account reference is passed, the user is directly attached to the account. |string |
96-
|`display_name` |The name of the workspace that's shown on the widget. |string |
137+
This approach ensures efficient management and integration of objects within the DevOrg.
97138

98-
**Attributes for accounts**
139+
| Workspace Ref | Account Ref | Results |
140+
|---------------|-------------|------------------------------------------------------------------------------------------------------|
141+
||| (Most common Usage) \nIf the account doesn't exist: An account is created, and the user is linked with the account. |
142+
||| No action on account or workspace. The user is returned. |
143+
||| If neither exists: System creates the account first, then creates the workspace. User is linked to both.<br />If account exists but workspace doesn't: System creates the workspace under the existing account. User is linked to both.<br />If workspace exists under different account: System returns an error, as workspaces cannot be a part of 2 accounts. |
144+
||| If workspace doesn't exist: System creates a new account and workspace (if needed). User is linked to both. |
99145

100-
|Attributes |Description |Type |
101-
|---|---|---|
102-
|`account_ref` |A unique reference for the account. |string |
103-
|`display_name` | The name of the account that's shown on the widget. |string |
104-
|`domains` |The domain names of the accounts that the users belongs to. |array |
105-
| `phone_numbers` |The phone number associated with the account. |array |
146+
147+
148+
### Best practices
149+
150+
- Populate user traits like email and display name to make users identifiable and to prevent duplicate users across integrations.
151+
- Maintain consistent unique identifiers across your system.
152+
- Follow the specified formats for phone numbers and domains.
153+
- Keep your application access token secure.
106154

107155
## Pass the session token
108156

@@ -115,7 +163,7 @@ const sessionToken = '<SESSION_TOKEN>'
115163
<script>
116164
(() => {
117165
window.plugSDK.init({
118-
app_id: '<your_unique_app_id>',
166+
app_id: '<your_unique_app_id>',
119167
session_token: sessionToken
120168
})})();
121169
</script>
@@ -137,17 +185,17 @@ This method is currently in beta and comes with the following limitations:
137185

138186
```jsx
139187
window.plugSDK.init({
140-
app_id: '<your_unique_app_id>',
188+
app_id: appId,
141189
identity: {
142-
user_ref: string;
143-
user_traits?: { // optional
144-
custom_fields?: object; // optional
145-
display_name?: string; // optional
146-
email?: string; // optional
147-
phone_numbers?: string[]; // optional
190+
user_ref: userRef,
191+
user_traits: { // Optional user details
192+
custom_fields?: object,
193+
display_name: 'John Doe',
194+
195+
phone_numbers: ['+1234567890']
148196
}
149197
}
150-
})
198+
});
151199
```
152200

153201
You can add or update the data in `user_traits` by using the `updateIdentity` method on the PLuG SDK. Attached is a sample code snippet for the same.
@@ -162,4 +210,3 @@ window.plugSDK.updateIdentity({
162210
}
163211
})
164212
```
165-

0 commit comments

Comments
 (0)