Skip to main content

System variables

Aimylogic automatically creates system variables. You can manipulate them in exactly the same way you do with the variables you add in your blocks.


This variable contains the entire text of the current user request.

You can use the $queryText variable to pass the text entered by the user. For example, if you use the Intents block you can pass the text from it in the HTTP request and collect all the reactions of the user to a Google sheet.

First, add the Conditions block with the following:

$reply = $queryText

Thus, you create the new $reply variable that will contain the user input. Then you can use the IFTTT service to pass it further.

You can use any JavaScript expressions in the Conditions block

You can then output the value from this variable, send it in a Telegram message or email, or submit it to a Google sheet. You can do all this with the $queryText system variable.


This is the unique identifier of the user that is not changed with time. This ID is only unique for the bot/user pair. That means that if the user starts a dialog with your other bot, it will have another ID.


The identifier of the channel your bot uses for conversation with the user. You can create multiple channels of the same type, and each of them will have a unique identifier. This ID does not change with time.


Type of the channel. For example, chatwidget or telegram.


The request in the format of the channel the bot received it from. This variable can be useful if you need to get some additional data from the initial request, such as user name, etc.


This system variable stores the number of seconds since the previous request from the user. Until the first interaction the variable will stay undefined. Use it to vary the bot’s logic for new and existing users.

For example change the logic depending on whether the user was seen recently or long ago.

Or determine if the bot has already contacted this unique user.

Or specify the time interval since the last interaction. Your bot can write them “Welcome back!” after a certain time or ping them otherwise.


The $chathistory system variable stores the last 100 messages from the current chat session between the client and the bot.

If you’re using $chathistory to work with webhooks, declare this variable as some other variable, e.g. $history. While working with webhooks, use the new $history variable.

You can declare a new variable as follows:

  • $history = $chathistory


The $chathistoryjson variable contains the same data as the $chathistory variable — messages from the current chat session between the client and the bot. The only difference is in data format — $chathistoryjson returns data in the JSON format. So chat history inside $chathistoryjson can be sent to external systems, such as operator channels.