Skip to content

Action: Receive parameters

This action allows capturing parameters sent through other commands or buttons, as well as via webhooks, and reusing them in later actions.

No configuration is required; simply add this action to the button or command and press ✅ Activate to enable it.


What can you do with this action?

  1. Capture parameters sent in bot commands:

    • In a command like:

      /pay 123456789 10 "Withdrawal processed"
      

      You can extract:

      • 123456789 as the first parameter.
      • 10 as the second parameter.
      • "Withdrawal processed" as the third parameter.
  2. Reuse parameters in other actions:

    • Use the captured parameters in subsequent actions.
    • Values are accessed using the ID of this action, followed by .param(n), where n is the position of the parameter in the list, starting from 1. For example:

      • First parameter: #ActionID.param1#
      • Second parameter: #ActionID.param2#
      • Third parameter: #ActionID.param3#
  3. Work with different data types:

    • Texts, dates, expressions, and variables: Must be enclosed in quotes when sent. Example:

      /command "Example text"
      /command "01-03-2024 00:07:48"
      /command "{2 + 2}" "{date_now()}" "{balance}"
      
    • Numbers, booleans, and action IDs: Are sent without quotes. Example:

      /command 50 True #jG8K3.text#
      

Practical example: Capturing and reusing parameters

VisualMaker has a native command that allows you to send a private message to any user of your bot. Check it out here.

In this example, we will create a /message command that does exactly that. It will require 2 parameters:

  • Parameter 1: The @username or the user ID who will receive the message.
  • Parameter 2: The message to be sent.

An example of using the command would be:

/message "@JohnDoe" "Hello, I am the admin"
  • Parameter 1: @JohnDoe
  • Parameter 2: Hello, I am the admin

We want to capture these parameters and use them in the following action.

1. Create the command

  1. Enter edit mode by pressing 🛠 Edit on your bot.
  2. Press ✳️ New button | command and type /message.
  3. (Optional) Hide the command by pressing Hide 👁 so that only the bot owner (you) and other designated administrators can use it.
  4. Add actions to the command by pressing Actions 🌟.

2. Configure the actions

a) Action 1: Receive parameters
  1. Press 🎯 New action🖥 Receive parameters.
  2. This action does not require configuration, simply activate it by pressing ✅ Activate.
  3. Copy the Action ID, as you will need it shortly.
b) Action 2: Send message (to user)
  1. Press 🎯 New action✉️ Send message.
  2. Press Configure 🛠💬 Set message 💬 and enter the message that the user will receive, which is stored in parameter 2 of the Receive parameters action:

    ℹ️ Admin message ⬇️
    
    {#ActionID.param2#}
    

    Replace ActionID with the Action ID of Receive parameters.

  3. Press 👤 Send to someone else 👤📍 Set new recipient 📍:

    • Here, you must specify the user who will receive the message, using their @username or ID. Since you are sending it in parameter 1 of the /message command, it should look like this:

      {#ActionID.param1#}
      

      Replace ActionID with the Action ID of Receive parameters.

  4. Return to the actions menu and activate the action by pressing ✅ Activate.

c) Action 3: Send message (to you)
  1. Press 🎯 New action✉️ Send message.
  2. Press Configure 🛠💬 Set message 💬 and enter a delivery confirmation message that you will receive. Example:

    ✅ Message sent to the user.
    
    User: {#ActionID.param1#}
    Message: {#ActionID.param2#}
    

    Replace ActionID with the Action ID of Receive parameters.

  3. Return to the actions menu and press ✅ Activate to make it functional.


Final result

When you send the command:

/message "@MaryDoe" "Hello, I am the admin"

The bot will:

  1. Capture the data:
    • "@MaryDoe" (parameter 1): The user who will receive the message.
    • "Hello, I am the admin" (parameter 2): The message content.
  2. Send the message to the user, who will receive:

    ℹ️ Admin message ⬇️
    
    Hello, I am the admin
    
  3. Notify you that the message was sent, displaying something like:

    ✅ Message sent to the user.
    
    User: @MaryDoe
    Message: Hello, I am the admin
    

User ID in Telegram

If you use the ID of the user instead of a @username, it will also work.

/message 123456789 "Greetings from the administration"

Learn how to get the user's ID by reading here.

This is how the actions turned out

VisualMaker action receive parameters example


This action is useful for custom workflows that require dynamic inputs, such as administrative commands or processes based on user data, as well as for capturing data sent via webhook.