User object

This is an instance of the User class regarding the current user

getMagicVariable ()

Get the value of a magic variable

Parameter

Type

Description

name

String

Name of the magic variable

Example

const converse = new NewBot()

converse.exec('hey', 'user id', {
    preUser(user) {
        user.getMagicVariable('text') // "hey"
    }
})

setMagicVariable ()

Assign a value to a magic variable

Parameter

Type

Description

name

String

Name of the magic variable

value

Any

Value of the magic variable

Example

const converse = new NewBot()

converse.exec('hey', 'user id', {
    preUser(user) {
        user.setMagicVariable('custom', 'foo')
    }
})

In ConverseScript

@Intent(/hey/i)
hey() {
    > { :custom } // => "foo"
}

getVariable ()

Get the value of a global variable

Parameter

Type

Description

name

String

Name of the global variable

setVariable ()

Assign a value to a global variable

Parameter

Type

Description

name

String

Name of the global variable

value

Any

Value of the global variable

saveSession ()

Save a session

Parameter

Type

Description

session

Object

The properties of the session

retrieveSession ()

Return the saved session

setLang ()

Assign the language of the user

Parameter

Type

Description

lang

String

Language to assign (example: fr_FR, en_EN, etc.)

getLang ()

Retrieves the user's language

toJson ()

Returns all the data of the user in order to save his progress in the script

fromJson ()

Restores the user's progress thanks to the JSON saved by toJson()

Parameter

Type

Description

json

Object

User progress

Last updated