AI functions for beginners

Functions are powerful tools that enable your AI to perform specific tasks. These tasks can range from processing user information, making decisions, switching between different conversational tasks, or even retrieving data through API calls. Functions are often linked to various elements of your AI, such as messages, forms, director conditions, and prompts, allowing for highly interactive and dynamic user experiences.

How to Set Up a New Function

Navigate to Functions Section

In your MagicBlocks workspace, go to Library > Functions section where you can create new functions for your AI agent.12

Create a New Function3

Click on the Create New button to start setting up a new function.

Step-by-Step: Configuring Function Settings

1. General Settings4

Name of Function: Provide a clear and descriptive name for the function. This name will help you identify the function’s purpose within the AI Agent.

AI Instruction: Enter specific instructions that the AI should follow when using this function. This helps the AI understand the function's role in the conversation.

Tags: Add tags to categorize the function, making it easier to find in the future.

2. API URL (if applicable)5

Enter API URL: If the function needs to communicate with an external service, enter the API endpoint URL here.

HTTP Method: Choose the HTTP method (e.g., POST, GET) based on the requirement of the API.

Headers: Add any necessary headers. For instance, if the API requires authentication, include a header key like Authorization and add the token as the header value.

Security Note: Once saved, header values will be encrypted for security.

3. Function Parameters67

Parameter Name: Specify each parameter that the function will need. This could include details the AI will need to pass to the API or process internally.

Parameter Type: Define the type of data (e.g., string, number, boolean) the parameter will accept.

Option Values (optional): If applicable, provide predefined options for the parameter. This is useful when parameters have fixed possible values.

AI Instructions for Parameters: Give the AI clear instructions on how to use each parameter in context.

 

Example: Using Functions to Guide Conversations

Let’s say you’re creating a function for a Lead Qualification Bot to qualify potential customers. You can create a function that:

Checks if a user meets specific criteria (like their location or interest in a particular product).

Calls an API to fetch more detailed data about the user if necessary.

Determines the next best step based on the user's responses (like scheduling a call or sending them an informational brochure).

Sample Function Setup

Function Name: Qualify_Lead

AI Instruction: “Verify if the user meets lead qualification criteria, then retrieve additional user data if required.”

API URL: https://api.yourcrm.com/qualify

Headers:

Authorization: Bearer YOUR_API_KEY

Function Parameters:

User Location (String): Determine if the user is in a target region.

Interest Level (Number): Rate the user’s interest on a scale of 1-5.

By creating and using functions, you’ll add a layer of depth and interactivity to your AI, enabling it to perform complex tasks and offer tailored responses based on user interactions.

Functions act as a bridge between different parts of the AI Agent, allowing for dynamic adjustments and more precise user engagement.

Was this article helpful?