与出站拨号规则一起使用的操作指南

在定义将数据返回到出站拨号规则的数据操作的成功模式时,需要特别注意事项。

嵌套输出属性

When constructing its output contact (success schema), it is imperative to nest properties when necessary. If an output field from /execute is a complex object, the corresponding property in the schema should be a nested schema, and not a string that assumes “flattened” output. Outbound already uses ?flatten=true to flatten output.

未嵌套的属性示例

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "data.my data field": {
      "type": "string",
    }
  }
}

The above example specifies a “data.my data field” in the success schema of a data action. The resulting action won’t work if it used by an outbound dialing data action rule. Outbound will be unable to find the field in the /actions/{actionId}/execute response. It will skip calls with a result of ININ-OUTBOUND-RULE-ERROR-SKIPPED.

为了避免这个问题,请将 “我的数据字段” 设置为 “data” 字段的嵌套属性:

正确嵌套的例子

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "my data field": {
          "type": "string"
        }
      }
    }
  }
}

通常,你的输出架构应该与你关心从 /execute 请求返回的属性具有相同的结构。

考虑一下这个简单的对象,以及输出架构如何返回它:

一个简单的对象

{
  "foo": {
    "bat": "bar"
  }
}

简单对象的输出架构

{
 "$schema": "http://json-schema.org/draft-04/schema#",
 "type": "object",
 "properties": {
   "foo": {
     "type": "string"
   }
 }
}

要使其与 Outbound 兼容,请修改简单对象的输出架构以嵌套属性:

正确嵌套简单对象

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "foo": {
      "type": "object",
      "properties": {
        "bat": {
          "type": "string"
        }
      }
    }
  }
}

此模式将返回:

{
  "foo": {
    "bat": "bar"
  }
}

必填字段

如果有您的数据操作需要的字段,请在成功模式中将这些字段标记为必填字段。

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "required": [
    "contact_id",
    "phone_number"
  ],
  "properties": {
   ...
    },
注意: 单个广告活动可以拥有的最大数据操作规则条件数为两个。