Notion 集成
让你的智能体通过 Notion 管理用户并创建评论。你可以访问工作区用户信息,并在页面和讨论中创建评论,从而借助 AI 驱动的自动化简化协作工作流。
在使用 Notion 集成之前,请确保你已具备:
- 一个拥有有效订阅的 CrewAI AMP 账户
- 一个具备相应工作区权限的 Notion 账户
- 通过 集成页面 连接了你的 Notion 账户
设置 Notion 集成
Section titled “设置 Notion 集成”1. 连接你的 Notion 账户
Section titled “1. 连接你的 Notion 账户”- 访问 CrewAI AMP Integrations
- 在 Authentication Integrations 部分找到 Notion
- 点击 Connect 并完成 OAuth 流程
- 授予用户访问和评论创建所需权限
- 从 Integration Settings 复制你的 Enterprise Token
2. 安装所需包
Section titled “2. 安装所需包”uv add crewai-tools3. 环境变量设置
Section titled “3. 环境变量设置”export CREWAI_PLATFORM_INTEGRATION_TOKEN="your_enterprise_token"或者将其添加到你的 .env 文件中:
CREWAI_PLATFORM_INTEGRATION_TOKEN=your_enterprise_tokennotion/list_users
说明: 列出工作区中的所有用户。
参数:
page_size(integer, optional): 响应中返回的项目数量。最小值:1,最大值:100,默认值:100start_cursor(string, optional): 分页游标。返回此游标之后的结果。
notion/get_user
说明: 通过 ID 检索某个用户。
参数:
user_id(string, required): 要检索的用户 ID。
notion/create_comment
说明: 在页面或讨论中创建评论。
参数:
parent(object, required): 要评论的父级页面或讨论。或{"type": "page_id","page_id": "PAGE_ID_HERE"}{"type": "discussion_id","discussion_id": "DISCUSSION_ID_HERE"}rich_text(array, required): 评论的富文本内容。[{"type": "text","text": {"content": "This is my comment text"}}]
基础 Notion 智能体设置
Section titled “基础 Notion 智能体设置”from crewai import Agent, Task, Crew
# Create an agent with Notion capabilitiesnotion_agent = Agent( role="Workspace Manager", goal="Manage workspace users and facilitate collaboration through comments", backstory="An AI assistant specialized in user management and team collaboration.", apps=['notion'] # All Notion actions will be available)
# Task to list workspace usersuser_management_task = Task( description="List all users in the workspace and provide a summary of team members", agent=notion_agent, expected_output="Complete list of workspace users with their details")
# Run the taskcrew = Crew( agents=[notion_agent], tasks=[user_management_task])
crew.kickoff()筛选特定 Notion 工具
Section titled “筛选特定 Notion 工具”comment_manager = Agent( role="Comment Manager", goal="Create and manage comments on Notion pages", backstory="An AI assistant that focuses on facilitating discussions through comments.", apps=['notion/create_comment'])
# Task to create comments on pagescomment_task = Task( description="Create a summary comment on the project status page with key updates", agent=comment_manager, expected_output="Comment created successfully with project status updates")
crew = Crew( agents=[comment_manager], tasks=[comment_task])
crew.kickoff()用户信息和团队管理
Section titled “用户信息和团队管理”from crewai import Agent, Task, Crew
team_coordinator = Agent( role="Team Coordinator", goal="Coordinate team activities and manage user information", backstory="An AI assistant that helps coordinate team activities and manages user information.", apps=['notion'])
# Task to coordinate team activitiescoordination_task = Task( description=""" 1. List all users in the workspace 2. Get detailed information for specific team members 3. Create comments on relevant pages to notify team members about updates """, agent=team_coordinator, expected_output="Team coordination completed with user information gathered and notifications sent")
crew = Crew( agents=[team_coordinator], tasks=[coordination_task])
crew.kickoff()from crewai import Agent, Task, Crew
collaboration_facilitator = Agent( role="Collaboration Facilitator", goal="Facilitate team collaboration through comments and user management", backstory="An AI assistant that specializes in team collaboration and communication.", apps=['notion'])
# Task to facilitate collaborationcollaboration_task = Task( description=""" 1. Identify active users in the workspace 2. Create contextual comments on project pages to facilitate discussions 3. Provide status updates and feedback through comments """, agent=collaboration_facilitator, expected_output="Collaboration facilitated with comments created and team members notified")
crew = Crew( agents=[collaboration_facilitator], tasks=[collaboration_task])
crew.kickoff()自动化团队沟通
Section titled “自动化团队沟通”from crewai import Agent, Task, Crew
communication_automator = Agent( role="Communication Automator", goal="Automate team communication and user management workflows", backstory="An AI assistant that automates communication workflows and manages user interactions.", apps=['notion'])
# Complex communication automation taskautomation_task = Task( description=""" 1. List all workspace users and identify team roles 2. Get specific user information for project stakeholders 3. Create automated status update comments on key project pages 4. Facilitate team communication through targeted comments """, agent=communication_automator, expected_output="Automated communication workflow completed with user management and comments")
crew = Crew( agents=[communication_automator], tasks=[automation_task])
crew.kickoff()