Skip to content

Action: HTTP request

With this action, you can interact with APIs and external websites, sending and receiving data to integrate them into your VisualMaker bots.


What can you do with this action?

  • Retrieve real-time dynamic information: Integrate services like Google Maps, OpenWeather, or financial APIs to provide users with up-to-date data at any time.

  • Unlimited connections: Connect your bots to virtually any service that offers an API, such as payment systems, messaging services, weather platforms, and more. The possibilities are endless!

  • Create smart and useful bots: Make your bot take decisions based on the information retrieved from APIs. For example, send personalized recommendations based on user location or preferences.

  • Offer advanced functionalities in your bot: For example, you can integrate a translation service, process payments using platforms like PayPal or Stripe, or even implement virtual assistants using IA.

  • Customize responses based on external data: Make your bot's responses vary according to the information obtained from the external service, such as responding with user-specific or context-specific data.


How to configure the action?

1. Create the action

  • Go to your bot and press 🛠 Edit to enter editor mode.
  • Select the button or command where you want to add this action, or create a new one.
  • Go to Actions 🌟🎯 New action🌐 HTTP request.
  • Click Configure 🛠 to set it up.

2. Configure the options

➡️ Method

Choose the HTTP method type: GET or POST.

➡️ Body

Select the request body format: JSON, data, or params.

➡️ Set URL

Specify the URL where the request will be sent.

➡️ Set body (optional)

Define the data to be sent in the request body. Use the correct format, for example:

"name": "John"
"age": 25
"using_action_ID": #Jsh4K.text#
"using_expression": "{first_name}"

➡️ Set headers (optional)

Add custom headers for the request. Write each header on a new line, with its value separated by a colon, for example:

"Content-Type": "application/json"
"User-Agent": "Mozilla/5.0"

➡️ Set cookies (optional)

Specify cookies using the same format as the previous fields:

"Cookie-Name": "Cookie-Value"

➡️ Set proxy (optional)

Configure an HTTP or SOCKS proxy for the request.

For HTTP proxies:

http://host:port

For SOCKS4 proxies:

socks4://host:port

For SOCKS5 proxies:

socks5://host:port

If the proxy requires authentication, set it as follows:

socks5://user:password@host:port

3. Activate the action

Click ✅ Activate to enable this action and make it functional.

Dynamic data

You can use expressions, variables, and IDs from previous actions to perform dynamic requests.

Data types must be respected.

Working with different data types

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

    "name": "John"
    "date": "31-12-2024 23:59:59"
    "using_expression_with_variable": "{first_name}"
    
  • Numbers, booleans, and action IDs: Should be sent without quotes. Example:

    "age": 25
    "active": True
    "using_action_ID": #GhB2K.param1#
    

What does the action return through its ID?

  • Response in text format: #ActionID.text#
  • Response in JSON format: #ActionID.json#
  • Request status code: #ActionID.status#

Replace ActionID with the action ID of this action (HTTP request).


Practical example: Getting BTC price

In this example, we will retrieve the current Bitcoin price from the CoinMarketCap API.

1. Create a new button

  1. Enter edit mode by clicking 🛠 Edit in your bot.
  2. Click ✳️ New button | command.
  3. Enter the button name, for example: BTC Price.
  4. Click Actions 🌟 to configure the button's actions.

2. Add the necessary actions

a) Action 1: HTTP request
  1. Click 🎯 New action🌐 HTTP request.
  2. Click Configure 🛠 and set the following:

    • Method:

      GET
      
    • Body:

      params
      
    • Set URL:

      https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest
      
    • Set body:

      "symbol": "BTC"
      "convert": "USD"
      
    • Set headers:

      "X-CMC_PRO_API_KEY": "your_api_key_here"
      

      Replace your_api_key_here with your CoinMarketCap API Key, get it here.

  3. Return to the actions menu and activate this action by clicking ✅ Activate.

  4. Copy the action ID of this action, you will need it shortly.
b) Action 2: Send message
  1. Click 🎯 New action✉️ Send message.
  2. Click Configure 🛠💬 Set message 💬 and enter:

    The current Bitcoin price is {fix(#ActionID.json.data.BTC.quote.USD.price#, 3)} USD.
    

    Note 1: Replace ActionID with the action ID of the HTTP request action you copied earlier.

    Note 2: We used the function fix() to limit the number to 3 decimal places. You can see this and all functions here.

  3. Return to the actions menu and activate this action by clicking ✅ Activate.

Final result

  1. The user clicks the BTC Price button.
  2. The bot sends a GET request to the CoinMarketCap API.
  3. It receives a JSON response with Bitcoin’s price.
  4. It displays to the user something like:
    The current Bitcoin price is 104096.253 USD.
    

Important

VisualMaker already has an action to get the price of any cryptocurrency listed in the VisualMaker wallet, called Crypto price. Unless you need to retrieve the price of unlisted cryptocurrencies, using CoinMarketCap or similar services is unnecessary.