UploadData

Updated at:

Upload offline plain text quality inspection data (plain text sessions). This applies to online agent scenarios. Use the UploadDataV4 API. Differences between UploadDataV4 and UploadData include the following: UploadDataV4 supports only POST requests, and it supports longer JsonStr values.

Note

This API has been deprecated. We recommend migrating to Qualitycheck(2019-01-15) - UploadDataV4 for enhanced functionality and continued support. While the deprecated API remains temporarily accessible, no further updates or bug fixes will be provided.

Operation description

You can call UploadData.json to upload text-based quality inspection data. Text typically originates from online customer service interactions or tickets. The API returns a task ID. You can retrieve results in one of three ways:

  • Message notification: For details, see message queues. After you receive a message, call the GetResult API to retrieve detailed results. (Recommended)

  • Callback: Specify a callback URL in your request parameters. After the task completes, the system sends a callback to that URL. Then call the GetResult API to retrieve detailed results.

  • Polling: Use the returned task ID to poll the GetResult API asynchronously. Check whether the status field 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:UploadData

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 API. See the JsonStr property description below.

xxx

BaseMeAgentId

integer

No

Workspace ID. Use this to select a specific workspace in multi-workspace scenarios. Defaults to the default workspace.

123456

JsonStr property description

PropertyTypeRequiredDescription
ticketsListYesText data to inspect. Each element is a full conversation. See the JsonStr.tickets property description
businessStringNoLine-of-business name. Used for classification and reporting. All data in this request must belong to the same line of business.
callbackUrlStringNoWebhook address. If not specified, no callback occurs. Ensure the webhook address is reachable from your SCA application. IP addresses are not supported. The system sends a callback after quality inspection completes. For details, see the Callback parameter description

JsonStr.tickets property description

PropertyTypeRequiredDescription
dialogueListYesText-based dialogue to inspect. See the dialogue property description
tidStringNoConversation ID. Avoid duplicates. If omitted, the system generates a UUID.
fileNameStringNoFile name.
customerServiceIdLongNoAgent ID. Get it from the console: Basic Settings > Agent Management. Enter the correct agent ID so agents can view associated files when they log on to the Control Tower.
customerServiceNameStringNoAgent name.
skillGroupIdStringNoSkill group ID for the agent.
skillGroupNameStringNoSkill group name for the agent.
callTypeIntegerNoCall type. Valid values: 1 (outbound), 3 (inbound). Use this when you run your own speech-to-text service and upload plain text directly to SCA.
sessionGroupIdStringNoSession group ID. A session group includes all conversations between one agent and one customer. When you provide this ID, you can view quality inspection results at the session group level on the session group results page.
customerIdStringNoCustomer ID.
customerNameStringNoCustomer name.
schemeTaskConfigIdStringNoManual quality inspection task ID. If set, SCA uses this task for inspection.
remark1StringNoCustom field 1. Store business-specific data. Maximum length: 64 characters.
remark2StringNoCustom field 2. Store business-specific data. Maximum length: 64 characters.
remark3StringNoCustom field 3. Store business-specific data. Maximum length: 64 characters.
remark4StringNoCustom field 4. Store business-specific data. Maximum length: 64 characters.
remark5LongNoCustom field 5. Store business-specific data as a signed long integer.
remark6StringNoCustom field 6. Store business-specific data. Maximum length: 1024 characters.
remark7StringNoCustom field 7. Store business-specific data. Maximum length: 64 characters.
remark8StringNoCustom field 8. Store business-specific data. Maximum length: 64 characters.
remark9StringNoCustom field 9. Store business-specific data. Maximum length: 64 characters.
remark10StringNoCustom field 10. Store business-specific data. Maximum length: 64 characters.
remark11StringNoCustom field 11. Store business-specific data. Maximum length: 64 characters.
remark12StringNoCustom field 12. Store business-specific data. Maximum length: 64 characters.
remark13StringNoCustom field 13. Store business-specific data. Maximum length: 64 characters.
remark14LongNoCustom field 14. Store business-specific data as a signed long integer.
remark15LongNoCustom field 15. Store business-specific data as a signed long integer.
remark16StringNoCustom field 16. Store business-specific data. Maximum length: 64 characters.
remark17StringNoCustom field 17. Store business-specific data. Maximum length: 64 characters.
remark18StringNoCustom field 18. Store business-specific data. Maximum length: 64 characters.
remark19StringNoCustom field 19. Store business-specific data. Maximum length: 64 characters.
remark20StringNoCustom field 20. Store business-specific data. Maximum length: 64 characters.
remark21StringNoCustom field 21. Store business-specific data. Maximum length: 64 characters.
remark22StringNoCustom field 22. Store business-specific data. Maximum length: 64 characters.
remark23StringNoCustom field 23. Store business-specific data. Maximum length: 64 characters.
remark24StringNoCustom field 24. Store business-specific data. Maximum length: 64 characters.
remark25StringNoCustom field 25. Store business-specific data. Maximum length: 64 characters.
jsonParamStrStringNoAdditional custom fields. Format as a JSON string. Keys are field names. Values are field contents. Example: {"Customer Level": 3,"Channel":"Official Website"}.

dialogue property description

