- AI Agents
- Replay Failed Steps
- API App
- Schedule App
- Filter Versus Condition
- Filter App
- Delay App
- Branch App
- Email Parser
- Export/Import Workflows
- Hide OttoKit from WordPress
- Using Conditions
- Number Formatter
- Date/Time Formatter
- Trigger Button
- Path App
- Folders
- Organizations and Workspaces
- Human in the Loop
- Getting Started with Otto AI Agents: A Step-by-Step Workflow Example
- Automate Repetition with Precision: OttoKit Loop Integration
- How to Switch Organizations in OttoKit
- How to Invite Members to a Workspace in OttoKit
- How to Disconnect OttoKit from WordPress
- How to Delete a WordPress Connection in OttoKit
- Code by OttoKit (Python) – Complete User Guide
- Prerequisites
- Building an Integration
- Setting Up Authentication
- Setting Up Triggers & Actions
- Publishing Integration
- How To Authenticate Your Application Using The API Key Method
- How to Set-Up the Integration Based on Auth Type Bearer Token
- How To Authenticate Your Application Using OAuth 2.0
- How To Authenticate Your Application Using Basic Auth
- How To Authenticate Your Application Using The JWT Bearer Method
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 callsuuid
: Generate UUIDsdatetime
: Handle date and timerandom
: 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.
We don't respond to the article feedback, we use it to improve our support content.