UploadDataV4

Updated at:

Uploads offline text quality inspection data (plain text conversations) applicable to online agent scenarios. We recommend using the UploadDataV4 operation. Differences between UploadDataV4 and UploadData: 1. V4 supports only POST requests. 2. V4 supports longer JsonStr values.

Operation description

Calls UploadData.json to upload text quality inspection data. The text typically comes from online customer service or tickets. The operation returns a taskId. You can obtain results in three ways:

  • Message notification: For details, see Message channel. After receiving a message, call the GetResult operation to obtain detailed results. (Recommended)

  • Callback: Specify a callbackUrl in the request parameters. The system initiates a callback after the task is completed. After receiving the callback, call the GetResult operation to obtain detailed results.

  • Polling: Use the task ID returned by this operation to poll the GetResult operation asynchronously. Check whether the status in the response indicates completion. (Not recommended)

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:UploadDataV4

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

JsonStr

string

Yes

JsonStr is a JSON string that contains all custom parameters for this operation. For details, see the jsonStr property description below.

xxx

BaseMeAgentId

integer

No

The business space ID. Used to specify a business space in multi-business space scenarios. Default value: the default business space.

123456

jsonStr metric description

PropertyTypeRequiredDescription
ticketsListYesThe text data to be inspected. Each element is a complete conversation. For details, see jsonStr.tickets metric description below.
businessStringNoThe business line name, used for classification and statistics. All data in this request should belong to the same business line.
callbackUrlStringNoThe callback URL. If not specified, no callback is initiated. Ensure connectivity between the callback URL and the SCA application. IP addresses are not supported. A callback is initiated after quality inspection analysis is completed. For details, see Callback parameter description below.

jsonStr.tickets property description

PropertyTypeRequiredDescription
dialogueListYesThe text conversation to be inspected. For details, see dialogue property description below.
tidStringNoThe conversation ID. Ensure it is unique. If not provided, a UUID is randomly generated.
fileNameStringNoThe text name.
voiceFileUrlStringNoThe audio file URL.
customerServiceIdLongNoThe customer service representative ID. You can obtain this from the console under Basic Settings > Personnel Management. When the correct ID is provided, the customer service representative can view associated files when logging in to the control tower.
customerServiceNameStringNoThe customer service representative name.
skillGroupIdStringNoThe ID of the skill group to which the agent belongs.
skillGroupNameStringNoThe name of the skill group to which the agent belongs.
callTypeIntegerNoThe call type. Valid values: 1 (outbound), 3 (inbound). This is applicable when you have a local speech-to-text service installed and upload the text directly to the SCA system to specify the call type.
sessionGroupIdStringNoThe session group ID. Typically, conversations between the same customer service representative and the same customer are referred to as a session group. When a session group ID is provided, you can view quality inspection results at the session group level on the session group results page.
customerIdStringNoThe customer ID.
customerNameStringNoThe customer name.
schemeTaskConfigIdStringNoThe manually specified quality inspection task ID. When specified, the specified quality inspection task is used for inspection.
remark1StringNoCustom data 1. You can store custom fields related to your business. Maximum length: 64 characters.
remark2StringNoCustom data 2. You can store custom fields related to your business. Maximum length: 64 characters.
remark3StringNoCustom data 3. You can store custom fields related to your business. Maximum length: 64 characters.
remark4StringNoCustom data 4. You can store custom fields related to your business. Maximum length: 64 characters.
remark5LongNoCustom data 5. You can store custom fields related to your business. Format: signed long.
remark6StringNoCustom data 6. You can store custom fields related to your business. Maximum length: 1024 characters.
remark7StringNoCustom data 7. You can store custom fields related to your business. Maximum length: 64 characters.
remark8StringNoCustom data 8. You can store custom fields related to your business. Maximum length: 64 characters.
remark9StringNoCustom data 9. You can store custom fields related to your business. Maximum length: 64 characters.
remark10StringNoCustom data 10. You can store custom fields related to your business. Maximum length: 64 characters.
remark11StringNoCustom data 11. You can store custom fields related to your business. Maximum length: 64 characters.
remark12StringNoCustom data 12. You can store custom fields related to your business. Maximum length: 64 characters.
remark13StringNoCustom data 13. You can store custom fields related to your business. Maximum length: 64 characters.
remark14LongNoCustom data 14. You can store custom fields related to your business. Format: signed long.
remark15LongNoCustom data 15. You can store custom fields related to your business. Format: signed long.
remark16StringNoCustom data 16. You can store custom fields related to your business. Maximum length: 64 characters.
remark17StringNoCustom data 17. You can store custom fields related to your business. Maximum length: 64 characters.
remark18StringNoCustom data 18. You can store custom fields related to your business. Maximum length: 64 characters.
remark19StringNoCustom data 19. You can store custom fields related to your business. Maximum length: 64 characters.
remark20StringNoCustom data 20. You can store custom fields related to your business. Maximum length: 64 characters.
remark21StringNoCustom data 21. You can store custom fields related to your business. Maximum length: 64 characters.
remark22StringNoCustom data 22. You can store custom fields related to your business. Maximum length: 64 characters.
remark23StringNoCustom data 23. You can store custom fields related to your business. Maximum length: 64 characters.
remark24StringNoCustom data 24. You can store custom fields related to your business. Maximum length: 64 characters.
remark25StringNoCustom data 25. You can store custom fields related to your business. Maximum length: 64 characters.
jsonParamStrStringNoAdditional custom fields in JSON string format. The key is the field name and the value is the field content. Example: {"CustomerLevel": 3,"Channel":"OfficialWebsite"}.