PropertyTypeRequiredDescription
roleStringYesSpeaker role. Valid values: agent, customer.
customerServiceTypeIntegerNoDistinguishes human agents from bots. Valid values: 0 (human), 1 (bot). Default: 0. If set to 1, the review page shows a bot profile picture.
identityStringNoSpecific identity of the speaker.
wordsStringYesOne utterance by this speaker. Supports UTF-8 encoding only. For emoji support, see the Emoji display notes
typeStringNoUtterance type. Valid values: TEXT (text), AUDIO (audio), IMAGE (image). Images appear on the review details page. Audio plays on the review details page. Default: TEXT. For AUDIO or IMAGE, pass the resource URL in the words field. (Applies only to the new Smart Conversation Analysis)
beginIntegerYesStart time of this utterance, relative to the start point. Unit: milliseconds.
endIntegerYesEnd time of this utterance, relative to the start point. Unit: milliseconds.
beginTimeDateYesStart time of this utterance. Example: 2019-11-25 15:37:16.

Emoji display notes

On the review details page, only standard Emoji characters display. When uploading, replace emojis with UTF-8 character codes such as 😀. For example, the smiley face emoji is 😀. Codes start with &# and end with a semicolon. For more information, see the Emoji character reference table and the HTML character display guide.

Callback parameter description

If you specify the callback URL http://aliyun.com/callback, the full callback URL becomes http://aliyun.com/callback?taskId=xxx&timestamp=xxx&signature=xxx&event=xxx. Parameters:

  • taskId: Task ID.

  • timestamp: UNIX timestamp of the callback request. Unit: milliseconds.

  • aliUid: Alibaba Cloud account UID of the caller.

  • signature: Signature used to verify the request originated from Alibaba Cloud. Compute it by applying MD5 then Base64 encoding to the string taskId=xxx&timestamp=xxx&aliUid=xxx. Maintain the parameter order. After receiving the callback, extract taskId and timestamp from the URL. Use your Alibaba Cloud account UID as aliUid. Compare your computed signature with the one in the URL. See the Java code example below.

  • event: Event name. Use this to identify which event triggered the callback. Valid value: TaskComplete (sent when the task completes).

public static void signature() {
    long timestamp = System.currentTimeMillis();
    String taskId = "xxxx";
    String aliUid = "xxxxx";
    // Apply MD5 then Base64 encoding to "taskId=xxx&timestamp=xxx&aliUid=xxx", and place result 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": "Zhang San 1",
      "customerId": "zhangsan-vip-audio",
      "dialogue": [
        {
          "beginTime": "2019-11-25 15:36:01",
          "role": "customer",
          "identity": "A customer",
          "emotionValue": 6,
          "speechRate": 153,
          "words": "Hello.",
          "end": 2580,
          "begin": 1800,
          "channelId": 1
        },
        {
          "beginTime": "2019-11-25 15:37:01",
          "role": "agent",
          "identity": "An agent",
          "emotionValue": 6,
          "speechRate": 153,
          "words": "How can I help you? What would you like to buy? Please tell me.",
          "end": 2580,
          "begin": 1800,
          "channelId": 1
        },
        {
          "beginTime": "2019-11-25 15:37:06",
          "role": "agent",
          "identity": "An agent",
          "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\": \"Zhang San 1\",\n" +
                "            \"customerId\": \"zhangsan-vip-audio\",\n" +
                "            \"dialogue\":[\n" +
                "                 {\n" +
                "                    \"beginTime\":\"2019-11-25 15:36:01\",\n" +
                "                    \"role\":\"customer\",\n" +
                "                    \"identity\":\"A customer\",\n" +
                "                    \"emotionValue\":6,\n" +
                "                    \"speechRate\":153,\n" +
                "                    \"words\":\"Hello.\",\n" +
                "                    \"end\":2580,\n" +
                "                    \"begin\":1800,\n" +
                "                    \"channelId\":0\n" +
                "                },\n" +
                "                {\n" +
                "                    \"beginTime\":\"2019-11-25 15:37:01\",\n" +
                "                    \"role\":\"agent\",\n" +
                "                    \"identity\":\"An agent\",\n" +
                "                    \"emotionValue\":6,\n" +
                "                    \"speechRate\":153,\n" +
                "                    \"words\":\"How can I help you? What would you like to buy? Please tell me.\",\n" +
                "                    \"end\":2580,\n" +
                "                    \"begin\":1800,\n" +
                "                    \"channelId\":1\n" +
                "                },\n" +
                "                {\n" +
                "                    \"beginTime\":\"2019-11-25 15:37:06\",\n" +
                "                    \"role\":\"customer\",\n" +
                "                    \"identity\":\"A customer\",\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" +
                "}";

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

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

        result.setJsonStr(json);

        UploadDataResponse response = client.uploadData(result);
        System.out.println(JSONObject.toJSONString(response));
    }


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

Response elements

Element

Type

Description

Example

object

Code

string

Result code. 200 means success. Any other value means failure. Use this field to diagnose failures.

200

Message

string

Error details if the request failed. Returns successful if the request succeeded.

successful

Data

string

Task ID for this request.

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

RequestId

string

Request ID. A unique identifier for this request. Use it to trace the request.

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

Success

boolean

Indicates whether the request succeeded. true means success. false or null means failure.

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.