Python programming

The editor supports Python coding. You can create a bot of any logic. The article explains how to connect the source code to the bot.

How to run a Python source code in Salebot.ai

To run a source code (.py extension) the function code_executor(URL, params) is used, where

URL - the url to the source code (“https://salebot.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:

Requirements for the source code:

There has to be the function handle(data) that hosts a parameter holding a hash of parameters that you put in the block’s settings. The function has to return the value that after the execution will be returned to the bot. To divide it into the editor’s parameters, you need to return JSON.

An example code you can see here: https://salebot.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

Video version of the article

Last updated