跳转到内容

Box 集成

让你的代理通过 Box 管理文件、文件夹和文档。上传文件、整理文件夹结构、搜索内容,并借助 AI 驱动的自动化简化团队的文档管理。

在使用 Box 集成前,请确保你已经具备:

  • 一个拥有有效订阅的 CrewAI AMP 账号
  • 一个具有相应权限的 Box 账号
  • 已通过 集成页面 连接你的 Box 账号
  1. 进入 CrewAI AMP Integrations
  2. 在身份验证集成部分找到 Box
  3. 点击 Connect 并完成 OAuth 流程
  4. 授予文件和文件夹管理所需的权限
  5. Integration Settings 复制你的 Enterprise Token
Terminal window
uv add crewai-tools
Terminal window
export CREWAI_PLATFORM_INTEGRATION_TOKEN="your_enterprise_token"

或者将其添加到你的 .env 文件中:

CREWAI_PLATFORM_INTEGRATION_TOKEN=your_enterprise_token
box/save_file

描述: 从 URL 将文件保存到 Box。

参数:

  • fileAttributes (object, required): 属性 - 文件元数据,包括名称、父文件夹和时间戳。
    {
    "content_created_at": "2012-12-12T10:53:43-08:00",
    "content_modified_at": "2012-12-12T10:53:43-08:00",
    "name": "qwerty.png",
    "parent": { "id": "1234567" }
    }
  • file (string, required): 文件 URL - 文件大小必须小于 50MB。(示例:"https://picsum.photos/200/300")。
box/save_file_from_object

描述: 在 Box 中保存文件。

参数:

  • file (string, required): 文件 - 接受包含文件数据的 File 对象。文件大小必须小于 50MB。
  • fileName (string, required): 文件名(示例:"qwerty.png")。
  • folder (string, optional): 文件夹 - 使用 Connect Portal Workflow Settings 让用户选择文件的目标文件夹。如果留空,则默认为用户的根文件夹。
box/get_file_by_id

描述: 通过 ID 获取 Box 中的文件。

参数:

  • fileId (string, required): 文件 ID - 表示文件的唯一标识符。(示例:"12345")。
box/list_files

描述: 列出 Box 中的文件。

参数:

  • folderId (string, required): 文件夹 ID - 表示文件夹的唯一标识符。(示例:"0")。
  • filterFormula (object, optional): 以析取范式表示的筛选器 - 若干 AND 条件组的 OR。
    {
    "operator": "OR",
    "conditions": [
    {
    "operator": "AND",
    "conditions": [
    {
    "field": "direction",
    "operator": "$stringExactlyMatches",
    "value": "ASC"
    }
    ]
    }
    ]
    }
box/create_folder

描述: 在 Box 中创建文件夹。

参数:

  • folderName (string, required): 名称 - 新文件夹的名称。(示例:"New Folder")。
  • folderParent (object, required): 父文件夹 - 将创建新文件夹的父级文件夹。
    {
    "id": "123456"
    }
box/move_folder

描述: 在 Box 中移动文件夹。

参数:

  • folderId (string, required): 文件夹 ID - 表示文件夹的唯一标识符。(示例:"0")。
  • folderName (string, required): 名称 - 文件夹名称。(示例:"New Folder")。
  • folderParent (object, required): 父文件夹 - 新的父文件夹目标位置。
    {
    "id": "123456"
    }
box/get_folder_by_id

描述: 通过 ID 获取 Box 中的文件夹。

参数:

  • folderId (string, required): 文件夹 ID - 表示文件夹的唯一标识符。(示例:"0")。
box/search_folders

描述: 在 Box 中搜索文件夹。

参数:

  • folderId (string, required): 文件夹 ID - 要在其中搜索的文件夹。
  • filterFormula (object, optional): 以析取范式表示的筛选器 - 若干 AND 条件组的 OR。
    {
    "operator": "OR",
    "conditions": [
    {
    "operator": "AND",
    "conditions": [
    {
    "field": "sort",
    "operator": "$stringExactlyMatches",
    "value": "name"
    }
    ]
    }
    ]
    }
box/delete_folder

描述: 在 Box 中删除文件夹。

参数:

  • folderId (string, required): 文件夹 ID - 表示文件夹的唯一标识符。(示例:"0")。
  • recursive (boolean, optional): 递归 - 通过递归删除文件夹及其所有内容来删除非空文件夹。
from crewai import Agent, Task, Crew
from crewai import Agent, Task, Crew
# Create an agent with Box capabilities
box_agent = Agent(
role="Document Manager",
goal="Manage files and folders in Box efficiently",
backstory="An AI assistant specialized in document management and file organization.",
apps=['box'] # All Box actions will be available
)
# Task to create a folder structure
create_structure_task = Task(
description="Create a folder called 'Project Files' in the root directory and upload a document from URL",
agent=box_agent,
expected_output="Folder created and file uploaded successfully"
)
# Run the task
crew = Crew(
agents=[box_agent],
tasks=[create_structure_task]
)
from crewai import Agent, Task, Crew
# Create agent with specific Box actions only
file_organizer_agent = Agent(
role="File Organizer",
goal="Organize and manage file storage efficiently",
backstory="An AI assistant that focuses on file organization and storage management.",
apps=['box/create_folder', 'box/save_file', 'box/list_files'] # Specific Box actions
)
# Task to organize files
organization_task = Task(
description="Create a folder structure for the marketing team and organize existing files",
agent=file_organizer_agent,
expected_output="Folder structure created and files organized"
)
crew = Crew(
agents=[file_organizer_agent],
tasks=[organization_task]
)
crew.kickoff()
from crewai import Agent, Task, Crew
file_manager = Agent(
role="File Manager",
goal="Maintain organized file structure and manage document lifecycle",
backstory="An experienced file manager who ensures documents are properly organized and accessible.",
apps=['box']
)
# Complex task involving multiple Box operations
management_task = Task(
description="""
1. List all files in the root folder
2. Create monthly archive folders for the current year
3. Move old files to appropriate archive folders
4. Generate a summary report of the file organization
""",
agent=file_manager,
expected_output="Files organized into archive structure with summary report"
)
crew = Crew(
agents=[file_manager],
tasks=[management_task]
)
crew.kickoff()