Instruction on Function Calling in AI Assistants on the Leeloo.AI Platform

Instruction on Function Calling in AI Assistants on the Leeloo.AI Platform

UA

image-20240611-123449.png

US

image-20240611-123805.png

RU

image-20240611-131051.png

UA

image-20240611-123449.png

US

image-20240611-123805.png

RU

image-20240611-131051.png

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:

  1. Scenarios and triggers are defined for the AI Assistant.

  2. The AI Assistant is connected to chats via a sales tunnel, through bulk audience actions or manually in the "Chats" section.

  3. The user sends a message to the chat where the AI Assistant is enabled.

  4. The assistant analyzes the message and determines the user’s intent.

  5. If the condition matches a defined scenario, the AI Assistant calls a function.

  6. The function is executed — performing a corresponding action on the Leeloo.AI platform.

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

  1. Go to the Assistants section on the OpenAI platform and create or select an existing AI Assistant.

    ksnip_20250226-144939.png
  2. Navigate to the System instructions section of your AI Assistant.

    ksnip_20250226-145046-20250226-125046.png
  3. 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)"

    ksnip_20250228-162250.png

     

  4. In the Functions section of your assistant, enter the function execution command (START_TUNNEL).

    ksnip_20250228-160846.png

     

     

  5. Insert the JSON code of the function and specify tunnel_block_id in the description of your function.

    ksnip_20250228-161111.png

     

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.

image-20250227-081400.png

4. Available Functions

START_TUNNEL — Subscribe to a funnel block

{ "name": "START_TUNNEL", "description": "Subscribe user to a tunnel block 67923e109cf6cf5c3ca547c3", "strict": true, "parameters": { "type": "object", "properties": { "tunnel_block_id": { "type": "string", "description": "Id in description" } }, "required": [ "tunnel_block_id" ], "additionalProperties": false } }

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.

ksnip_20250428-153614-20250428-123614.png

 

STOP_TUNNEL — Stop funnel content

Subscribes the user to a specific funnel block. The block ID is set in the description.

{ "name": "STOP_TUNNEL", "description": "Stop sending to user from one of 679a7d8dc43c5ad7e43facc0", "strict": true, "parameters": { "type": "object", "properties": { "tunnel_block_id": { "type": "string", "description": "One of ids listed in description" } }, "required": ["tunnel_block_id"], "additionalProperties": false } }

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.

{ "name": "ADD_TAG", "description": "Add tag to user...", "strict": true, "parameters": { "type": "object", "properties": { "tag_name": { "type": "string", "description": "Some word that describe the user" } }, "required": ["tag_name"], "additionalProperties": false } }

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.

{ "name": "REMOVE_TAG", "description": "Remove tag from user", "strict": true, "parameters": { "type": "object", "properties": { "tag_name": { "type": "string", "description": "Some word" } }, "required": ["tag_name"], "additionalProperties": false } }

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

{ "name": "ADD_CUSTOM_FIELD", "description": "Add field to user", "strict": true, "parameters": { "type": "object", "properties": { "field_name": { "type": "string", "description": "Name of field to add" }, "field_value": { "type": "string", "description": "Value of field" } }, "required": ["field_name", "field_value"], "additionalProperties": false } }

 

ADD_TO_SALES_PLAN — Add to Sales Plan

Creates a deal for the user in the specified sales plan.

{ "name": "ADD_TO_SALES_PLAN", "description": "Add user to one of 647732ddd51d2a81a61be394, without_duplication = true", "strict": true, "parameters": { "type": "object", "properties": { "sales_plan_id": { "type": "string", "description": "One of ids listed in description" }, "sales_plan_status": { "type": "string", "description": "Name or id of status listed in description or may be empty" }, "user_email": { "type": "string", "description": "One of emails listed in description or may be empty" }, "without_duplication": { "type": "boolean" } }, "required": [ "sales_plan_id", "sales_plan_status", "user_email", "without_duplication" ], "additionalProperties": false } }

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.

ksnip_20250428-155007-20250428-125007.png

 

REMOVE_FROM_SALES_PLAN — Remove from Sales Plan

Removes the user’s deal from the selected sales plan.

{ "name": "REMOVE_FROM_SALES_PLAN", "description": "Remove user from one of 679a7d8dc43c5ad7e43facc0", "strict": true, "parameters": { "type": "object", "properties": { "sales_plan_id": { "type": "string", "description": "One of ids listed in description" } }, "required": [ "sales_plan_id" ], "additionalProperties": false } }

 

MOVE_SALES_PLAN_DEAL — Move deal

Moves a deal to another status within a sales plan.

 

{ "name": "MOVE_SALES_PLAN_DEAL", "description": "Move user in Sales plan to status - Id", "strict": true, "parameters": { "type": "object", "properties": { "sales_plan_id": { "type": "string", "description": "Sales plan id is 682b235dbb1982bebd204asd" }, "sales_plan_status": { "type": "string", "description": "Status name is - Kval id - 625b2525dbb1982bebd204asd" } }, "required": [ "sales_plan_id", "sales_plan_status" ], "additionalProperties": false } }

Moves a deal from one status (current) to another specified in the "description" field.

  1. Specify the Sales Plan ID where the deal status will be changed.

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

{ "name": "NOTIFY_USER_IN_CHAT", "description": "Notify one of kaliukh.w.o.r.k@gmail.com", "strict": true, "parameters": { "type": "object", "properties": { "user_email": { "type": "string", "description": "One of emails listed in description" }, "comment_text": { "type": "string", "description": "Some information that describes reason of notification (may be empty)" } }, "required": [ "user_email", "comment_text" ], "additionalProperties": false } }

 

MARK_AS_UNREAD — Mark message as unread

Marks the user’s last message as unread.

 

{ "name": "MARK_AS_UNREAD", "description": "Mark last message of user as unread", "strict": true, "parameters": { "type": "object", "properties": {}, "required": [], "additionalProperties": false } }

 

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.

{ "name": "CHANGE_AI_SETTINGS", "description": "Change ai assistant settings RESTART", "strict": true, "parameters": { "type": "object", "properties": { "ai_action_type": { "type": "string", "description": "Type of action to perform", "enum": [ "START", "STOP", "RESTART" ] }, "ai_integration_id": { "type": "string", "description": "Id of ai assistant, need only if ai_action_type=RESTART", "enum": [ "6737456b274ee315f1d9b72d" ] } }, "required": [ "ai_action_type", "ai_integration_id" ], "additionalProperties": false } }

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.

ksnip_20250428-161605-20250428-131605.png

IMPORTANT!

  • IMPORTANT:

    • The function_name must match exactly (e.g., START_TUNNEL, ADD_TAG, REMOVE_TAG, etc.).

    • The description field is the only editable field where you specify the action logic and IDs.

5. Testing and Verifying the Function

After setting up the assistant:

  1. Activate the AI Assistant for the selected communication channel.

  2. Send a test message that matches the trigger condition in the chatbot (communication channel).

  3. Ensure the function executed successfully. You can check this by looking at the lead's status in the chat.

    image-20250226-170010.png
  4. If errors occur, verify that the function parameters and call conditions are correctly configured.

  5. Make necessary adjustments to the assistant's instructions if required.