UploadRule
Creates a rule. You can use this operation to provide your own rule editing interface.
Operation description
For more information, see Rule configuration.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
sca:UploadRule |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| JsonStr |
string |
Yes |
Complete JSON string. For details, see the following sections. |
{“conditions”:“xxxxx”,"rules":"xxxx"} |
| BaseMeAgentId |
integer |
No |
Workspace ID. |
123456 |
JSON string for request parameters
| Property | Type | Required | Description |
| appKey | String | Yes | Tag for the business party or scenario. |
| conditions | List | Yes | Detailed configuration for all conditions. For details, see ConditionBasicInfo below. |
| rules | List | Yes | Rule configuration. For details, see RuleInfo below. |
Condition configuration: ConditionBasicInfo
| Property | Type | Required | Example value | Description |
| cid | String | Yes | "1" | Condition ID. Must be a numeric string (we recommend starting from 1 and incrementing by 1). After upload, the system replaces this with an auto-generated ID. |
| check_range | CheckRange | Yes | See CheckRange | Scope of condition evaluation. |
| operators | List | Yes | See OperatorBasicInfo | Operators in this condition. |
| lambda | String | Yes | One operator: "1". Multiple operators: 1&&2&&3 | Logical relationship among operators. Built from operator IDs (oid) and logical operators (AND, OR, NOT). In the example, 1, 2, and 3 are operator IDs. See OperatorBasicInfo for details on oid. |
CheckRange
| Property | Type | Required | Example value | Description |
| role | String | No | Agent | Target role. Valid values: "Agent", "Customer". If omitted, applies to all roles. |
| anchor | Anchor | No | See Anchor | Prerequisite condition details. |
| range | String | No | {"from":1,"to":3} | Evaluation range. For usage details, see Range usage notes later in this document. |
Anchor
| Property | Type | Required | Example value | Description |
| cid | String | Yes | "3" | Condition ID (cid) of the prerequisite condition. Identifies which condition serves as the anchor. |
| location | String | Yes | AROUND | Specifies where to evaluate relative to the anchor condition's matched sentence. Valid values:BEFORE: before the anchor sentence.AROUND: around the anchor sentence (before and after).AFTER: after the anchor sentence.CURRENT: the anchor sentence itself.Use this field to define a scope. Then use the from and to values in range to specify exact sentences. |
| hit_time | Integer | Yes | 3 | How many times the prerequisite condition must match. Options:Positive integer (1–N): matches the first (or Nth) occurrence.0: matches every occurrence.-1: matches any occurrence. |
OperatorBasicInfo
| Property | Type | Required | Example value | Description |
| oid | String | Yes | "1" | Operator ID. Must be a numeric string (we recommend starting from 1 and incrementing by 1). After upload, the system replaces this with an auto-generated ID. |
| name | String | Yes | My operator name | Operator name and description. |
| type | String | Yes | INCLUDE_KEYWORDS | Operator type. For details, see Param below. |
| param | Param | Yes | See Param | Operator expression details. |
Param: Operator types and parameters
The param object contains many properties. Some are shared across all operator types, while others apply only to specific types. This section lists each operator type, its valid properties, and provides configuration examples.
1. Keyword check
Matches if any keyword is present (HIT_ANY_KEYWORDS), all keywords are present, a specific number of keywords are present, or no keywords are present (INCLUDE_KEYWORDS).
| Property | Type | Required | Example value | Description |
| keywords | List | Yes | ["Hello", "Hi", "Good morning"] | List of keywords. |
| contextChatMatch | Boolean | No | false | Whether to analyze multiple sentences together. Valid values: true (multi-sentence analysis), false (single-sentence analysis). Default: false. See Detailed analysis modes |
| keywordMatchSize | Integer | No | 3 | Number of keywords to match. Rules:Any one keyword: set to 1.All keywords: set to -1.Any N keywords: set to an integer between 1 and the total number of keywords.None: set to 0.Default depends on type: HIT_ANY_KEYWORDS → 1, INCLUDE_KEYWORDS → -1. |
| in_sentence | Boolean | No | true | Whether to restrict matching to a single sentence. A sentence ends at punctuation like commas or periods. Valid values: true (restrict), false (no restriction). Default: false. This setting has no effect if contextChatMatch is true. |
| keywordExtension | Integer | No | 0 | Whether to enable synonym expansion. Valid values: 1 (enable), 0 (disable). Default: 0. |
Detailed analysis modes
-
Single-sentence and multi-sentence analysis apply to the sentences that are defined by the role, anchor, and range of the current condition.
-
Limited sentences: Refers to one or more sentences that are defined by the role, anchor, and range of the condition.
-
Single-sentence analysis: Analyzes each limited sentence separately. For example, to match all keywords, at least one sentence must contain all of the specified keywords.
-
Multi-sentence analysis: Combines all limited sentences into a single paragraph and analyzes it. For example, to match all keywords, the combined paragraph must contain all of the specified keywords.
Request examples: 1. Single-sentence analysis to match any one keyword.
{
"keywords":[
"Hi",
"Hello",
"Good morning"
],
"contextChatMatch":false
}

