Python programming
The builder supports running Python source code, allowing you to create bots with any logic you need. This article explains how to connect source code to your bot.
Last updated
The builder supports running Python source code, allowing you to create bots with any logic you need. This article explains how to connect source code to your bot.
To run a source code (.py extension) the function code_executor(URL, params) is used, where
URL - the url to the source code (“https://mavibot.ai/handler.py” as an example)
params - the parameters that are needed for your code (they come as a JSON line)
The returned value is what the function returns
Example:
If you need to send API requests from a Russian IP address, we recommend using the Salebot proxy.
Example:
requests.get('https://google.com', proxies={'https': 'http://51.250.88.121:24532'}).text
139.59.148.123 — Python code executor
Requirements for the source code:
Your code must include a handle(data) function that accepts a parameter containing a hash of the parameters you specified in the block settings. The function must return a value that will be passed back to the bot after execution. To split the result into the editor’s parameters, return it as JSON.
An example code you can see here: https://mavibot.ai/handler.py
You can use standard libraries, as well as those listed below:
requests logger gspread oauth2client numpy pyzbar fuzzywuzzy python-Levenshtein re urllib time json hmac hashlib beautifulsoup4 pandas base64 xmltodict mysql-connector-python zeep Google-api-python-client
Last updated