Instruction on Function Calling in AI Assistants on the Leeloo.AI Platform
- 1 1. Introduction
- 2 2. How It Works
- 3 3. Adding a Function to AI Assistant
- 4 4. Available Functions
- 4.1 ✅ START_TUNNEL — Subscribe to a funnel block
- 4.2 ✅ ADD_TAG — Add a tag
- 4.3 ✅ REMOVE_TAG — Remove a tag
- 4.4 ✅ ADD_CUSTOM_FIELD — Add a custom field
- 4.5 ✅ ADD_TO_SALES_PLAN — Add to Sales Plan
- 4.6 ✅ REMOVE_FROM_SALES_PLAN — Remove from Sales Plan
- 4.7 ✅ MOVE_SALES_PLAN_DEAL — Move deal
- 4.8 ✅ NOTIFY_USER_IN_CHAT — Notify a team member
- 4.9 ✅ MARK_AS_UNREAD — Mark message as unread
- 4.10 ✅ CHANGE_AI_SETTINGS — Control AI Assistant
- 5 5. Testing and Verifying the Function
1. Introduction
A function is a predefined action that an AI Assistant can execute for a subscriber on the Leeloo.AI platform, based on certain conditions in a conversation. These conditions are defined in the AI Assistant's instructions.
With functions, the AI Assistant can:
Issue invoices — automate payments and accelerate the customer journey.
Add tags and custom fields — create precise segments for personalized offers.
Manage AI Assistant activity — flexibly start, stop, or restart the assistant as business goals change.
Subscribe or unsubscribe users from funnel blocks — guide users to the right content and increase conversions.
Work with the Sales Plan (CRM) — create, move, or delete deals without a manager’s involvement.
Mark messages as unread — enhance team awareness and response speed to important messages.
2. How It Works
AI Assistants interact with users via messengers (Telegram, WhatsApp, Facebook Messenger, etc.) and can perform actions within the Leeloo.AI platform — for example, subscribing a lead to a funnel block based on set conditions.
Process:
Scenarios and triggers are defined for the AI Assistant.
The AI Assistant is connected to chats via a sales tunnel, through bulk audience actions or manually in the "Chats" section.
The user sends a message to the chat where the AI Assistant is enabled.
The assistant analyzes the message and determines the user’s intent.
If the condition matches a defined scenario, the AI Assistant calls a function.
The function is executed — performing a corresponding action on the Leeloo.AI platform.
The user receives an offer, buttons, tags, or other interactions (e.g., connect with a manager, purchase a product, etc.).
3. Adding a Function to AI Assistant
To add a function to AI Assistant:
Go to the Assistants section on the OpenAI platform and create or select an existing AI Assistant.
Navigate to the System instructions section of your AI Assistant.
Add a condition to the base instruction or a condition file specifying when the assistant should call the function. Example:
"If the client asks about membership, provide information about membership and then activate the function (START_TUNNEL)"
In the Functions section of your assistant, enter the function execution command (START_TUNNEL).
Insert the JSON code of the function and specify tunnel_block_id in the description of your function.
Now, the AI Assistant will analyze client dialogues and, based on their messages, execute the appropriate actions on the platform.
You can also write in the description of your function, which allows you to sign leads on several different blocks in the sales tunnel, for one additional function.
4. Available Functions
✅ START_TUNNEL — Subscribe to a funnel block
In the JSON code, in the "description" field where you specify the function's operation conditions, you need to insert the block ID to which the lead will be subscribed. You can obtain the ID by navigating to the "Sales Tunnels" section, entering the desired sales funnel, clicking on the blue block to which the subscription will be applied, and copying the block ID from the URL in the browser's address bar.
✅ STOP_TUNNEL — Stop funnel content
Subscribes the user to a specific funnel block. The block ID is set in the description.
Stops sending messages after a specific block.
✅ ADD_TAG — Add a tag
Adds a tag to the user. If the tag doesn't exist, it will be created.
In the "description" field, specify which tag to add.
For example, set the condition within the AI Assistant instruction: "Call the ADD_TAG function if...".
The function will create the tag "CONSULTATION" if it is not already in your list of tags.
The tag will be added only to the user who is currently interacting with the AI Assistant.
✅ REMOVE_TAG — Remove a tag
Removes a specified tag from the user.
In the "description" field, specify which tag to remove.
The tag will be deleted only for the user who is currently interacting with the AI Assistant.
✅ ADD_CUSTOM_FIELD — Add a custom field
Adds or updates a custom field (e.g., phone number, client type).
✅ ADD_TO_SALES_PLAN — Add to Sales Plan
Creates a deal for the user in the specified sales plan.
Adds a user to the Sales Plan after specifying the Sales Plan ID.
To obtain the Sales Plan ID, go to the CRM section, navigate to the sales plan where you want to add the subscriber, and copy the link from the browser's address bar.
✅ REMOVE_FROM_SALES_PLAN — Remove from Sales Plan
Removes the user’s deal from the selected sales plan.
✅ MOVE_SALES_PLAN_DEAL — Move deal
Moves a deal to another status within a sales plan.
Moves a deal from one status (current) to another specified in the "description" field.
Specify the Sales Plan ID where the deal status will be changed.
Specify the name or ID of the status to which the deal should be moved.
✅ NOTIFY_USER_IN_CHAT — Notify a team member
Sends an internal message to a platform user (via email) in chat.
User notification in chat.
In the "description" field, specify the email of the Leeloo.AI platform user whom the AI Assistant will notify in the chat.
✅ MARK_AS_UNREAD — Mark message as unread
Marks the user’s last message as unread.
✅ CHANGE_AI_SETTINGS — Control AI Assistant
Starts, stops, or restarts the AI Assistant in the user’s chat. Uses commands: START, STOP, RESTART, and the assistant’s ID.
Managing the AI Assistant status for a lead in the Leeloo.AI chat.
Specify one of the actions: START, STOP, RESTART – it must be in English and in uppercase letters.
In the "description" field, specify the status to which the AI Assistant should be switched in the chat with the lead.
In the "enum" field, specify the ID of the AI Assistant that you are starting, stopping, or restarting.
IMPORTANT!
IMPORTANT:
The
function_namemust match exactly (e.g.,START_TUNNEL,ADD_TAG,REMOVE_TAG, etc.).The
descriptionfield is the only editable field where you specify the action logic and IDs.
5. Testing and Verifying the Function
After setting up the assistant:
Activate the AI Assistant for the selected communication channel.
Send a test message that matches the trigger condition in the chatbot (communication channel).
Ensure the function executed successfully. You can check this by looking at the lead's status in the chat.
If errors occur, verify that the function parameters and call conditions are correctly configured.
Make necessary adjustments to the assistant's instructions if required.