Functions
Functions let your AI Agent perform actions — like sending leads to your CRM, fetching data from an API, or booking appointments. They bridge your AI’s logic with external tools, allowing it to not only respond but act.
The Functions page in MagicBlocks is where you define and manage all the actions your AI can perform.
Think of Functions as your AI’s “capabilities” — each one is a command your Agent can call when triggered by user intent or a journey block.
From here, you can:
- Create new functions that call APIs or trigger actions.
- Define parameters the AI can fill dynamically (like name, date, or email).
- Manage encryption, headers, and integrations securely.
You’ll find it under Library → Functions.
Step 1: Create a New Function
Click Create New on the Functions page to open the setup modal.
You’ll see three tabs on the left:
- General
- API Url
- Function Parameters
Each section defines a key part of how your Function works.
Step 2: Fill Out the “General” Section
This section sets the name, AI behavior, and tags for your function.
Fields:
Name of your function — A short, clear label (e.g., Send Lead to HubSpot, Check Order Status).
AI Instruction — This tells the AI when to use the function and how.
Example:
“Use this function when the user asks to submit a contact form or requests a callback.”
Tags — Optional. Helps organize or group functions for quick search.
Example:
Name of your function: “Send Lead to HubSpot”
AI Instruction: “Use this function to send collected user info (name, email, company) to our CRM.”
Once filled, click Next → API Url.
Step 3: Add Your API Endpoint
This is where you define the API your AI will call when the function runs.
Fields:
Field | Description |
|---|---|
Your URL | The endpoint your function will send data to. Example:
. |
Method (GET/POST/PUT/DELETE) | Choose based on your API’s purpose. |
Headers | Add any required API headers, like authentication keys or content type. |
You can click + Add Header to include multiple headers.
Each key-value pair will be encrypted after saving for security.
Example Header:
Key:
AuthorizationValue:
Bearer {{api_token}}Key:
Content-TypeValue:
application/json
You can also Test your connection here to ensure it’s valid before saving.
Step 4: Add Function Parameters
Parameters define the data the AI should collect or use when calling your function.
Each parameter acts like a variable the AI fills in automatically from user input or context.
Fields:
Field | Description |
|---|---|
Parameter Name | The variable name (e.g.,
,
,
). |
Parameter Type | The data type (String, Number, Boolean, etc.). |
Required | Toggle this if the parameter must be provided before the function can run. |
Option Values (optional) | If the parameter is a dropdown or fixed choice (comma-separated). |
AI Instructions | Help the AI understand how to ask or interpret this data. |
Example:
Parameter Name | Type | Required | AI Instruction |
|---|---|---|---|
| String | ✅ | “Ask for the user’s email address.” |
| String | ⛔️ | “Ask which product they’re referring to if not already known.” |
You can click + Add Parameter to define multiple values (e.g., name, phone, company, message).
Step 5: Save & Test
Once all sections are complete:
Click Create.
The function will appear in your Function list as Unused until it’s linked to an Agent or workflow.
Test it by connecting it to a Block in an Agent journey.
Step 6: Connect Your Function to an Agent
To make the function usable in a conversation:
Go to Agents → Journey.
Select a Block (e.g., Form Completed, Confirmation Step).
Under Actions, choose Call Function.
Pick your newly created function from the list.
Your AI will now automatically trigger the function when that block runs.
Example Use Cases
Use Case | Function Example | Description |
|---|---|---|
Data Lookup |
| Queries backend for order tracking info. |
Notifications |
| Alerts your team in Slack when a goal is reached. |
Automation |
| Passes data into a connected Zap for workflow automation. |
Best Practices
- Name clearly: Use action-based names (e.g., “Submit Contact Form”).
- Test frequently: Always test endpoints before publishing.
- Re-use Functions: One Function can serve multiple Agents.
- Secure credentials: Use headers for sensitive data (API keys, tokens).
- Tag functions: Helps organize by project, integration, or client.
- Write precise AI instructions: Guide the AI when to call this function to avoid misuse.
Related Articles
API Tokens – Secure Your Integrations