Merlin Functions (Beta) connector

Add Custom Logic to Your Workflows with Merlin Functions

Run serverless custom functions inside your tray.ai automations without touching infrastructure.

What can you do with the Merlin Functions (Beta) connector?

Merlin Functions lets you run custom code and business logic inside your integration workflows, without giving up the speed of no-code automation. Need to transform a gnarly data structure, apply your own business rules, or call an internal API? You can do all of that natively in tray.ai, without duct-taping in a separate service. For teams that keep bumping against the limits of standard connectors, Merlin Functions is the escape hatch.

Automate & integrate Merlin Functions (Beta)

Automating Merlin Functions (Beta) business process or integrating Merlin Functions (Beta) data is made easy with tray.ai

Use case

Custom Data Transformation and Enrichment

When data flowing between systems doesn't match the expected format, you can write and execute custom transformation logic on the fly. Parse complex JSON payloads, reformat date strings, normalize field naming conventions, or merge datasets from multiple sources — no clunky workarounds needed. Your downstream systems stay clean and consistent without a separate ETL tool.

Use case

Dynamic Business Rules Execution

Most organizations have business logic that's too context-sensitive for a standard connector — routing decisions, approval thresholds, pricing tiers, eligibility checks. You can encode these rules as executable functions that run in real time as part of an automated workflow, so your integration logic stays in sync with how your business actually works.

Use case

Internal API and Microservice Calls

Most enterprises have internal APIs or microservices that'll never get a dedicated tray.ai connector. Merlin Functions lets you write custom HTTP calls or SDK invocations to interact with these internal services, making them full participants in your automation workflows. No more waiting for a connector that may never come.

Use case

Advanced String and Text Processing

Workflows that handle unstructured text — parsing email bodies, extracting fields from documents, cleaning user-generated content — often need logic that standard string utilities can't touch. You can apply regex, NLP preprocessing, or custom parsing algorithms to text data mid-workflow, making it practical to work with unstructured information at scale.

Use case

Cryptographic Operations and Security Transformations

Sometimes a workflow needs to sign a payload, verify a webhook, hash a sensitive field, or encrypt data before it reaches a third-party service. Merlin Functions gives you an environment to run these cryptographic operations securely and programmatically, without routing data through an external service. For teams with real compliance obligations, that matters.

Use case

Custom Aggregation and Reporting Logic

Automated reporting pipelines often need to aggregate, group, or calculate metrics in ways that standard connectors don't support. You can implement custom aggregation logic, compute weighted averages, run statistical summaries, or build scoring models directly in the workflow before results go to a dashboard or database.

Use case

AI Agent Tool and Function Calling

When building AI agents in tray.ai, Merlin Functions can act as custom tools that agents invoke to perform specialized tasks, retrieve computed results, or interact with systems that don't have a native connector. Agents can run deterministic logic or call internal services as part of their decision-making, which makes them a lot more useful in practice.

Get started with our Merlin Functions (Beta) connector today

If you would like to get started with the tray.ai Merlin Functions (Beta) connector today then speak to one of our team.

Merlin Functions (Beta) Challenges

What challenges are there when working with Merlin Functions (Beta) and how will using Tray.ai help?

Challenge

Going Beyond Standard Connector Capabilities

No matter how many connectors a platform offers, your specific business logic, data format, or internal system will eventually fall outside what's available. Teams often end up building and maintaining separate microservices just to fill these gaps, which adds real operational overhead and something new to keep alive.

How Tray.ai Can Help:

Merlin Functions lets you embed custom executable logic directly into tray.ai workflows, so you're not spinning up external microservices or inventing workarounds. Developer-grade flexibility lives in the same platform as your automations.

Challenge

Maintaining Security During Data Transformation

When sensitive data — PII, financial records, credentials — flows through integration pipelines, applying encryption, hashing, or signing without routing it through additional external services is genuinely hard. Every extra service is another attack surface and another thing to audit.

How Tray.ai Can Help:

With Merlin Functions, cryptographic and security operations run as native workflow steps inside tray.ai. Sensitive data stays in a controlled, auditable environment without needing an external service to handle security transformations.

Challenge

Keeping Business Logic in Sync with Workflows

Business rules change constantly, but when that logic is hardcoded into workflow configurations, every rule change means a workflow update. That creates bottlenecks for non-technical teams and quietly introduces drift between what the business intends and what the automation actually does.

How Tray.ai Can Help:

Merlin Functions lets you encapsulate business logic as versioned, reusable functions that update independently of the workflow structure. Rule management and workflow design stop being tangled together.

Challenge