dialogue property description

PropertyTypeRequiredDescription
roleStringYesThe role of the conversation content. Valid values: customer service representative, customer.
customerServiceTypeIntegerNoSpecifies whether the role is a human or a robot. Valid values: 0 (human), 1 (robot). Default value: 0. This field determines whether the avatar displayed on the review page is a robot avatar.
identityStringNoThe specific identity of the conversation role.
wordsStringYesA sentence spoken by this role. Only UTF-8 encoding is supported. If the sentence contains emojis, see Emoji display description below.
typeStringNoThe type of the current sentence. Valid values: TEXT (text), AUDIO (audio), IMAGE (image). Images can be displayed on the review details page. Audio can be played on the review details page. Default value: TEXT. When the value is AUDIO or IMAGE, pass the URL of the corresponding resource in the words field. (Applicable only to the new version of Intelligent Speech Analytics)
beginIntegerYesThe start time of this sentence. This is the start time offset relative to the starting point, in ms.
endIntegerYesThe end time of this sentence. This is the end time offset relative to the starting point, in ms.
beginTimeDateYesThe start time of this sentence. Example: 2019-11-25 15:37:16.

Emoji display description

When viewing conversation details on the review details page, only universal Emoji display is supported. When uploading, replace emojis with characters in the UTF-8 character set. For example, the smiley face emoji corresponds to the character 😀, starting with &# and ending with a semicolon. For more information, see Emoji Character Reference and HTML Page Character Display.

Callback parameter description

Assume the callback URL provided by the caller is http://aliyun.com/callback. The complete callback URL is http://aliyun.com/callback?taskId=xxx&timestamp=xxx&signature=xxx&event=xxx, where:

  • taskId: The task ID.

  • timestamp: The timestamp when the call is made, in milliseconds.

  • aliUid: The Alibaba Cloud primary account UID of the caller.

  • signature: The signature. The caller can use this to verify whether the request is from Alibaba Cloud. Calculation: Perform MD5 + Base64 encryption on taskId=xxx&timestamp=xxx&aliUid=xxx. Note the order. After receiving the callback, the caller can obtain taskId and timestamp from the callback URL. aliUid is the Alibaba Cloud primary account ID. Compare the calculated signature with the signature in the URL to verify consistency. See the Java code example below.

  • event: The event name. The caller can use this to determine which event triggered the callback. Valid values: TaskComplete (callback when the task is completed).

