UploadRule

Updated at:

Creates a rule. You can use this operation to provide your own rule editing interface.

Operation description

Note

For more information, see Rule configuration.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

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

PropertyTypeRequiredDescription
appKeyStringYesTag for the business party or scenario.
conditionsListYesDetailed configuration for all conditions. For details, see ConditionBasicInfo below.
rulesListYesRule configuration. For details, see RuleInfo below.

Condition configuration: ConditionBasicInfo

PropertyTypeRequiredExample valueDescription
cidStringYes"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_rangeCheckRangeYesSee CheckRangeScope of condition evaluation.
operatorsListYesSee OperatorBasicInfoOperators in this condition.
lambdaStringYesOne operator: "1". Multiple operators: 1&&2&&3Logical 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

PropertyTypeRequiredExample valueDescription
roleStringNoAgentTarget role. Valid values: "Agent", "Customer". If omitted, applies to all roles.
anchorAnchorNoSee AnchorPrerequisite condition details.
rangeStringNo{"from":1,"to":3}Evaluation range. For usage details, see Range usage notes later in this document.

Anchor

PropertyTypeRequiredExample valueDescription
cidStringYes"3"Condition ID (cid) of the prerequisite condition. Identifies which condition serves as the anchor.
locationStringYesAROUNDSpecifies 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_timeIntegerYes3How 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

PropertyTypeRequiredExample valueDescription
oidStringYes"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.
nameStringYesMy operator nameOperator name and description.
typeStringYesINCLUDE_KEYWORDSOperator type. For details, see Param below.
paramParamYesSee ParamOperator 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).

PropertyTypeRequiredExample valueDescription
keywordsListYes["Hello", "Hi", "Good morning"]List of keywords.
contextChatMatchBooleanNofalseWhether to analyze multiple sentences together. Valid values: true (multi-sentence analysis), false (single-sentence analysis). Default: false. See Detailed analysis modes
keywordMatchSizeIntegerNo3Number 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_sentenceBooleanNotrueWhether 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.
keywordExtensionIntegerNo0Whether 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)

PropertyTypeRequiredExample valueDescription
regexStringYesSee code example belowRegular expression to match.
notRegexStringNoSee code example belowRegular expression to exclude.
in_sentenceBooleanNotrueWhether 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)

PropertyTypeRequiredExample valueDescription
similarlySentencesListYesSee code example belowExample sentences. Maximum 200 sentences. Each sentence can be up to 50 characters long.
scoreIntegerNo80Similarity 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)

PropertyTypeRequiredExample valueDescription
fromIntegerNo3Maximum gap (in sentences) between repeated sentences. Default: 2. For example, if set to 2, repetition within the last two sentences triggers a violation.
hit_timeIntegerNo2Which repetition triggers a violation. Default: 1.
thresholdIntegerNo5Minimum sentence length (in characters) to check. Sentences shorter than this value are skipped. Default: 4.
excludesListNo["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)

PropertyTypeRequiredExample valueDescription
intervalIntegerYes5000Silence duration (in milliseconds).
different_roleBooleanNofalseWhether 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.
targetIntegerNo1How 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_endBooleanNofalseWhether 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)

PropertyTypeRequiredExample valueDescription
velocityInMintIntegerYes370Speech speed (characters per minute). Used to determine whether the current sentence exceeds this speed.
minWordSizeIntegerNo4Minimum sentence length (in characters) to check. Sentences shorter than this value are skipped.
averageBooleanNofalseWhether 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)

PropertyTypeRequiredExample valueDescription
intervalIntegerYes5000Overlap time (in milliseconds). Calculated as the customer’s speech end time minus the agent’s speech start time.
thresholdIntegerNo4Minimum sentence length (in characters) to check for interruptions.
delayTimeIntegerNo1000Delay 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.

PropertyTypeRequiredExample valueDescription
target_roleStringYesCustomerTarget 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.

PropertyTypeRequiredExample valueDescription
intervalIntegerYes5000Time (in milliseconds) between the end of the last sentence and the hang-up.
compareOperatorStringNogtComparison operator for interval. Valid values: gt (greater than), lt (less than). Default: gt.
beginTypeStringYesDIALOGUEFixed value: DIALOGUE.
target_roleStringNoCustomerRole 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)

PropertyTypeRequiredExample valueDescription
intervalIntegerYes5000Recording duration (in milliseconds).
compareOperatorStringNogtComparison operator for interval. Valid values: gt (greater than), lt (less than). Default: gt.
{
    "interval":60000,
    "compareOperator":"lt"
}

11. Energy detection (ASR_EMOTION)

PropertyTypeRequiredExample valueDescription
maxEmotionChangeValueIntegerNo3Energy value. Range: 1–10.
checkTypeIntegerNo3Detection method. Valid values:1: energy fluctuation between adjacent sentences.2: maximum energy span.3: energy range detection.Default: 3.
compareOperatorStringNogtComparison 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.

PropertyTypeRequiredExample valueDescription
pvaluesListNo["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.

PropertyTypeRequiredExample valueDescription
pvaluesListNo["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.

PropertyTypeRequiredExample valueDescription
pvaluesListNo["jifeng01"]Detection type. Valid value: jifeng01 (mockery detection). Default: ["jifeng01"].

Rule configuration: RuleInfo

PropertyTypeRequiredExample valueDescription
ridStringYes1Rule ID. Must be a numeric string. After upload, the system replaces this with an auto-generated ID.
lambdaStringYesOne condition: "". Multiple conditions: a&&b&&cLogical relationship among conditions. Built from condition IDs (cid) and logical operators (AND, OR, NOT). In the example, a, b, and c are condition IDs.
businessListYesSee BusinessCategoryBasicInfoBusinesses this rule applies to. Get this from the Create Rule page. If empty, defaults to "All businesses".
typeIntegerYes1Rule type. Get this from the Create Rule page.
triggersListYes["a","b","c"]Condition IDs (cid) whose results should be returned. When the rule matches, these condition details are included in the response.
NameStringYes"Customer may file a complaint"Rule name.
scoreSubIdIntegerNo3678ID of the scoring sub-item this rule is attached to. Required if attaching to a scoring item.
ruleScoreTypeIntegerNo3Whether this rule contributes to scoring. 1: no contribution. 3: contributes.
levelIntegerNo2Severity level. Used to group rules by severity in review pages. Values: 0 (severe), 1 (moderate), 2 (minor). Default: 2.
fullCycleIntegerNo1When the rule is active. Valid values: 0 (active during a specific period), 1 (always active).
effectiveStartTimeDateNo2021-03-04 04:05:05Start time for a specific active period.
effectiveEndTimeDateNo2021-03-06 04:05:05End time for a specific active period.

BusinessCategoryBasicInfo

PropertyTypeRequiredExample valueDescription
bidIntegerYes267202890Business 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 means success.

  • false or null means failure.

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.