Methods
(async, inner) getTag(userId, tag) → (nullable) {String}
Returns the value of a user tag, if it exists
Parameters:
Name | Type | Description |
---|---|---|
userId |
String
|
[description] |
tag |
String
|
[description] |
Returns:
- Type:
-
String
Value of the tag
(async, inner) getTags(userId) → {Array.<{tag: String, value: String}>}
Returns all the tags for a given user
Parameters:
Name | Type | Description |
---|---|---|
userId |
String
|
[description] |
Returns:
- Type:
-
Array.<{tag: String, value: String}>
An array of all the tags for this user
(async, inner) hasTag(userId, tag) → {Boolean}
Returns whether or not a user has a specific tag or not.
Parameters:
Name | Type | Description |
---|---|---|
userId |
String
|
|
tag |
String
|
The name of the tag. Case insensitive. |
Returns:
- Type:
-
Boolean
Example
if (await bp.users.hasTag(event.user.id, 'IS_SUBSCRIBED')) {...}
(async, inner) tag(userId, tag, valueopt)
Tags a user with a specific tag (or overwrites an existing one) and a given value for that tag (optional).
Tags can be used to classify users (no value needed) or to store information about them (with a tag value).
Values are useful to store user information like emails, etc.
Value is always assumed to be a string.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
userId |
String
|
|||
tag |
String
|
The name of the tag. Case insensitive. Note that this property will always be upper-cased. | ||
value |
String
|
<optional> |
true | Any string value to store info about this tag |
Example
await bp.users.tag(event.user.id, 'EMAIL', 'sylvain@botpress.io')
await bp.users.tag(event.user.id, 'PAYING_USER')