您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

定义和使用审查工作流 (REST)Define and use moderation workflows (REST)

工作流是基于云的自定义筛选器可用来更有效地处理内容。Workflows are cloud-based customized filters that you can use to handle content more efficiently. 工作流可以连接到各种服务来以不同方式筛选内容,然后采取相应的措施。Workflows can connect to a variety of services to filter content in different ways and then take the appropriate action. 本指南演示如何使用 API 控制台中,通过工作流 REST Api 创建和使用工作流。This guide shows you how to use the workflow REST APIs, through the API console, to create and use workflows. 一旦您了解的 Api 结构,您可以轻松地移植到任何 REST 兼容平台这些调用。Once you understand the structure of the APIs, you can easily port these calls to any REST-compatible platform.

必备组件Prerequisites

  • 登录或在内容审查器上创建一个帐户审阅工具站点。Sign in or create an account on the Content Moderator Review tool site.

创建工作流Create a workflow

若要创建或更新的工作流,请转到**工作流-创建或更新** API 引用页,选择密钥中你所在区域的按钮 (您可以在中找到此终结点 URL 上凭据页的审阅工具)。To create or update a workflow, go to the Workflow - Create Or Update API reference page and select the button for your key region (you can find this in the Endpoint URL on the Credentials page of the Review tool). 这将启动 API 控制台中,您可以轻松地构建和运行的 REST API 调用。This starts the API console, where you can easily construct and run REST API calls.

“工作流 - 创建或更新”页上的区域选择

输入 REST 调用参数Enter REST call parameters

输入值团队workflowname,并Ocp Apim 订阅密钥:Enter values for team, workflowname, and Ocp-Apim-Subscription-Key:

  • team:您设置时创建的团队 ID 你审阅工具帐户 (在中找到Id评审工具的凭据屏幕上的字段)。team: The team ID that you created when you set up your Review tool account (found in the Id field on your Review tool's Credentials screen).
  • workflowname:要添加的新工作流 (或现有的名称,如果你想要更新现有工作流) 的名称。workflowname: The name of a new workflow to add (or an existing name, if you want to update an existing workflow).
  • Ocp-Apim-Subscription-Key:你的内容审查器密钥。Ocp-Apim-Subscription-Key: Your Content Moderator key. 您可以在上找到此设置选项卡审阅工具You can find this on the Settings tab of the Review tool.

“工作流 - 创建或更新”控制台查询参数和请求头

输入工作流定义Enter a workflow definition

  1. 编辑请求正文框中输入的详细信息的 JSON 请求说明类型(或者ImageText)。Edit the Request body box to enter the JSON request with details for Description and Type (either Image or Text).
  2. 有关表达式,复制 JSON 表达式的默认工作流。For Expression, copy the default workflow JSON expression. 最终的 JSON 字符串应如下所示:Your final JSON string should look like this:
{
  "Description":"<A description for the Workflow>",
  "Type":"Text",
  "Expression":{
    "Type":"Logic",
    "If":{
      "ConnectorName":"moderator",
      "OutputName":"isAdult",
      "Operator":"eq",
      "Value":"true",
      "Type":"Condition"
    },
    "Then":{
      "Perform":[
        {
          "Name":"createreview",
          "CallbackEndpoint":null,
          "Tags":[

          ]
        }
      ],
      "Type":"Actions"
    }
  }
}

备注

可以为使用此 API 工作流定义简单而甚至嵌套的复杂的表达式。You can define simple, complex, and even nested expressions for your workflows using this API. 工作流-创建或更新文档中有更复杂的逻辑的示例。The Workflow - Create Or Update documentation has examples of more complex logic.

提交请求Submit your request

选择“发送”。Select Send. 如果操作成功,“响应状态”为“200 OK”,且“响应内容”框显示“true”。If the operation succeeds, the Response status is 200 OK, and the Response content box displays true.

检查新的工作流Examine the new workflow

在中审阅工具,选择设置 > 工作流In the Review tool, select Settings > Workflows. 新工作流应显示在列表中。Your new workflow should appear in the list.

“审阅”工具的工作流列表

选择编辑工作流选项并转到设计器选项卡。这里,您可以看到 JSON 逻辑的直观表示形式。Select the Edit option for your workflow and go to the Designer tab. Here, you can see an intuitive representation of the JSON logic.

选定工作流的“设计器”选项卡

获取工作流详细信息Get workflow details

若要检索有关现有工作流的详细信息,请转到**工作流-Get** API 引用页,选择你所在区域的按钮 (在其中管理你的密钥的区域)。To retrieve details about an existing workflow, go to the Workflow - Get API reference page and select the button for your region (the region in which your key is administered).

“工作流 - 获取”区域选择

输入 REST 调用参数,如在上面的部分。Enter the REST call parameters as in the above section. 请确保此时间workflowname是现有工作流的名称。Make sure that this time, workflowname is the name of an existing workflow.

“获取”查询参数和请求头

选择“发送”。Select Send. 如果操作成功,响应状态200 OK,和响应内容框显示在工作流以 JSON 格式,如下所示:If the operation succeeds, the Response status is 200 OK, and the Response content box displays the workflow in JSON format, like the following:

{
  "Name":"default",
  "Description":"Default",
  "Type":"Image",
  "Expression":{
    "If":{
      "ConnectorName":"moderator",
      "OutputName":"isadult",
      "Operator":"eq",
      "Value":"true",
      "AlternateInput":null,
      "Type":"Condition"
    },
    "Then":{
      "Perform":[
        {
          "Name":"createreview",
          "Subteam":null,
          "CallbackEndpoint":null,
          "Tags":[

          ]
        }
      ],
      "Type":"Actions"
    },
    "Else":null,
    "Type":"Logic"
  }
}

后续步骤Next steps