# Merlin Functions (Beta) integrations

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

**Canonical page:** https://tray.ai/connectors/merlin-functions-beta-integrations/
**Categories:** General automation services, Databases
**Documentation:** https://tray.ai/documentation/connectors/artificial-intelligence/merlin-functions-beta

## Overview

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.

## Use cases

### 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.

- Eliminate manual data reformatting between incompatible systems
- Apply proprietary normalization rules not supported by standard connectors
- Process nested or complex data structures with full programmatic control

### 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.

- Encode custom eligibility, routing, or scoring logic directly in workflows
- Update business rules independently of workflow structure
- Support conditional branching based on multi-variable calculations

### 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.

- Integrate proprietary internal APIs without building a custom connector
- Access internal microservices as workflow steps
- Authenticate and interact with legacy systems using custom code

### 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.

- Apply regex and custom parsing to extract structured data from text
- Preprocess text for downstream AI or NLP workflows
- Sanitize and validate user-generated content before storage

### 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.

- Sign and verify webhook payloads using HMAC or other algorithms
- Hash or encrypt sensitive fields before storing or transmitting data
- Perform token generation and validation within secure workflow steps

### 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.

- Compute custom KPIs and metrics not available in standard connectors
- Aggregate and group large datasets before writing to reporting destinations
- Build reusable scoring or ranking functions across multiple workflows

### 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.

- Expose custom functions as callable tools for AI agents
- Give agents access to internal data sources and computations
- Combine deterministic function logic with AI-driven orchestration

## Templates

### 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.

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

### 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.

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

### 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.

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

### 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.

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

### 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.

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

### 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.

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

## Challenges Tray.ai solves

### 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 helps:** 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.

### 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 helps:** 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.

### 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 helps:** 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.

### 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 helps:** 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.

### 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 helps:** 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.

## Learn more

- Intelligent Integration: https://tray.ai/platform/intelligent-ipaas/
- Merlin Agent Builder: https://tray.ai/platform/merlin-agent-builder/
- Agent Gateway for MCP: https://tray.ai/platform/agent-gateway/
- Book a demo: https://tray.ai/contact/
