UploadDataV4
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
Test
RAM authorization
|
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
| Property | Type | Required | Description |
| tickets | List | Yes | The text data to be inspected. Each element is a complete conversation. For details, see jsonStr.tickets metric description below. |
| business | String | No | The business line name, used for classification and statistics. All data in this request should belong to the same business line. |
| callbackUrl | String | No | The 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
| Property | Type | Required | Description |
| dialogue | List | Yes | The text conversation to be inspected. For details, see dialogue property description below. |
| tid | String | No | The conversation ID. Ensure it is unique. If not provided, a UUID is randomly generated. |
| fileName | String | No | The text name. |
| voiceFileUrl | String | No | The audio file URL. |
| customerServiceId | Long | No | The 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. |
| customerServiceName | String | No | The customer service representative name. |
| skillGroupId | String | No | The ID of the skill group to which the agent belongs. |
| skillGroupName | String | No | The name of the skill group to which the agent belongs. |
| callType | Integer | No | The 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. |
| sessionGroupId | String | No | The 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. |
| customerId | String | No | The customer ID. |
| customerName | String | No | The customer name. |
| schemeTaskConfigId | String | No | The manually specified quality inspection task ID. When specified, the specified quality inspection task is used for inspection. |
| remark1 | String | No | Custom data 1. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark2 | String | No | Custom data 2. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark3 | String | No | Custom data 3. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark4 | String | No | Custom data 4. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark5 | Long | No | Custom data 5. You can store custom fields related to your business. Format: signed long. |
| remark6 | String | No | Custom data 6. You can store custom fields related to your business. Maximum length: 1024 characters. |
| remark7 | String | No | Custom data 7. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark8 | String | No | Custom data 8. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark9 | String | No | Custom data 9. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark10 | String | No | Custom data 10. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark11 | String | No | Custom data 11. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark12 | String | No | Custom data 12. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark13 | String | No | Custom data 13. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark14 | Long | No | Custom data 14. You can store custom fields related to your business. Format: signed long. |
| remark15 | Long | No | Custom data 15. You can store custom fields related to your business. Format: signed long. |
| remark16 | String | No | Custom data 16. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark17 | String | No | Custom data 17. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark18 | String | No | Custom data 18. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark19 | String | No | Custom data 19. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark20 | String | No | Custom data 20. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark21 | String | No | Custom data 21. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark22 | String | No | Custom data 22. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark23 | String | No | Custom data 23. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark24 | String | No | Custom data 24. You can store custom fields related to your business. Maximum length: 64 characters. |
| remark25 | String | No | Custom data 25. You can store custom fields related to your business. Maximum length: 64 characters. |
| jsonParamStr | String | No | Additional 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
| Property | Type | Required | Description |
| role | String | Yes | The role of the conversation content. Valid values: customer service representative, customer. |
| customerServiceType | Integer | No | Specifies 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. |
| identity | String | No | The specific identity of the conversation role. |
| words | String | Yes | A sentence spoken by this role. Only UTF-8 encoding is supported. If the sentence contains emojis, see Emoji display description below. |
| type | String | No | The 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) |
| begin | Integer | Yes | The start time of this sentence. This is the start time offset relative to the starting point, in ms. |
| end | Integer | Yes | The end time of this sentence. This is the end time offset relative to the starting point, in ms. |
| beginTime | Date | Yes | The 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×tamp=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×tamp=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×tamp=xxx&aliUid=xxx and place it in the signature field
String signature;
try {
signature = URLEncoder.encode(md5Base64("taskId=" + taskId + "×tamp=" + 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.