Integrating Proprietary Internal APIs Without a Dedicated Connector

Internal APIs, legacy systems, and custom microservices almost never have pre-built connectors on any integration platform. Development teams get pulled in to build and maintain custom connectors just to expose these internal capabilities — time-consuming work that's hard to justify and harder to maintain.

How Tray.ai Can Help:

Merlin Functions lets you write custom HTTP requests or SDK calls to internal APIs directly within a workflow step. Any internal service becomes workflow-accessible without the overhead of building and maintaining a full custom connector.

Challenge

Enabling AI Agents to Access Custom and Internal Systems

AI agents built on standard toolsets are limited to whatever connectors and actions the platform exposes natively. When an agent needs to run a calculation, call an internal API, or execute specialized logic, you hit a wall fast — and the options are usually "limit the agent" or "build complex external tooling."

How Tray.ai Can Help:

Merlin Functions plugs directly into tray.ai's AI agent framework as a callable tool, letting agents invoke custom code for computations, internal API calls, or data enrichment. Agents get significantly more capable without requiring external infrastructure.

Talk to our team to learn how to connect Merlin Functions (Beta) with your stack

Find the tray.ai connector with one of the 700+ other connectors in the tray.ai connector library to integrate your stack.

Start using our pre-built Merlin Functions (Beta) templates today

Start from scratch or use one of our pre-built Merlin Functions (Beta) templates to quickly solve your most common use cases.

Merlin Functions (Beta) Templates

Find pre-built Merlin Functions (Beta) solutions for common use cases

Browse all templates

Template

Webhook Signature Verification and Routing

Automatically verify incoming webhook payloads using a custom HMAC signature check in Merlin Functions, then route verified events to the correct downstream workflow or reject invalid ones.

Steps:

  • Receive incoming webhook payload via tray.ai webhook trigger
  • Pass payload and headers to Merlin Functions to perform HMAC signature validation
  • Route verified events to downstream processing or send alert to Slack for invalid signatures

Connectors Used: Merlin Functions (Beta), Webhook Trigger, Slack

Template

CRM Data Normalization Before Salesforce Sync

Run raw contact data from web forms or third-party sources through a Merlin Functions normalization step to standardize phone numbers, names, and addresses before creating or updating records in Salesforce.

Steps:

  • Trigger on new form submission or CRM event from HubSpot
  • Pass raw contact fields to Merlin Functions to apply normalization and deduplication logic
  • Create or update the normalized contact record in Salesforce

Connectors Used: Merlin Functions (Beta), Salesforce, HubSpot

Template

AI Agent with Custom Internal API Tool

Build an AI agent that uses Merlin Functions as a callable tool to query an internal inventory or pricing API, so the agent can answer questions or make decisions based on real-time internal data.

Steps:

  • AI agent receives a user query via Slack or another interface
  • Agent invokes Merlin Functions tool to call the internal pricing or inventory API and return structured results
  • Agent uses the function output to generate a response and reply to the user

Connectors Used: Merlin Functions (Beta), tray.ai AI Agent, Slack

Template

Automated Report Generation with Custom Metrics

Pull raw activity data from multiple sources, compute custom business metrics using Merlin Functions, and automatically deliver a formatted report to a Google Sheet or email distribution list.

Steps:

  • Scheduled trigger pulls raw data from source systems such as a database or CRM
  • Merlin Functions aggregates and computes custom KPIs, weighted scores, or trend calculations
  • Results are written to Google Sheets and a summary email is sent via SendGrid

Connectors Used: Merlin Functions (Beta), Google Sheets, SendGrid

Template

Sensitive Field Encryption Before Database Write

Intercept records containing personally identifiable information, apply field-level encryption using Merlin Functions, and write only the encrypted values to a downstream database or data warehouse.

Steps:

  • Trigger on new record creation or data pipeline event
  • Pass sensitive fields such as SSN, email, or financial data to Merlin Functions for encryption
  • Write encrypted values to PostgreSQL and store an audit log in AWS S3

Connectors Used: Merlin Functions (Beta), PostgreSQL, AWS S3

Template

Text Extraction and NLP Preprocessing for AI Pipelines

Process incoming documents or email bodies through Merlin Functions to extract structured fields, clean text, and prepare it for downstream AI enrichment or classification workflows.

Steps:

  • Trigger on new incoming email in Gmail matching specific criteria
  • Pass email body to Merlin Functions for regex extraction, cleaning, and structured field parsing
  • Send preprocessed text to OpenAI for classification or summarization and store results

Connectors Used: Merlin Functions (Beta), Gmail, OpenAI