Users

Users

The Users namespace contains operations available for the known users of your bot.

Source:

Example

bp.users

Methods

(async, static) getTag(userId, tag) → (nullable) {String}

Returns the value of a user tag, if it exists

Source:
Parameters:
Name Type Description
userId String

[description]

tag String

[description]

Returns:
Type:
String

Value of the tag

(async, static) getTags(userId) → {Array.<{tag: String, value: String}>}

Returns all the tags for a given user

Source:
Parameters:
Name Type Description
userId String

[description]

Returns:
Type:
Array.<{tag: String, value: String}>

An array of all the tags for this user

(async, static) hasTag(userId, tag) → {Boolean}

Returns whether or not a user has a specific tag or not.

Source:
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, static) 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.

Source:
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')

(async, static) untag(userId, tag)

Removes a tag from a user if it exists.

Source:
Parameters:
Name Type Description
userId String
tag String

Name of the tag. Case-insensitive.