public static void signature() {
    long timestamp = System.currentTimeMillis();
    String taskId = "xxxx";
    String aliUid = "xxxxx";
    // Perform MD5 + Base64 encryption on taskId=xxx&timestamp=xxx&aliUid=xxx and place it in the signature field
    String signature;
    try {
        signature = URLEncoder.encode(md5Base64("taskId=" + taskId + "&timestamp=" + timestamp + "&aliUid=" + aliUid), "utf-8");
        System.out.println(signature);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

public static String md5Base64(String str) throws NoSuchAlgorithmException {
    //string encoding must be utf-8
    byte[] utfBytes = str.getBytes(StandardCharsets.UTF_8);
    MessageDigest mdTemp = MessageDigest.getInstance("MD5");
    mdTemp.update(utfBytes);
    byte[] md5Bytes = mdTemp.digest();
    return Base64.encodeBase64String(md5Bytes);
}

Request parameter example

{
  "callbackUrl": "https://123.123.com/sca-callback",
  "tickets": [
    {
      "schemeTaskConfigId": "389",
      "customerName": "Customer1",
      "customerId": "zhangsan-vip-audio",
      "dialogue": [
        {
          "beginTime": "2019-11-25 15:36:01",
          "role": "客户",
          "identity": "某客户",
          "emotionValue": 6,
          "speechRate": 153,
          "words": "Hello.",
          "end": 2580,
          "begin": 1800,
          "channelId": 0
        },
        {
          "beginTime": "2019-11-25 15:37:01",
          "role": "客服",
          "identity": "某客服",
          "emotionValue": 6,
          "speechRate": 153,
          "words": "How can I help you? Would you like to buy something? Please go ahead.",
          "end": 2580,
          "begin": 1800,
          "channelId": 1
        },
        {
          "beginTime": "2019-11-25 15:37:06",
          "role": "客户",
          "identity": "某客户",
          "emotionValue": 6,
          "speechRate": 305,
          "words": "I want to buy a sweater.",
          "end": 12540,
          "begin": 6770,
          "channelId": 0
        }
      ]
    }
  ]
}

Request code example

public class sca {

    private static String ak = "YOUR_ACCESS_KEY_ID";
    private static String sk = "YOUR_ACCESS_KEY_SECRET";

    private static void uploadText() throws Exception {
        String json="{\n" +
                "    \"callbackUrl\":\"https://123.123.com/sca-callback\",\n" +
                "    \"tickets\":[\n" +
                "        {\n" +
                "            \"schemeTaskConfigId\":\"389\",\n" +
                "            \"customerName\": \"Customer1\",\n" +
                "            \"customerId\": \"zhangsan-vip-audio\",\n" +
                "            \"dialogue\":[\n" +
                "                 {\n" +
                "                    \"beginTime\":\"2019-11-25 15:36:01\",\n" +
                "                    \"role\":\"客户\",\n" +
                "                    \"identity\":\"某客户\",\n" +
                "                    \"emotionValue\":6,\n" +
                "                    \"speechRate\":153,\n" +
                "                    \"words\":\"Hello.\",\n" +
                "                    \"end\":2580,\n" +
                "                    \"begin\":1800,\n" +
                "                    \"channelId\":0,\n" +
                "                    \n" +
                "                },\n" +
                "                {\n" +
                "                    \"beginTime\":\"2019-11-25 15:37:01\",\n" +
                "                    \"role\":\"客服\",\n" +
                "                    \"identity\":\"某客服\",\n" +
                "                    \"emotionValue\":6,\n" +
                "                    \"speechRate\":153,\n" +
                "                    \"words\":\"How can I help you? Would you like to buy something? Please go ahead.\"\",\n" +
                "                    \"end\":2580,\n" +
                "                    \"begin\":1800,\n" +
                "                    \"channelId\":1,\n" +
                "                    \n" +
                "                },\n" +
                "                {\n" +
                "                    \"beginTime\":\"2019-11-25 15:37:06\",\n" +
                "                    \"role\":\"客户\",\n" +
                "                    \"identity\":\"某客户\",\n" +
                "                    \"emotionValue\":6,\n" +
                "                    \"speechRate\":305,\n" +
                "                    \"words\":\"I want to buy a sweater.\",\n" +
                "                    \"end\":12540,\n" +
                "                    \"begin\":6770,\n" +
                "                    \"channelId\":0,\n" +
                "                    \n" +
                "                }\n" +
                "            ],\n" +
                "        }\n" +
                "        \n" +
                "            ]\n" +
                "         \n" +
                "        }";


        Config config = new Config();
        config.setAccessKeyId(ak).setAccessKeySecret(sk).setEndpoint("qualitycheck.ap-southeast-1.aliyuncs.com")
                .setRegionId("ap-southeast-1").setProtocol("HTTPS");

        Client client = new Client(config);
        UploadDataV4Request result = new UploadDataV4Request();

        result.setJsonStr(json);

        UploadDataV4Response response = client.uploadDataV4(result);
        System.out.println(JSONObject.toJSONString(response));
    }


    public static void main(String[] args) throws Exception {
        uploadText();
    }
}

Response elements

Element

Type

Description

Example

object

The response parameters.

Code

string

The result code. A value of 200 indicates success. Other values indicate failure. You can use this field to determine the cause of failure.

200

Message

string

The error details when the request fails. The value is "successful" when the request succeeds.

successful

Data

string

The taskId of the task.

6F5934C7-C223-4F0F-BBF3-5B3594***

RequestId

string

The request ID. A unique identifier for the request that can be used to locate and trace the request.

6F5934C7-C223-4F0F-BBF3-5B3594***

Success

boolean

Indicates whether the request was successful. Valid values: true: successful. false/null: failed.

true

Examples

Success response

JSON format

{
  "Code": "200",
  "Message": "successful",
  "Data": "6F5934C7-C223-4F0F-BBF3-5B3594***",
  "RequestId": "6F5934C7-C223-4F0F-BBF3-5B3594***",
  "Success": true
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.