PROCESIO
OverviewPlatform ActionsIntegrations & DemosCustom ActionsDeveloper’s Guide

Ruby

The Ruby Action allows you to execute Ruby code directly inside your workflow.

Ruby Action

(Screenshot unavailable — image was removed from the original source.)

The Ruby Action allows you to execute Ruby code directly inside your workflow.

The code you write is executed as the body of a function, meaning:

  • You can use puts to print to standard output logs.
  • You can return simple values, arrays, objects, or complex structures.

Ruby Actions are ideal for data manipulation, HTTP calls, JSON/XML parsing, statistics, templating, and custom business logic.

Available Gems

The following gems are preinstalled and available:

Data manipulation

  • jmespath
  • jsonpath
  • nokogiri

HTTP client

  • httpx

Auth / tokens

  • jwt

Utilities

  • liquid
  • reverse_markdown
  • faker

Statistics

  • descriptive_statistics

You can freely require any of these gems inside the Ruby Action.


Usage Examples

Return a simple value

return "Hello from Ruby!"

Return a list

return [1, 2, 3, "abc"]

Return an object

return { success: true, message: "Done" }

Use standard output

puts "Debug message"
return "OK"

Raise error

raise "Something went wrong!"

HTTP Requests (HTTPX)

require "httpx"
require "json"

resp = HTTPX.get("https://httpbin.org/json")
raise "bad response" unless resp.status == 200

doc = JSON.parse(resp.to_s, symbolize_names: true)

return {
  ok: true,
  title: doc.dig(:slideshow, :title)
}

XML Parsing (Nokogiri)

require "nokogiri"

xml = "<root><x>1</x><x>2</x></root>"
doc = Nokogiri::XML(xml)

return doc.xpath("//x").map(&:text)

Extract values (JSONPath)

require "jsonpath"

doc = { "store" => { "book" => [ { "price" => 8.95 }, { "price" => 12.99 } ] } }
prices = JsonPath.new("$.store.book[*].price").on(doc)

return prices.max

Aggregate values (JSONPath)

require "json"
require "jsonpath"

doc = JSON.parse('{"store":{"book":[{"price":8.95},{"price":12.99},{"price":5.50}]}}')
prices = JsonPath.new("$..book[*].price").on(doc)

return {
  count: prices.size,
  min:   prices.min,
  max:   prices.max,
  sum:   prices.sum
}

String Templates (Liquid)

require "liquid"

tpl = Liquid::Template.parse("Hello, {{ user }}! You have {{ count }} new messages.")
output = tpl.render("user" => "Razvan", "count" => 3)

return output

HTML → Markdown (ReverseMarkdown)

require "reverse_markdown"

html = "<h1>Title</h1><p>Hello <strong>world</strong> &amp; <em>friends</em>.</p>"
md = ReverseMarkdown.convert(html)

return md

Statistics

require "descriptive_statistics"

arr = [1,2,2,3,5,8,13,21]

return({
  mean: arr.mean,
  median: arr.median,
  variance: arr.variance,
  stdev: arr.standard_deviation
})

JWT Tokens

require "jwt"

payload = { user: "razvan", exp: Time.now.to_i + 3600 }
secret  = "my-secret"

token = JWT.encode(payload, secret, "HS256")
decoded = JWT.decode(token, secret, true, { algorithm: "HS256" })

return {
  token: token,
  decoded: decoded
}

Faker – Random Test Data

require "faker"

return {
  name:  Faker::Name.name,
  email: Faker::Internet.email,
  city:  Faker::Address.city
}

JMESPath Example

require "jmespath"

data = {
  users: [
    { name: "John", age: 30 },
    { name: "Mike", age: 25 }
  ]
}

return JMESPath.search("users[?age > `26`].name", data)

Trim, normalize, and sanitize strings

text = "  Hello   World	 "
clean = text.strip.gsub(/\s+/, " ")

return clean

Remove nils and empty strings from arrays

arr = ["a", nil, "", "b", " ", "c"]

clean = arr.map { |x| x.to_s.strip }.reject(&:empty?)

return clean

Deep-clean a hash

def deep_clean(value)
  case value
  when Hash
    value
      .map { |k, v| [k, deep_clean(v)] }
      .to_h
      .reject { |_k, v| v.nil? || v == "" }
  when Array
    value.map { |v| deep_clean(v) }.reject { |v| v.nil? || v == "" }
  else
    value.is_a?(String) ? value.strip : value
  end
end

input = {
  name: " Razvan ",
  email: "",
  tags: ["  ruby ", nil, "  ", "ai"],
  details: { city: "  Bucharest ", postcode: nil }
}

return deep_clean(input)

Convert keys of a hash to snake_case

def snake_keys(obj)
  case obj
  when Hash
    obj.map do |k, v|
      new_key = k.to_s.gsub(/([A-Z])/, '_\1').downcase.sub(/^_/, '')
      [new_key, snake_keys(v)]
    end.to_h
  when Array
    obj.map { |v| snake_keys(v) }
  else
    obj
  end
end

input = {
  "FullName" => "Razvan",
  "UserID"   => 123,
  "Address"  => { "PostalCode" => "050000" }
}

return snake_keys(input)

Normalize numeric input

values = ["10", " 20.5 ", nil, "abc", 7]

clean = values.map do |v|
  Float(v) rescue nil
end.compact

return clean

Detect duplicates & uniques

arr = ["a", "b", "a", "c", "b"]

return {
  unique: arr.uniq,
  duplicates: arr.tally.select { |k,v| v > 1 }.keys
}

Best Practices

  • Always return the final output.
  • Prefer structured arrays and hashes.
  • Use puts for logging debug information.
  • Use the whitelisted gems listed above.

Available Ruby Gems - list

The following gems are preinstalled and can be used inside the Ruby Action.

Data Manipulation

GemVersion
jmespath1.6.2
jsonpath1.1.5
nokogiri1.18.9

HTTP Client

GemVersion
httpx1.3.1

Authentication / Tokens

GemVersion
jwt2.9.3

Utilities

GemVersion
hashdiff1.0.1
liquid5.5.1
reverse_markdown3.0.0
faker3.2.2

On this page