2. Multi-sentence analysis to match all keywords.
{
"keywordMatchSize":-1,
"keywords":[
"Hi",
"Hello",
"Good morning"
],
"contextChatMatch":true
}

3. Single-sentence analysis to match any two keywords, restricted to one sentence, with synonym expansion enabled.
{
"keywordMatchSize":2,
"keywordExtension":1,
"keywords":[
"Hi",
"Hello",
"Good morning"
],
"in_sentence":true,
"contextChatMatch":false
}

4. Single-sentence analysis to match none of the keywords.
{
"keywordMatchSize":0,
"keywords":[
"Hi",
"Hello",
"Good morning"
],
"contextChatMatch":false
}

2. Regular expression check (REGULAR_EXPRESSION)
| Property | Type | Required | Example value | Description |
| regex | String | Yes | See code example below | Regular expression to match. |
| notRegex | String | No | See code example below | Regular expression to exclude. |
| in_sentence | Boolean | No | true | Whether to restrict matching to a single sentence. Default: false. Valid values: true (restrict), false (no restriction). |
{
"regex":"Please.*(license plate number|engine number|driver's license number)",
"notRegex":"Send me|Tell me",
"in_sentence":true
}

3. Text similarity check (SIMILAR_MATCH)
| Property | Type | Required | Example value | Description |
| similarlySentences | List | Yes | See code example below | Example sentences. Maximum 200 sentences. Each sentence can be up to 50 characters long. |
| score | Integer | No | 80 | Similarity score. Default: 80. |
{
"score":80,
"similarlySentences":[
"I want to complain about your department",
"I want to complain about you",
"I want to report your department",
"I will call 12315 to report you",
"I will complain to the industrial and commercial administration"
]
}

4. Advanced repeat detection (ADVANCED_REPEAT_DETECT)
| Property | Type | Required | Example value | Description |
| from | Integer | No | 3 | Maximum gap (in sentences) between repeated sentences. Default: 2. For example, if set to 2, repetition within the last two sentences triggers a violation. |
| hit_time | Integer | No | 2 | Which repetition triggers a violation. Default: 1. |
| threshold | Integer | No | 5 | Minimum sentence length (in characters) to check. Sentences shorter than this value are skipped. Default: 4. |
| excludes | List | No | ["OK, I understand", "OK, I understand"] | Sentences that are exempt from repeat checks. Default: empty. |
{
"from":3,
"hit_time":2,
"threshold":5,
"excludes":[
"OK, I understand",
"OK, I understand"
]
}

5. Silence detection (INTERVAL_GREATER)
| Property | Type | Required | Example value | Description |
| interval | Integer | Yes | 5000 | Silence duration (in milliseconds). |
| different_role | Boolean | No | false | Whether to distinguish roles. true: distinguish roles. false: ignore roles. If true, sentences spoken by the same role as the target sentence are excluded from calculation. |
| target | Integer | No | 1 | How many sentences before the current sentence to use as the target. If 0, the interval equals the current sentence’s end time minus its start time. |
| from_end | Boolean | No | false | Whether to calculate the interval as the current sentence’s end time minus the target sentence’s end time. |
{
"interval":5000,
"different_role":false,
"target":1,
"from_end":false
}

6. Speech speed check (SPEECH_SPEED_CHECK)
| Property | Type | Required | Example value | Description |
| velocityInMint | Integer | Yes | 370 | Speech speed (characters per minute). Used to determine whether the current sentence exceeds this speed. |
| minWordSize | Integer | No | 4 | Minimum sentence length (in characters) to check. Sentences shorter than this value are skipped. |
| average | Boolean | No | false | Whether to check average speech speed across the entire conversation. true: check average. false: check per sentence. |
{
"velocityInMint":370,
"average":false,
"minWordSize":4
}

7. Interruption detection (GRAB_WORDS)
| Property | Type | Required | Example value | Description |
| interval | Integer | Yes | 5000 | Overlap time (in milliseconds). Calculated as the customer’s speech end time minus the agent’s speech start time. |
| threshold | Integer | No | 4 | Minimum sentence length (in characters) to check for interruptions. |
| delayTime | Integer | No | 1000 | Delay before detecting interruption (in milliseconds). For example, if set to 1000, overlap must persist for at least 1000 ms to trigger detection. |
{
"interval":3000,
"threshold":4
}

