CreateTask - Analyze conversations with Tongyi Xiaomi CCAI by uploading offline task data
Creates an offline asynchronous task for conversation analysis. Applications are called over HTTP.
Operation description
Before using this API, review the billing methods and pricing for the Tongyi Xiaomi CCAI-Conversation Analysis AIO product.
Prerequisites
-
- Activate the Tongyi Xiaomi CCAI-Conversation Analysis AIO service.
-
- Create an application: create a Tongyi Xiaomi CCAI-Conversation Analysis AIO application in the Application Center and obtain the APP-ID and WORKSPACE-ID: Obtain the APP-ID and WORKSPACE-ID.
Notes
-
- Task data is retained on the server for 90 days.
-
- Conversation text is limited to 20,000 characters. Content beyond this limit is automatically truncated.
-
- An 8 kHz sample rate is recommended for audio files. Other sample rates affect the final results.
Debug
You can run this API directly in OpenAPI Explorer without having to calculate signatures. After a successful run, OpenAPI Explorer can automatically generate SDK code examples.
Authorization information
No authorization information is available for this API operation.
Request syntax
POST /{workspaceId}/ccai/app/{appId}/createTask HTTP/1.1
Request parameters
| Name | Type | Required | Description | Example |
|---|---|---|---|---|
| workspaceId | string | No | The workspace ID. | llm-ik******RVYCKzt |
| appId | string | No | The application ID. | a070a49c681f4a95a0f0*********35c |
| body | object | No | The request body. | |
| dialogue | object | No | The conversation content items. | |
| sentences | array<object> | Yes | The conversation content. | |
| object | No | The conversation content. | ||
| role | string | Yes | The speaker role.
| user |
| text | string | Yes | The conversation text. | How can I apply for a new card? |
| sessionId | string | No | The customer service session ID (sessionId). | session-01 |
| examples | object | No | An example instruction. | |
| output | string | No | An example output. | Issue: asked when version 2.2 will be released. Resolution: informed the customer. |
| sentences | array<object> | Yes | An example conversation. | |
| object | Yes | An example conversation. | ||
| role | string | Yes | The speaker role.
| user |
| text | string | Yes | The conversation text. | When will it be updated? |
| fields | array<object> | No | The field structure. | |
| object | Yes | The field structure. | ||
| code | string | No | The field code. | phoneNumber |
| desc | string | Yes | The field description. | The reason for the customer call, such as a complaint, a question, or a policy suggestion. |
| enumValues | array<object> | No | The enumerated values. | |
| object | Yes | The enumerated values. | ||
| desc | string | Yes | The description of the enumerated value. | The customer has a new requirement/new scenario, and the customer service agent follows up to discuss the details. |
| enumValue | string | Yes | The enumerated value. | New business expansion |
| name | string | Yes | The field name. | The call reason category. |
| modelCode | string | Yes | The model code. | tyxmTurbo |
| resultTypes | array | No | The model processing type. | |
| string | Yes | summary: conversation summary; title: title generation; fields: field extraction; keywords: keyword extraction; service_inspection: service quality inspection; question_solution: issues and solutions; questions_and_answer: Q&A extraction; custom_prompt: custom instructions. | summary | |
| serviceInspection | object | No | The service quality inspection structure. | |
| inspectionContents | array<object> | Yes | The service quality inspection dimension structure. | |
| object | Yes | The service quality inspection dimension structure. | ||
| content | string | Yes | The description of the service quality inspection dimension. | Whether the customer service agent makes promises beyond the established service standards. For example, if the earliest delivery time is 12 hours, the agent must not promise an earlier delivery. |
| title | string | Yes | The name of the service quality inspection dimension. | Whether the customer service agent overpromises |
| inspectionIntroduction | string | Yes | The detailed description of the service quality inspection scenario. | Check whether the customer service agent behaves inappropriately, such as overpromising or deliberately eliciting customers' private information. |
| sceneIntroduction | string | Yes | The service quality inspection scenario. | Insurance sales |
| taskType | string | Yes | The task type. audio: audio file. text: text. | text |
| templateIds | array | No | The template IDs. | |
| string | Yes | The template ID. If both a template ID and an instruction task type are specified, the template ID takes precedence. | 34 | |
| transcription | object | No | The execution parameters for audio tasks. | |
| autoSplit | integer | No | Specifies whether to automatically distinguish speakers in single-channel audio. 0: enable automatic recognition. 1: disable automatic recognition. Default: 1. Applies only to audio files with an 8 kHz sample rate. | 1 |
| clientChannel | integer | No | For dual-channel recordings, the channel number for the customer. Valid values: 0 and 1. Default: 1, which means channel 1 is the customer. Channels are typically numbered from 0, so a two-channel recording has channels 0 and 1. Confirm which channel contains the agent and which contains the customer. **When using this parameter, you must set autoSplit to 0.** This parameter is ignored for single-channel files. | 1 |
| fileName | string | Yes | The file name. | sss.mp3 |
| serviceChannel | integer | No | For dual-channel recordings, the channel number for the customer service agent. Valid values: 0 and 1. Default: 0, which means channel 0 is the agent. Channels are typically numbered from 0, so a two-channel recording has channels 0 and 1. Confirm which channel contains the agent and which contains the customer. **When using this parameter, you must set autoSplit to 0.** This parameter is ignored for single-channel files. | 1 |
| serviceChannelKeywords | array | No | Primarily for single-channel recordings, a list of distinctive keywords that the customer service agent may say. The transcription is analyzed sentence by sentence from beginning to end. If a sentence matches a keyword, that speaker is identified as the agent and the other speaker as the customer. | |
| string | No | Primarily for single-channel recordings, a list of distinctive keywords that the customer service agent may say. The transcription is analyzed sentence by sentence from beginning to end. If a sentence matches a keyword, that speaker is identified as the agent and the other speaker as the customer. | Hello | |
| voiceFileUrl | string | Yes | The file URL. | http://1111.com/sss.mp3 |
| asrModelCode | string | No | The speech transcription model. Valid values: asr (small model) and paraformer (large model). | asr |
| level | string | No | The speech transcription priority. | low |
| vocabularyId | string | No | The speech hotword vocabulary ID. | esnvknv*****skdnvjksd |
| roleIdentification | boolean | No | Specifies whether to automatically identify speaker roles. true: enable automatic identification. false: disable automatic identification. Default: false. | true |
| languageHints | string | No | The recognition language. Default: Mandarin Chinese. For other supported languages and dialects, contact customer service. | zh |
| customPrompt | string | No | The custom instruction. | Summarize the call. |
| variables | array<object> | No | The variables. | |
| object | No | The variables. | ||
| variableCode | string | No | The variable code. | name |
| variableValue | string | No | The variable value. | Zhang San |
| categoryTags | array<object> | No | The label categories. | |
| object | No | The label categories. | ||
| tagName | string | No | The label name. | Agent overpromising |
| tagDesc | string | No | The label description. | Whether the customer service agent makes promises beyond the established service standards. |
| responseFormatType | string | No | The output format. jsonObject: JSON structure. text: raw string. | jsonObject |
| callBackUrl | string | No | The callback parameters used when the task is complete. | 123.456.com/callback |
Speech recognition parameters
When uploading an audio file, you must use serviceChannel or clientChannel to specify the channels for different roles. The backend service identifies roles by channel. Alternatively, use serviceChannelKeywords to set keywords from the agent's speech, and the backend service identifies roles by those keywords.
Callback parameters
If the callback URL passed in by the caller is http://aliyun.com/callback, the complete URL for the callback is http://aliyun.com/callback?taskId=xxx&timestamp=xxx&taskType=xxx&signature=YOUR_SIGNATURE&&success=xxx, where:
- taskId: the task ID.
- timestamp: the timestamp of the call, in milliseconds.
- taskType: the task type.
- success: whether the task succeeded.
- signature: the signature. The caller can use it to determine whether the request comes from Alibaba Cloud. Calculation: apply MD5 and then Base64 encoding to taskId=xxx×tamp=xxx&aliUid=xxx in this exact order. When the callback arrives, taskId and timestamp can be obtained from the callback URL, and aliUid is the Alibaba Cloud primary account ID. Compare the signature you calculate with the signature in the URL to check whether they match. For details, see the following Java code example.
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
public class Sample {
public static void signature() {
long timestamp = System.currentTimeMillis();
String taskId = "xxx";
String aliUid = "xxx";
// 将 taskId=xxx×tamp=xxx&aliUid=xxx 进行 md5 + base64 加密,放在 signature 字段
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 编码必须为 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);
}
}
Response parameters
| Name | Type | Description | Example |
|---|---|---|---|
| object | Schema of Response | ||
| data | object | The data. | |
| taskId | string | The task ID. | 20240905-********-93E9-5D45-B4EF-045743A34071 |
| requestId | string | The request ID. | 9F1DB065-AE0D-5EE3-B1AF-48632CB0831C |
| success | string | Indicates whether the request succeeded. | True |
Examples
Sample success response
JSON format
{
"data": {
"taskId": "20240905-********-93E9-5D45-B4EF-045743A34071"
},
"requestId": "9F1DB065-AE0D-5EE3-B1AF-48632CB0831C",
"success": "True"
}
Error codes
| HTTP status code | Error code | Error message | Description |
|---|---|---|---|
| 400 | CCAI.InvalidParam.NotExist | The specified parameter %s is not valid. | The request parameter does not exist. |
| 400 | CCAI.ParamInvalid.IllegalParamValue | The parameter value of the request API is illegal %s. | The parameter value of the request API is illegal. |
| 400 | CCAI.Throttling.Qpm | Trigger QPM flow restriction. Please purchase higher QPM for paid API. If free API has special requirements, please contact us through DingTalk group (62730018475). | Trigger QPM flow restriction. For paid APIs, purchase a higher QPM. If free APIs have special requirements, contact us through the DingTalk group (62730018475). |
| 400 | CCAI.Throttling.Qps | Trigger current QPS limit, pay API please buy higher QPS, the free API if you have special requirements, please contact us through the DingTalk group (62730018475). | Trigger flow restriction. For paid APIs, purchase a higher QPS. If free APIs have special requirements, contact us through the DingTalk group (62730018475). |
| 403 | CCAI.IllegalPermission.NoAuth | User not authorized to operate on the specified resource. | The user is not authorized to operate the specified resource |
| 403 | CCAI.ParamNotfound.MissParam | Parameter verification failed, The specified parameter %s is missing. | Parameter validation failed. The specified parameter is missing. |
| 403 | CCAI.TenantPermission.NoAuth | The current account does not have the permission to specify the business space. Please authorize the business space permission. | The current account does not have the permission to specify the business space. Please authorize the business space permission. |
| 429 | Ccai.Throttling.Qps | Trigger current QPS limit, pay API please buy higher QPS, free API if you have special requirements, please contact us through the DingTalk group (62730018475). | Invalid error code; scheduled for removal. |
| 500 | CCAI.InternalError | The request processing has failed due to some unknown error, exception or failure. | Internal system error. Try again later. |
See the Error Center for more error codes.