UploadData
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.
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
Test
RAM authorization
|
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
| Property | Type | Required | Description |
| tickets | List | Yes | Text data to inspect. Each element is a full conversation. See the JsonStr.tickets property description |
| business | String | No | Line-of-business name. Used for classification and reporting. All data in this request must belong to the same line of business. |
| callbackUrl | String | No | Webhook 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
| Property | Type | Required | Description |
| dialogue | List | Yes | Text-based dialogue to inspect. See the dialogue property description |
| tid | String | No | Conversation ID. Avoid duplicates. If omitted, the system generates a UUID. |
| fileName | String | No | File name. |
| customerServiceId | Long | No | Agent 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. |
| customerServiceName | String | No | Agent name. |
| skillGroupId | String | No | Skill group ID for the agent. |
| skillGroupName | String | No | Skill group name for the agent. |
| callType | Integer | No | Call 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. |
| sessionGroupId | String | No | Session 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. |
| customerId | String | No | Customer ID. |
| customerName | String | No | Customer name. |
| schemeTaskConfigId | String | No | Manual quality inspection task ID. If set, SCA uses this task for inspection. |
| remark1 | String | No | Custom field 1. Store business-specific data. Maximum length: 64 characters. |
| remark2 | String | No | Custom field 2. Store business-specific data. Maximum length: 64 characters. |
| remark3 | String | No | Custom field 3. Store business-specific data. Maximum length: 64 characters. |
| remark4 | String | No | Custom field 4. Store business-specific data. Maximum length: 64 characters. |
| remark5 | Long | No | Custom field 5. Store business-specific data as a signed long integer. |
| remark6 | String | No | Custom field 6. Store business-specific data. Maximum length: 1024 characters. |
| remark7 | String | No | Custom field 7. Store business-specific data. Maximum length: 64 characters. |
| remark8 | String | No | Custom field 8. Store business-specific data. Maximum length: 64 characters. |
| remark9 | String | No | Custom field 9. Store business-specific data. Maximum length: 64 characters. |
| remark10 | String | No | Custom field 10. Store business-specific data. Maximum length: 64 characters. |
| remark11 | String | No | Custom field 11. Store business-specific data. Maximum length: 64 characters. |
| remark12 | String | No | Custom field 12. Store business-specific data. Maximum length: 64 characters. |
| remark13 | String | No | Custom field 13. Store business-specific data. Maximum length: 64 characters. |
| remark14 | Long | No | Custom field 14. Store business-specific data as a signed long integer. |
| remark15 | Long | No | Custom field 15. Store business-specific data as a signed long integer. |
| remark16 | String | No | Custom field 16. Store business-specific data. Maximum length: 64 characters. |
| remark17 | String | No | Custom field 17. Store business-specific data. Maximum length: 64 characters. |
| remark18 | String | No | Custom field 18. Store business-specific data. Maximum length: 64 characters. |
| remark19 | String | No | Custom field 19. Store business-specific data. Maximum length: 64 characters. |
| remark20 | String | No | Custom field 20. Store business-specific data. Maximum length: 64 characters. |
| remark21 | String | No | Custom field 21. Store business-specific data. Maximum length: 64 characters. |
| remark22 | String | No | Custom field 22. Store business-specific data. Maximum length: 64 characters. |
| remark23 | String | No | Custom field 23. Store business-specific data. Maximum length: 64 characters. |
| remark24 | String | No | Custom field 24. Store business-specific data. Maximum length: 64 characters. |
| remark25 | String | No | Custom field 25. Store business-specific data. Maximum length: 64 characters. |
| jsonParamStr | String | No | Additional 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
| Property | Type | Required | Description |
| role | String | Yes | Speaker role. Valid values: agent, customer. |
| customerServiceType | Integer | No | Distinguishes human agents from bots. Valid values: 0 (human), 1 (bot). Default: 0. If set to 1, the review page shows a bot profile picture. |
| identity | String | No | Specific identity of the speaker. |
| words | String | Yes | One utterance by this speaker. Supports UTF-8 encoding only. For emoji support, see the Emoji display notes |
| type | String | No | Utterance 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) |
| begin | Integer | Yes | Start time of this utterance, relative to the start point. Unit: milliseconds. |
| end | Integer | Yes | End time of this utterance, relative to the start point. Unit: milliseconds. |
| beginTime | Date | Yes | Start 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×tamp=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×tamp=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×tamp=xxx&aliUid=xxx", and place result 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": "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.