This site is no longer updated.Go to new Conversational Cloud docs

$request


This object contains client request data.

Special attributes

It has the following attributes:

  • version — the version of the protocol. The last version by default.
  • channelType — the communication channel type. Empty by default.
  • replyTо — the queue name used for delivering the response.
  • botId — the bot identifier used for matching the request with the script it should be processed in.
  • channelUserId — the user identifier.
  • questionId — the request identifier.
  • query — the user request in text format.
  • data — request parameters (lang, timezone, location, etc.).
  • rawRequest — the original request dump to be processed within the script later on.

How to use

  • $request.channelType
state: goToOpeartor
    script:
        if ($request.channelType == 'telegram' || $request.channelType == 'chatwidget') {
            $reactions.answer('Transferring the dialogue to operator')
        } else {
            $reactions.answer('Unable to transfer the dialogue to operator')
        }

  • $request.botId and $request.channelUserId
state:
    q!: * transfer money *
    # the bot function can only be accessed after client authentication
    script:
        # get the pushback link
        $temp.securityToken = "ExampleToken";
        var channelType = $request.channelType;

        # get bot ID
        var botId = $request.botId;
        
        # get the user identifier
        var chatId = $request.channelUserId;
        # event name
        var event = "authEvent";

        var eventData = {
            "token": $temp.securityToken,
            "someData": {
                "smth": 1
            }
        };
        $temp.pushgateResponse = $pushgate.createPushback(channelType, botId, chatId, event, eventData);
...

  • $request.query
state: NoMatch
    event!: noMatch
    a: I do not understand. You said: {{$request.query}}

  • $request.data
script: reset
    intent!: /reset
    script:
        $jsapi.newSession({message: "/start", data: $request.data});

  • $request.rawRequest
state: GetPhoneNumber
    event: telegramSendContact
    script:
        $client.phone_number = $request.rawRequest.message.contact.phone_number;
    a: Thank you! Our Manager will contact you by  {{$client.phone_number }}.