Overview

Serverless Functions allow your agents to execute custom code in the cloud without managing infrastructure. This powerful capability enables complex operations and integrations beyond what standard actions can provide.

Use Cases

  • Custom Logic Implementation: Execute specialized code for unique business requirements 

  • External System Integration: Connect with third-party services and APIs 

  • Advanced Data Processing: Perform complex calculations and transformations 

  • Extended Functionality: Add capabilities not available in standard Agent.ai actions

How Serverless Functions Work

Serverless Functions in Agent.ai:

  1. Run in AWS Lambda (fully managed by Agent.ai)

  2. Support Python and Node.js

  3. Automatically deploy when you save the action

  4. Generate a REST API endpoint for programmatic access

Creating a Serverless Function

  1. In the Actions tab, click “Add action”

  2. Select the “Advanced” category

  3. Choose “Call Serverless Function”

Configuration Fields

Language

  • Description: Select the programming language for the serverless function.

  • Options: Python, Node

  • Required: Yes

Serverless Code

  • Description: Write your custom code.

  • Example: Python or Node script performing custom logic.

  • Required: Yes

Serverless API URL

  • Description: Provide the API URL for the deployed serverless function.

  • Required: Yes (auto-generated upon deployment)

Output Variable Name

  • Description: Assign a variable name to store the result of the serverless function.

  • Example: “function_result” or “api_response.”

  • Validation: Only letters, numbers, and underscores (_) are allowed.

  • Required: Yes

Deploy and Save

  1. Click “Deploy to AWS Lambda”

  2. After successful deployment, the API URL will be populated automatically

Using Function Results

The function’s output is stored in your specified variable name. You can access specific data points using dot notation, for example:

  • {{variable_name.message}}

  • {{variable_name.input}}

Example: Serverless Function Agent

See this simple Message Analysis Agent that demonstrates how to use Serverless Functions:

  1. Step 1: Get user input text message

  2. Step 2: Call a serverless function that analyzes:

    • Word count

    • Character count

    • Sentiment (positive/negative/neutral)

  3. Step 3: Display the results in a formatted output

This sample agent shows how Serverless Functions can extend your agent’s capabilities with custom logic that would be difficult to implement using standard actions alone.