|
/ Documentation /Core Features/ Code by OttoKit (Python) – Complete User Guide

Code by OttoKit (Python) – Complete User Guide

Code by OttoKit allows you to embed and execute custom Python code within your workflow—unlocking powerful capabilities such as calculations, data transformation, API interactions, and more. This feature is ideal for users who want to add dynamic, logic-driven steps into their automation flows.

What Can You Achieve with Code by OttoKit?

OttoKit supports a safe and practical subset of Python that covers most common use cases in workflow automation.

Supported Python Features

Core Programming Concepts:
  • Variables, Loops (for, while)
  • Conditional Statements (if, elif, else)
  • Functions (including recursive functions)
Data Types:
  • Numbers: int, float
  • Text: str
  • Boolean: bool
  • Collections: list, dict, tuple, set
Safe Built-in Functions:
You can use essential Python functions like:
  • print(), len(), sum(), min(), max(), abs(), sorted()
  • map(), filter(), type(), etc.
Pre-Installed Modules:
OttoKit makes the following Python libraries available for use:
  • requests: Make API calls
  • uuid: Generate UUIDs
  • datetime: Handle date and time
  • random: Generate random numbers

Typical Use Cases

  • Data formatting & cleaning
  • Handling timestamps and date logic
  • API requests and response parsing
  • Mathematical or statistical computations
  • Creating or modifying JSON-like dictionaries
  • Custom business logic

What Is Not Allowed (For Security Reasons)

To maintain a secure and reliable platform, some Python capabilities are restricted.

Blocked Modules

You cannot import or use the following modules:

  • System & OS Access: os, sys, subprocess, shutil, socket, platform, multiprocessing, etc.
  • File Handling: Reading from or writing to files is not allowed.
  • Low-Level System Access: inspect, pickle, marshal, importlib, etc.
Attempting to use these may throw errors like:
ImportError: Import of 'os' is blocked for security reasons.

Important Note: Braces {} Are Stripped

Due to platform-level parsing rules, any content inside curly braces {} is automatically removed from your code. This affects syntax like f-strings and dictionary literals.

Problematic Example (won’t work)
name = "Alice"
print(f"Hello, {name}")  # This will break!

Safe & Recommended Alternatives

Use String Concatenation
first_name = "John"
last_name = "Doe"
print("Full Name:", first_name + " " + last_name)
Use %-Style String Formatting
name = "Alice"
age = 30
print("Name: %s, Age: %d" % (name, age))
Use dict() Instead of {} for Dictionaries
person = dict(name="Alice", age=30)
print("Name is:", person["name"])

Example Code Snippets

Here are some handy code snippets that you can use directly or adapt to your use case:

Basic Math
a = 10
b = 20
print("Sum is:", a + b)
Generate a UUID
import uuid
print("UUID:", str(uuid.uuid4()))
Make an API Request
import requests
res = requests.get("https://api.github.com")
print("GitHub Status:", res.status_code)
Recursive Function (Factorial)
def factorial(n):
    return 1 if n == 0 else n * factorial(n - 1)

print("Factorial of 5:", factorial(5))
Current Date & Time
from datetime import datetime
now = datetime.now()
print("Now:", now.strftime("%Y-%m-%d %H:%M:%S"))

Tips, Limits & Best Practices

  • Always use print() to return output—this is how results are shown in the OttoKit interface.
  • Avoid long-running loops or deep recursion to prevent timeouts or memory issues.
  • Output is limited to 5,000 characters—extra content is automatically truncated.
  • Stick to safe string formatting methods (like concatenation or %s) to bypass {} removal.

Final Thoughts

Code by OttoKit empowers you to enhance your workflows with real logic and customization, while keeping the platform safe and stable for everyone. With a little creativity, you can turn simple automations into powerful, intelligent workflows.

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page
Scroll to Top