跳转到内容

Webhook 自动化

CrewAI AMP 允许你使用 webhooks 来自动化工作流。本文将引导你完成 webhook 的配置与使用,以便触发 crew 执行,并重点介绍与 ActivePieces 的集成。ActivePieces 是一个与 Zapier 和 Make.com 类似的工作流自动化平台。

  1. 访问 Kickoff 界面
    • 前往 CrewAI AMP 仪表板
    • 找到 /kickoff 区域,它用于启动 crew 执行
      Kickoff 界面
  2. 配置 JSON 内容

    在 JSON Content 部分,你需要提供以下信息:

    • inputs: 一个 JSON 对象,包含:
      • company: 公司名称(例如 "tesla"
      • product_name: 产品名称(例如 "crewai"
      • form_response: 响应类型(例如 "financial"
      • icp_description: 理想客户画像的简要描述
      • product_description: 产品的简短描述
      • taskWebhookUrlstepWebhookUrlcrewWebhookUrl: 各 webhook 端点的 URL(ActivePieces、Zapier、Make.com 或其他兼容平台)
  3. 与 ActivePieces 集成

    本示例将使用 ActivePieces。你也可以使用 Zapier 和 Make.com 等其他平台。

    要与 ActivePieces 集成:

    1. 在 ActivePieces 中创建一个新的 flow

    2. 添加一个触发器(例如 Every Day 日程)

      ActivePieces 触发器
    3. 添加一个 HTTP action 步骤

      • 将 action 设置为 Send HTTP request

      • 使用 POST 作为方法

      • 将 URL 设置为你的 CrewAI AMP kickoff 端点

      • 添加必要的 headers(例如 Bearer Token

        ActivePieces Headers
      • 在 body 中,包含第 2 步配置的 JSON 内容

        ActivePieces Body
      • 这样 crew 就会在预定时间启动。

  4. 设置 Webhook
    1. 在 ActivePieces 中创建一个新的 flow 并为其命名

      ActivePieces Flow
    2. 添加一个 webhook 步骤作为触发器:

      • 选择 Catch Webhook 作为触发器类型

      • 这会生成一个唯一 URL,用于接收 HTTP 请求并触发你的 flow

        ActivePieces Webhook
      • 配置 email,以使用 crew webhook body 文本

        ActivePieces Email

注意: 你在 kickoff 请求中提供的任何 meta 对象都会包含在所有 webhook payload 中,这样你可以跟踪请求,并在整个 crew 执行生命周期内保持上下文。

步骤 Webhook

stepWebhookUrl - 会在每个 agent 内部思考时触发的回调

{
"prompt": "Research the financial industry for potential AI solutions",
"thought": "I need to conduct preliminary research on the financial industry",
"tool": "research_tool",
"tool_input": "financial industry AI solutions",
"result": "**Preliminary Research Report on the Financial Industry for crewai Enterprise Solution**\n1. Industry Overview and Trends\nThe financial industry in ....\nConclusion:\nThe financial industry presents a fertile ground for implementing AI solutions like crewai, particularly in areas such as digital customer engagement, risk management, and regulatory compliance. Further engagement with the lead is recommended to better tailor the crewai solution to their specific needs and scale.",
"kickoff_id": "97eba64f-958c-40a0-b61c-625fe635a3c0",
"meta": {
"requestId": "travel-req-123",
"source": "web-app"
}
}
任务 Webhook

taskWebhookUrl - 会在每个任务结束时触发的回调

{
"description": "Using the information gathered from the lead's data, conduct preliminary research on the lead's industry, company background, and potential use cases for crewai. Focus on finding relevant data that can aid in scoring the lead and planning a strategy to pitch them crewai.",
"name": "Industry Research Task",
"expected_output": "Detailed research report on the financial industry",
"summary": "The financial industry presents a fertile ground for implementing AI solutions like crewai, particularly in areas such as digital customer engagement, risk management, and regulatory compliance. Further engagement with the lead is recommended to better tailor the crewai solution to their specific needs and scale.",
"agent": "Research Agent",
"output": "**Preliminary Research Report on the Financial Industry for crewai Enterprise Solution**\n1. Industry Overview and Trends\nThe financial industry in ....\nConclusion:\nThe financial industry presents a fertile ground for implementing AI solutions like crewai, particularly in areas such as digital customer engagement, risk management, and regulatory compliance.",
"output_json": {
"industry": "financial",
"key_opportunities": ["digital customer engagement", "risk management", "regulatory compliance"]
},
"kickoff_id": "97eba64f-958c-40a0-b61c-625fe635a3c0",
"meta": {
"requestId": "travel-req-123",
"source": "web-app"
}
}
Crew Webhook

crewWebhookUrl - 会在 crew 执行结束时触发的回调

{
"kickoff_id": "97eba64f-958c-40a0-b61c-625fe635a3c0",
"result": "**Final Analysis Report**\n\nLead Score: Customer service enhancement and compliance are particularly relevant.\n\nTalking Points:\n- Highlight how crewai's AI solutions can transform customer service\n- Discuss crewai's potential for sustainability goals\n- Emphasize compliance capabilities\n- Stress adaptability for various operation scales",
"result_json": {
"lead_score": "Customer service enhancement, and compliance are particularly relevant.",
"talking_points": [
"Highlight how crewai's AI solutions can transform customer service with automated, personalized experiences and 24/7 support, improving both customer satisfaction and operational efficiency.",
"Discuss crewai's potential to help the institution achieve its sustainability goals through better data analysis and decision-making, contributing to responsible investing and green initiatives.",
"Emphasize crewai's ability to enhance compliance with evolving regulations through efficient data processing and reporting, reducing the risk of non-compliance penalties.",
"Stress the adaptability of crewai to support both extensive multinational operations and smaller, targeted projects, ensuring the solution grows with the institution's needs."
]
},
"token_usage": {
"total_tokens": 1250,
"prompt_tokens": 800,
"completion_tokens": 450
},
"meta": {
"requestId": "travel-req-123",
"source": "web-app"
}
}