8. Role check (ROLE_CHECK)
This operator requires changes to check_range. See the full condition example below.
| Property | Type | Required | Example value | Description |
| target_role | String | Yes | Customer | Target role for the sentence. Valid values: "Agent", "Customer". |
{
"cid":"1",
"lambda":"1",
"check_range":{
"absolute":true,
"alSentencesSatisfy":true,
"range":{
"from":2,
"to":2
}
},
"operators":[
{
"oid":1,
"type":"ROLE_CHECK",
"param":{
"target_role":"Agent"
}
}
]
}

9. Abnormal hang-up (DURATION)
Detects abnormal hang-ups based on the role of the last sentence and the time that elapses between the end of that sentence and the hang-up. To evaluate the last sentence, set both `from` and `to` in `check_range.range` to -1. See the full condition example below.
| Property | Type | Required | Example value | Description |
| interval | Integer | Yes | 5000 | Time (in milliseconds) between the end of the last sentence and the hang-up. |
| compareOperator | String | No | gt | Comparison operator for interval. Valid values: gt (greater than), lt (less than). Default: gt. |
| beginType | String | Yes | DIALOGUE | Fixed value: DIALOGUE. |
| target_role | String | No | Customer | Role of the last sentence. If omitted, applies to all roles. |
{
"cid":"1",
"lambda":"1",
"check_range":{
"range":{
"from":-1,
"to":-1
}
},
"operators":[
{
"oid":1,
"type":"DURATION",
"param":{
"interval":3000,
"beginType":"DIALOGUE",
"target_role":"Customer"
}
}
]
}

10. Recording duration check (DURATION)
| Property | Type | Required | Example value | Description |
| interval | Integer | Yes | 5000 | Recording duration (in milliseconds). |
| compareOperator | String | No | gt | Comparison operator for interval. Valid values: gt (greater than), lt (less than). Default: gt. |
{
"interval":60000,
"compareOperator":"lt"
}

11. Energy detection (ASR_EMOTION)
| Property | Type | Required | Example value | Description |
| maxEmotionChangeValue | Integer | No | 3 | Energy value. Range: 1–10. |
| checkType | Integer | No | 3 | Detection method. Valid values:1: energy fluctuation between adjacent sentences.2: maximum energy span.3: energy range detection.Default: 3. |
| compareOperator | String | No | gt | Comparison direction. Valid values: gt (greater than), lt (less than). Default: gt. |

12. General detection model (EMOTION_MODEL)
Uses built-in algorithms to detect issues such as abusive language or high-risk content.
| Property | Type | Required | Example value | Description |
| pvalues | List | No | ["ruma01"] | Detection type. Valid values:ruma01: abusive language detection.goawei01: high-risk detection.Default: ["ruma01"]. |

13. Customer detection model (CUSTOMER_CHECK_MODEL)
Uses built-in algorithms to detect customer statements such as threats to complain, requests to speak with supervisors, complaints about agent attitude, internal complaints, or public sentiment issues.
| Property | Type | Required | Example value | Description |
| pvalues | List | No | ["tousu01","zhaozhuguan01"] | Detection type. Valid values:tousu01: threat to complain about agent.zhaozhuguan01: request to speak with supervisor.zhiyitaidu01: complaint about agent attitude.internal_complain01: internal complaint detection.public_opinion: public sentiment detection.Default: ["tousu01"]. |

14. Agent detection model (ABUSE_MODEL)
This model uses built-in algorithms and does not require `param` configuration.
| Property | Type | Required | Example value | Description |
| pvalues | List | No | ["jifeng01"] | Detection type. Valid value: jifeng01 (mockery detection). Default: ["jifeng01"]. |

