Insights & updates from our experts
Overview
Runs a user-supplied Ruby script inside a sandbox. The script is validated against an allowlist of methods, and of the classes it may name, before execution. This connector does not execute arbitrary Ruby, and eval, system, exec, require, instance_eval, direct instance / global variables, and method / constant definitions are all rejected. Use it for in-runbook data transformation, validation, and small computations that don't justify a dedicated connector.
Prerequisites
- Familiarity with Ruby syntax and with the allowed methods listed under the Evaluate Ruby Code action.
- Knowledge of the Ruby 3.4 standard library and the ActiveSupport 8.1 core extensions the allowlist draws from.
Authentication
None. This connector runs entirely in-process and requires no credentials.
Triggers
None. This connector is outbound only.
Actions
Evaluate Ruby Code
Runs a Ruby script with caller-defined input and output schemas. Values assigned to output[:field] inside the script are returned under results.
Use case: reshape data between actions, derive computed fields, validate an invariant and fail the job on breach, format timestamps or sizes, or decrypt secret inputs before passing them to a later step.
Input Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| input_schema | SchemaField[] | No | [] |
Field definitions for the script's inputs. Each entry has id, label, type (string, integer, secret_string, …), required |
| output_schema | SchemaField[] | No | [] |
Field definitions for the values returned under results. The runtime validates types and required fields after execution |
| input | Nested | Conditional | n/a | Values that match input_schema. Required when any input_schema entry has required: true |
| proc | Ruby | Yes | n/a | Ruby script to execute. Access inputs via input[:key] (or input['key']) and return data via output[:key] = value |
Example Input
{
"input_schema": [
{ "id": "i", "label": "Number", "type": "integer", "required": true },
{ "id": "a", "label": "First string", "type": "string", "required": true },
{ "id": "b", "label": "Second string", "type": "string", "required": true }
],
"output_schema": [
{ "id": "greeting", "label": "Greeting", "type": "string", "required": true }
],
"input": { "i": 4, "a": "hello", "b": "world" },
"proc": "if input['i'] > 3\n output['greeting'] = input['a'] + ' moon'\nelse\n output['greeting'] = 'bye ' + input['b']\nend"
}
Output
| Field Name | Type | Description |
|---|---|---|
results |
Nested | Hash populated by the script. See Results object fields below |
Results object fields
Fields are defined by output_schema. The runtime enforces the declared types and required flags; wrong types or missing required fields fail the job with Nested field 'results' invalid: ….
Example Output
{
"results": { "greeting": "hello moon" }
}
Allowed Ruby methods
Every method call in the script is validated against the allowlist before execution. The groups below sample the most frequently used methods per category; they are not the complete list.
| Category | Representative methods |
|---|---|
| Base / comparison | present?, blank?, nil?, presence, is_a?, tap, itself, to_json, pretty_generate, raise, Float, lambda, call, ==, !=, <, <=, >, >=, ! |
| Strings | split, gsub, sub, tr, strip, lstrip, rstrip, match, match?, captures, start_with?, end_with?, index, reverse, downcase, upcase, capitalize, swapcase, titleize, camelcase, underscore, strftime, to_i, to_f, to_sym, bytesize |
| Numbers | +, -, *, /, %, **, to_s, to_i, to_f, abs, ceil, times, durations (seconds, minutes, hours, days, weeks, fortnights), byte helpers (bytes, kilobytes, megabytes, gigabytes, terabytes, …), number_to_human_size |
| Hashes | [], []=, dig, drill, fetch, key?, delete, except, slice, merge, reduce, keys, values, each_value, transform_keys, transform_values, with_indifferent_access, deep_dup, to_a |
| Arrays | [], <<, push, length, size, first, last, include?, exclude?, each, each_with_index, each_with_object, each_slice, map, flat_map, filter, filter_map, select, reject, detect, reduce, sum, min, max, sort, sort_by, group_by, index_by, pluck, pick, uniq, compact, compact_blank, flatten, zip, take, to_h, to_set, any?, all?, none? |
| Time | Time.now, Time.current, Time.parse, utc, to_datetime, iso8601, zone, ago, at |
| Encoding & hashing | JSON.parse, Base64.strict_encode64, Base64.encode64, URI.encode_www_form, Digest::SHA256.hexdigest, OpenSSL::HMAC.hexdigest, SecureRandom.uuid (see Allowed classes below) |
| XML | text, at_xpath |
Calling anything outside the allowlist (including eval, system, exec, require, instance_eval, sleep, method / constant definitions, direct instance / class / global variables) is rejected at validation time with Method '<name>' not allowed.. The alias, undef, BEGIN and END keywords are rejected with 'alias' not allowed., 'undef' not allowed., 'BEGIN' not allowed. and 'END' not allowed..
to_json takes no arguments: call it bare (value.to_json). Passing options or a block, or :to_json as a symbol (&:to_json, reduce(:to_json)), is rejected with 'to_json' takes no arguments and cannot be passed as a symbol.; write map { |v| v.to_json } instead of map(&:to_json).
Allowed classes
A script may name only an approved class or module, matched by exact name (for example Time, Date, JSON, URI, Base64, SecureRandom, Digest::SHA256, OpenSSL::HMAC, StandardError, ArgumentError), and may call only the approved methods on each (JSON.parse, Time.now, Base64.encode64, …). A class may otherwise appear only where the construct consumes it: a rescue list, a when condition, a pattern match, or an argument to raise, is_a?, kind_of? or instance_of?. It may not be assigned to a variable, placed in a literal or passed to anything else. If you need a class or method that isn't allowed, please file a request.
Available iPaaS helpers
In addition to the allowed Ruby methods, the platform provides the helpers below.
Runbook-native (common)
| Helper | Purpose |
|---|---|
log(message) |
Emit a log line on the runbook run |
fail_job!(message) |
Fail the action with a custom message. Prefer this over raise |
finish_job!(message) |
Early exit: complete the job before the end of the runbook, skipping subsequent actions. The message is optional |
backoff(message, retry_after:) |
Pause the action and let the runbook runner run it again after retry_after (default: 1 minute). Both arguments are optional |
input |
The values mapped into this action's input field, with indifferent access |
job_context_identifier, job_context_identifier= |
Read / set the run's identifier, which you can use to filter jobs |
Secrets
| Helper | Purpose |
|---|---|
decrypt_secret_string(value) |
Decrypt a secret_string input into a plain string |
make_secret_string(value), new_secret_string(value) |
Wrap a plain value as a secret. Use when writing a secret_string output |
Data & name helpers
| Helper | Purpose |
|---|---|
compact_hash(hash) |
Remove nil / blank values from a hash |
camel_to_snake(string) |
Convert camelCase → snake_case |
humanize_field_name(string) |
Humanise a schema field name |
keys_to_field_id(hash) |
Convert keys to field-id form |
detect_content_type |
Detect a response's content type |
parse_json_response(body) |
Parse a JSON response body into a hash or array. Fails the job when the body is not valid JSON |
parse_xml_response(body) |
Parse an XML response body into a document with namespaces removed. Read values out of it with at_xpath and text |
Advanced helpers: available, but prefer alternatives
Reading or updating runbook state from inside the script is possible, but hides dependencies. Prefer mapping values so the wiring is visible in the runbook.
| Helper | Purpose |
|---|---|
trigger_output |
Read the runbook's trigger output. Prefer an explicit input field |
action_output(ref) |
Read the output of another action in the same runbook, validated against existing references at save time. Prefer an explicit input field |
read_variable(name) |
Read a runbook variable. Prefer an explicit input field |
write_variable(name, value) |
Write a runbook variable. Prefer the 'Assign Runbook Variable' action |
environment['<uuid>'] |
Read an Environment Variable by its UUID. Prefer an explicit input field. See Using Environment Variables below |
Advanced helpers: primarily for connector authoring, available but not idiomatic here
| Helper | Purpose |
|---|---|
http_send(method, url, **options) |
Outbound HTTP request |
outbound_connection.store.read(key), outbound_connection.store.write(key, value) |
Persistent store shared by every Ruby action step wired to the same Ruby connection |
encode_jwt(payload, …), decode_jwt!(token, …) |
JWT encode / decode |
make_jwt_payload(…) |
Build a JWT payload |
pem_valid?(pem) |
Check PEM validity |
runbook |
The running runbook. Exposes runbook.uuid, runbook.account_id and runbook.read_variable(name) |
account_id |
Xurrent account the run belongs to |
Using Environment Variables
A Ruby script cannot look up an Environment Variable by name. Map it into the action as an input instead:
- In Input schema, add a field with the same type as the variable, for example
pool_id(String). For a Secret String variable, the field must be a Secret String; a String field is rejected withType of field '<x>' invalid, expected String found IPaaS::Encryption::SecretString. - Set Input values to Nested, switch the field to Variable mode and pick the Environment Variable.
- Read it in the script with
input['pool_id']. For a Secret String field, usedecrypt_secret_string(input['pool_id']).
This keeps the dependency visible in the runbook and shows the value used in each job execution.
In conditions and other Proc fields: the data pill picker does not list Environment Variables yet. In a Proc field, such as an If-then-else condition, reference a variable by the UUID shown on the variable's page:
environment['40a081ae-e99c-4e5a-84d3-717191803797'] == 'abc'
- A variable that isn't defined returns
nil. - Secret String values are returned encrypted, so compare
decrypt_secret_string(environment['<uuid>']). - Hashed Credential variables can't be compared or checked in a script or condition. They are meant for inbound OAuth2 client-credentials connections.
Error Handling
Errors surface before, during or after execution:
| Stage | Trigger | Message shape |
|---|---|---|
| Script validation (before execution) | Disallowed method call | Method '<name>' not allowed. |
| Script validation (before execution) | Class or module not on the approved list | Access to '<Name>' is not allowed in expressions; only an approved set of classes is available. Please file a request if access is needed. |
| Script validation (before execution) | Unapproved method on an approved class | Calling '<method>' on '<Name>' is not allowed in expressions; only approved methods of approved classes are available. Please file a request if access is needed. |
| Script validation (before execution) | Approved class used as a value (assigned, in a literal, passed on) | '<Name>' may only be called, rescued, raised or tested in expressions, not passed on as a value. |
| Script validation (before execution) | action_output('<ref>') references a step that doesn't exist |
(proc) invalid action references: '<ref>', … |
| Input validation (before execution) | input values don't match input_schema types / required flags |
Nested field 'input' invalid: Type of field '<x>' invalid, expected <T> found <U>. |
| Runtime | Any uncaught exception raised inside the script | The exception class and message propagate |
| Runtime | Intentional failure | Call fail_job!('<reason>'). Produces a clean error carrying that message |
| Runtime | Action runs longer than 90 seconds | Maximum time per action (90 seconds) exceeded. |
| Output validation (after execution) | results don't match output_schema types / required flags |
Output [] invalid: Nested field 'results' invalid: … |
Execution Limits
A Ruby action must complete within 90 seconds. An action that runs longer is stopped and the job fails with Maximum time per action (90 seconds) exceeded.
Best Practices
- Use the Ruby connector for glue logic only. Reshape data, validate invariants, compute derived fields. Anything that calls an external API belongs in a dedicated connector.
- Declare
input_schemaandoutput_schemaup front. The surrounding runbook editor uses them to validate wiring, and the runtime uses them to type-check at the boundaries. - Return data through
output[:field] = value. The script's return value is discarded. - Access inputs via
input[:key]orinput['key']. The hash iswith_indifferent_access. - Bring Environment Variables, trigger data and other actions' output in through input fields, so the wiring is visible in the runbook.
- Protect secrets: call
decrypt_secret_string(input[:x])only as late as needed and neverlog(...)a decrypted value; wrap outgoing secret values withmake_secret_string(value)when theoutput_schemadeclares asecret_stringfield. - Prefer
fail_job!('reason')overraisefor unrecoverable conditions. It produces a clean error on the job without a Ruby stack trace. - When the script needs to pause, call
backoffand let the runbook runner reschedule the action.sleepis not allowed. - If the validator rejects a method, pick an allowed alternative from the lists above.
- Keep scripts small. For logic that repeats across runbooks, add a dedicated connector action instead of pasting a large script into each runbook.
Common Use Cases
- Reshape action output: map another action's output, brought in through an input field, into a slimmer array of hashes before handing it to the next step.
- Custom validation: assert an invariant on upstream data (
fail_job!('no users found')) so the runbook stops before a destructive action. - Derived fields: compute a hash (
Digest::SHA256.hexdigest), build a query string (URI.encode_www_form), or normalise a timestamp (1.hour.ago.iso8601) for downstream actions. - Secret handling: call
decrypt_secret_string(input[:token]), use the plain value in a computed header, and surface the result as asecret_stringviamake_secret_string(...). - Human-readable formatting:
number_to_human_size(bytes)orstrftime('%Y-%m-%d')for values rendered in Xurrent records.



.webp)




























