user-robotAutomation Code Steps

circle-check

Overview

Code steps provide powerful, secure, and flexible scripting to Kizen Automations using Python. Code Steps natively integrate with automation variables and field values from your custom object entities. All code runs in an isolated container.

Available Runtimes

  • Python 3.12

  • Python 3.13

In addition to packages included in the Python Standard Library, the following packages come pre-installed:

  • awslambdaric

  • bcrypt

  • lxml

  • msgpack

  • numpy

  • paramiko

  • pytz

  • requests

  • pyjwt

  • tzdata

  • pypdf

circle-info

Note: If you have a library you would like for us to consider adding, send us a note at [email protected].

Limits

  • 1 GB RAM

  • 30 sec execution time

For more information see, Log Message Limits.


Using Inputs and Generating Outputs

Your python code will access input data in an object named inputs and write to an object named outputs. The names of the attributes are set when you select inputs and outputs in your Kizen Automation.

This example assumes an input called “name” and an output called “greeting”


Logging

You may write logs using the provided outputs.log() function.

Example:

To view these logs:

1. Open the Automation History, for example by navigating to entity record you’ve run this automation on, and clicking the “Automation Name” for an execution in the list.

  1. Then — in the Automation History view — click the Execution Status in Code Step Action (the word “Completed” in the screenshot):

  1. You will see your Execution details, including any logs you’ve written:

Log Message Limits

Each call to output.logs() supports a maximum message size of 8 KB. Messages that exceed this limit are truncated.

In addition, the combined size of all log messages generated during a single code step execution is limited to 100 KB. Once this limit is reached, any additional log messages are discarded.

To avoid losing diagnostic information:

  • Keep log messages short and focused

  • Avoid logging large data structures or verbose output, especially inside loops

  • For larger content, write values to fields or upload files, which support larger data sizes


Validating Inputs and Raising Errors

You can raise an Exceptionarrow-up-right to immediately stop execution of your Python code due to invalid data or other unexpected cases.

This error will be visible in the Execution details:

A successful execution will show the inputs, outputs, and logs (more detail on the encoding of inputs and outputs later in this document):


Making HTTP Requests

The ability to send HTTP requests enables powerful, flexible integrations.

Integration Secrets

You may also configure your Code Step with access to use Integration Secrets.

HTTP Request Logs

In addition to messages you log directly in your code, HTTP requests are logged automatically.

In your HTTP request logs you’ll find:

  • Total number of HTTP requests sent

  • Detailed logs of the first 100 requests sent:

    • HTTP Method

    • URL

    • Request and Response Headers

    • Request Body (truncated to the first 1 kB)

  • Number of requests sent without capturing detailed logs (due to exceeding the 100-request threshold)

This info will appear in the Execution Details:


Kizen Data Types and Data Encoding

When you view the Automation History for a Code Step, or use the Immediate/sync API for CodeRunner you will see your Kizen values encoded as JSON using the following scheme:

Boolean

b

Date

d

DateTime

dt

Number

n

Phone Number

p

String

s

UUID

u

Entity Record

e<uuid>

The UUID in the type code indicates which Custom Object the entity is part of.

Field Option

o<uuid,uuid>

The first UUID in the type code is the Custom Object id, the second UUID is the Field id.

Array (typed)

a[...]

List (untyped)

l

Note: Values are individually encoded, may be an empty list, and may be null.

File

a["f"]

Note: The value will be a valid file ID.

Last updated

Was this helpful?