Skip to content

request

morfeusys edited this page Mar 20, 2020 · 3 revisions

BotRequest contains a channel-related request data and available through request variable in the action block of the dialogue state.

In general this object contains at least type of the request, user's identifier and an input. Each channel defines its own implementation of BotRequest with additional channel-related request fields. It can be accessed via null-safe invocation of channel extension. For example:

state("main") {

    action {
        var name = context.client["name"]

        if (name == null) {
            request.telegram?.run {
                name = message.chat.firstName ?: message.chat.username
            }
            request.facebook?.run {
                name = reactions.facebook?.queryUserProfile()?.firstName()
            }
        }
    }
}

Request type

JAICF defines three types of the request: query, event and intent.

User ID

Channel-related user's identifier is contained in request.cluentId variable.

Input

request.input variable contains an input string that corresponds to the request's type.

For event and intent request it is a name of event or intent accordingly. In case of query request this variable contains a raw text of the user's request.

Clone this wiki locally