Danh mục thao tác

Kiểm tra luật

rules.validateMCP:rules_validateBộ công cụ: Thiết lập tự chạy

Validate a rule definition without saving it.

Chỉ đọc
Quyền: Đọc

Gọi bằng REST v2

curl -X POST https://zl.builera.app/api/public/v2/ops/rules.validate \
  -H "Authorization: Bearer za_live_…" \
  -H "Content-Type: application/json" \
  -d '{"rule":{"name":"Nguyễn Văn A","trigger":{"kind":"message_in"},"actions":[{"type":"send_template","text":"Chào anh, em gửi thông tin ạ"}]}}'

Mỗi khoá/kết nối tối đa 300 lệnh đọc và 60 lệnh ghi mỗi phút. Gọi lại cùng Idempotency-Key trả đúng kết quả cũ, không làm lại.

Gọi qua MCP

{
  "method": "tools/call",
  "params": {
    "name": "rules_validate",
    "arguments": {
      "rule": {
        "name": "Nguyễn Văn A",
        "trigger": {
          "kind": "message_in"
        },
        "actions": [
          {
            "type": "send_template",
            "text": "Chào anh, em gửi thông tin ạ"
          }
        ]
      }
    }
  }
}

Thêm https://zl.builera.app/mcp vào ứng dụng AI rồi cho phép kết nối; AI chỉ thấy công cụ trong bộ bạn chọn.

Kết quả

HTTP 200
{ "status": "succeeded", "operationId": "…", "data": { … } }

Ví dụ đầu vào

{
  "rule": {
    "name": "Nguyễn Văn A",
    "trigger": {
      "kind": "message_in"
    },
    "actions": [
      {
        "type": "send_template",
        "text": "Chào anh, em gửi thông tin ạ"
      }
    ]
  }
}

Thay mã (id) mẫu bằng mã thật lấy từ các thao tác liệt kê/tìm kiếm.

Lược đồ đầu vào (JSON Schema)

{
  "type": "object",
  "properties": {
    "rule": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "enabled": {
          "type": "boolean",
          "default": true
        },
        "accountIds": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uuid"
          },
          "maxItems": 50,
          "default": []
        },
        "trigger": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "message_in"
                  ]
                },
                "keywords": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 60
                  },
                  "maxItems": 30,
                  "default": []
                },
                "match": {
                  "type": "string",
                  "enum": [
                    "any",
                    "all",
                    "regex"
                  ],
                  "default": "any"
                },
                "regex": {
                  "type": "string",
                  "maxLength": 200,
                  "nullable": true,
                  "default": null
                }
              },
              "required": [
                "kind"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "first_message"
                  ]
                }
              },
              "required": [
                "kind"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "friend_accepted"
                  ]
                }
              },
              "required": [
                "kind"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "friend_request"
                  ]
                }
              },
              "required": [
                "kind"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "outside_hours"
                  ]
                }
              },
              "required": [
                "kind"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "silent"
                  ]
                },
                "days": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 90
                }
              },
              "required": [
                "kind",
                "days"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "stage_changed"
                  ]
                },
                "stageId": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true,
                  "default": null
                }
              },
              "required": [
                "kind"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "label_added"
                  ]
                },
                "labelId": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true,
                  "default": null
                }
              },
              "required": [
                "kind"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "task_overdue"
                  ]
                }
              },
              "required": [
                "kind"
              ],
              "additionalProperties": false
            }
          ]
        },
        "conditions": {
          "type": "object",
          "properties": {
            "labelsAny": {
              "type": "array",
              "items": {
                "type": "string",
                "format": "uuid"
              },
              "maxItems": 20,
              "default": []
            },
            "labelsNone": {
              "type": "array",
              "items": {
                "type": "string",
                "format": "uuid"
              },
              "maxItems": 20,
              "default": []
            },
            "stageIds": {
              "type": "array",
              "items": {
                "type": "string",
                "format": "uuid"
              },
              "maxItems": 20,
              "default": []
            },
            "threadType": {
              "type": "string",
              "enum": [
                "any",
                "user",
                "group"
              ],
              "default": "user"
            },
            "groupWithoutMention": {
              "type": "boolean",
              "default": false
            },
            "hours": {
              "type": "object",
              "properties": {
                "start": {
                  "type": "string",
                  "pattern": "^\\d{2}:\\d{2}$"
                },
                "end": {
                  "type": "string",
                  "pattern": "^\\d{2}:\\d{2}$"
                }
              },
              "required": [
                "start",
                "end"
              ],
              "additionalProperties": false,
              "nullable": true,
              "default": null
            },
            "field": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "maxLength": 40
                },
                "value": {
                  "type": "string",
                  "maxLength": 200
                }
              },
              "required": [
                "key",
                "value"
              ],
              "additionalProperties": false,
              "nullable": true,
              "default": null
            }
          },
          "additionalProperties": false,
          "default": {}
        },
        "actions": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "send_template"
                    ]
                  },
                  "text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "mediaIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "maxItems": 5,
                    "default": []
                  }
                },
                "required": [
                  "type",
                  "text"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "add_label"
                    ]
                  },
                  "labelId": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "type",
                  "labelId"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "remove_label"
                    ]
                  },
                  "labelId": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "type",
                  "labelId"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "set_stage"
                    ]
                  },
                  "stageId": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "type",
                  "stageId"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "assign"
                    ]
                  },
                  "userId": {
                    "type": "string",
                    "format": "uuid",
                    "nullable": true
                  },
                  "roundRobin": {
                    "type": "boolean",
                    "default": false
                  }
                },
                "required": [
                  "type",
                  "userId"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "create_task"
                    ]
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "dueInHours": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1440,
                    "default": 24
                  }
                },
                "required": [
                  "type",
                  "title"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "accept_friend"
                    ]
                  }
                },
                "required": [
                  "type"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "enroll_campaign"
                    ]
                  },
                  "campaignId": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "type",
                  "campaignId"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "webhook"
                    ]
                  },
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 500
                  }
                },
                "required": [
                  "type",
                  "url"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "notify"
                    ]
                  },
                  "target": {
                    "type": "string",
                    "enum": [
                      "assignee",
                      "admins",
                      "everyone"
                    ],
                    "default": "assignee"
                  },
                  "text": {
                    "type": "string",
                    "maxLength": 300,
                    "default": ""
                  }
                },
                "required": [
                  "type"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "mark_dnc"
                    ]
                  }
                },
                "required": [
                  "type"
                ],
                "additionalProperties": false
              }
            ]
          },
          "minItems": 1,
          "maxItems": 10
        },
        "priority": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000,
          "default": 100
        },
        "templateKey": {
          "type": "string",
          "maxLength": 40,
          "nullable": true,
          "default": null
        }
      },
      "required": [
        "name",
        "trigger",
        "actions"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "rule"
  ],
  "additionalProperties": false
}

Cùng bộ công cụ