Rule configuration: RuleInfo
| Property | Type | Required | Example value | Description |
| rid | String | Yes | 1 | Rule ID. Must be a numeric string. After upload, the system replaces this with an auto-generated ID. |
| lambda | String | Yes | One condition: "". Multiple conditions: a&&b&&c | Logical relationship among conditions. Built from condition IDs (cid) and logical operators (AND, OR, NOT). In the example, a, b, and c are condition IDs. |
| business | List | Yes | See BusinessCategoryBasicInfo | Businesses this rule applies to. Get this from the Create Rule page. If empty, defaults to "All businesses". |
| type | Integer | Yes | 1 | Rule type. Get this from the Create Rule page. |
| triggers | List | Yes | ["a","b","c"] | Condition IDs (cid) whose results should be returned. When the rule matches, these condition details are included in the response. |
| Name | String | Yes | "Customer may file a complaint" | Rule name. |
| scoreSubId | Integer | No | 3678 | ID of the scoring sub-item this rule is attached to. Required if attaching to a scoring item. |
| ruleScoreType | Integer | No | 3 | Whether this rule contributes to scoring. 1: no contribution. 3: contributes. |
| level | Integer | No | 2 | Severity level. Used to group rules by severity in review pages. Values: 0 (severe), 1 (moderate), 2 (minor). Default: 2. |
| fullCycle | Integer | No | 1 | When the rule is active. Valid values: 0 (active during a specific period), 1 (always active). |
| effectiveStartTime | Date | No | 2021-03-04 04:05:05 | Start time for a specific active period. |
| effectiveEndTime | Date | No | 2021-03-06 04:05:05 | End time for a specific active period. |
BusinessCategoryBasicInfo
| Property | Type | Required | Example value | Description |
| bid | Integer | Yes | 267202890 | Business ID (BID). Must be numeric. |

Range usage notes
The `range` parameter uses a numeric interval to select the sentences to which the condition applies.
Without a prerequisite condition

1. {"from":1,"to":3}: Selects the first three sentences spoken by the specified role. 2. {"from":-1,"to":-3}: Selects the last three sentences spoken by the specified role. 3. {"from":3,"to":-3}: Selects from the third sentence to the third-to-last sentence spoken by the specified role.
With a prerequisite condition
If a prerequisite condition exists, the system uses the matched prerequisite sentence as a divider to split all sentences into three segments: • All sentences before the matched prerequisite sentence. • All sentences after the matched prerequisite sentence. • Sentences around the matched prerequisite sentence. First, you must choose a segment. Then, you can use a numeric interval to select specific sentences within that segment.

Before the prerequisite match (anchor.location = BEFORE)

1. {"from":1,"to":3}: The first three sentences in the selected segment. The sentence immediately before the prerequisite match is considered sentence 1. 2. {"from":-1,"to":-3}: The last three sentences in the selected segment. The sentence farthest from the prerequisite match is considered the last sentence. 3. {"from":1,"to":-1}: All sentences before the prerequisite match. 4. {"from":0,"to":2}: The prerequisite match sentence plus the next two sentences spoken by the specified role. This is valid only if the current and prerequisite conditions apply to the same role.
5. These are only examples. You can use any positive or negative integers. Positive numbers count forward from the start of the segment, and negative numbers count backward from the end.
Around the prerequisite match (anchor.location = AROUND)

1. {"from":0,"to":0}: Only the prerequisite match sentence. 2. {"from":1,"to":3}: The first to third sentences after the prerequisite match. 3. {"from":-2,"to":-4}: The second to fourth sentences before the prerequisite match. 4. {"from":-3,"to":3}: From the third sentence before the prerequisite match to the third sentence after it. 5. These are only examples. You can use any positive or negative integers. Positive numbers refer to sentences after the prerequisite match, and negative numbers refer to sentences before it.
After the prerequisite match (anchor.location = AFTER)

1. {"from":1,"to":3}: The first three sentences in the selected segment. The sentence immediately after the prerequisite match is considered sentence 1. 2. {"from":-1,"to":-3}: The last three sentences in the selected segment. The sentence farthest from the prerequisite match is considered the last sentence. 3. {"from":1,"to":-1}: All sentences after the prerequisite match. 4. {"from":0,"to":2}: The prerequisite match sentence plus the next two sentences spoken by the specified role. This is valid only if the current and prerequisite conditions apply to the same role.
5. These are only examples. You can use any positive or negative integers. Positive numbers count forward from the start of the segment, and negative numbers count backward from the end.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| Code |
string |
Result code. 200 means success. Any other value indicates failure. Use this field to diagnose errors. |
200 |
| Message |
string |
Error details if the call fails. successful if successful. |
successful |
| RequestId |
string |
Request ID. |
4987D326-83D9-4A42-B9A5-0B27F9B40539 |
| Success |
boolean |
Whether the request succeeded. Use this field to verify success:
|
true |
| Data |
object |
||
| RidInfo |
array |
Rule IDs. |
|
|
string |
Rule ID. |
318 |
Examples
Success response
JSON format
{
"Code": "200",
"Message": "successful",
"RequestId": "4987D326-83D9-4A42-B9A5-0B27F9B40539",
"Success": true,
"Data": {
"RidInfo": [
"318"
]
}
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.