Best practices for field information extraction
This topic describes best practices for extracting field information using Tongyi Xiaomi CCAI-AIO conversation analysis.
Scenarios
You can use Tongyi Xiaomi CCAI-AIO to extract information from conversation records between customer service agents and users. The service analyzes text and audio files to understand, detect, and extract field information from customer service tickets. This information includes fields such as the customer's region, age, date, time, and requested service. This process improves the efficiency of ticket completion.
Solution overview
To extract field information using Tongyi Xiaomi CCAI-AIO conversation analysis, follow these steps:
- Activate Alibaba Cloud Model Studio. This lets you test the Playground, call models, and use the application experience service.
- Create a Tongyi Xiaomi CCAI-AIO conversation analysis application in Alibaba Cloud Model Studio and obtain the credentials required to call the application's API.
- Call the API to analyze conversations. To do this, install the SDK, and then provide the application information, conversation content, and property descriptions in the API call to extract the properties.
Solution architecture
Activate Alibaba Cloud Model Studio
For more information, see Activate product.
Activate and create a Tongyi Xiaomi CCAI-AIO conversation analysis application
To learn how to activate Tongyi Xiaomi CCAI-AIO Conversation Analysis and create an application, see the User Guide.
Obtain an AccessKey ID and AccessKey secret
If you do not have an AccessKey ID and AccessKey secret, see Obtain an AccessKey and AgentKey.
If you use a RAM user to call the API, see Use and authorize a RAM user for Tongyi Xiaomi CCAI conversation analysis.
Obtain a workspace ID and an app ID
For more information, see Obtain an app ID and a workspace ID.
Install the SDK
Java
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>contactcenterai20240603</artifactId>
<version>3.6.4</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.58</version>
</dependency>
Code example
NoteIn the code example, replace YOUR_WORKSPACEID, YOUR_ACCESS_KEY_ID, YOUR_ACCESS_KEY_SECRET, and YOUR_APPID with your workspace ID, AccessKey ID, AccessKey secret, and app ID. You must replace these placeholder values for the code to run correctly. To prevent key exposure, we recommend that you set the AccessKey ID and AccessKey secret as environment variables.
Synchronous non-streaming call
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.contactcenterai20240603.Client;
import com.aliyun.contactcenterai20240603.models.*;
import com.aliyun.teaopenapi.models.Config;
import java.util.*;
public class CcaiPaasTest {
public static void main(String[] args) throws Exception {
// Configure environment variables to prevent AccessKey pair exposure.
String accessKeyId = "YOUR_ACCESS_KEY_ID";
String accessKeySecret = "YOUR_ACCESS_KEY_SECRET";
String workspaceId = "YOUR_WORKSPACEID";
String appId = "YOUR_APPID";
Config config = new Config();
config.setAccessKeyId(accessKeyId).setAccessKeySecret(accessKeySecret).setEndpoint("contactcenterai.cn-shanghai.aliyuncs.com")
.setRegionId("cn-shanghai").setProtocol("HTTPS");
Client client = new Client(config);
AnalyzeConversationRequest request = new AnalyzeConversationRequest();
AnalyzeConversationRequest.AnalyzeConversationRequestDialogue dialogue = new AnalyzeConversationRequest.AnalyzeConversationRequestDialogue();
// Conversation content
List<AnalyzeConversationRequest.AnalyzeConversationRequestDialogueSentences> sentenceList = new ArrayList<>();
AnalyzeConversationRequest.AnalyzeConversationRequestDialogueSentences sentences1 = new AnalyzeConversationRequest.AnalyzeConversationRequestDialogueSentences();
sentences1.setRole("agent");
sentences1.setText("Hello, this is XXX Insurance Company. How can I help you?");
sentenceList.add(sentences1);
AnalyzeConversationRequest.AnalyzeConversationRequestDialogueSentences sentences2 = new AnalyzeConversationRequest.AnalyzeConversationRequestDialogueSentences();
sentences2.setRole("user");
sentences2.setText("Yes, I'd like to get a health insurance plan. Can you tell me about my options?");
sentenceList.add(sentences2);
dialogue.setSentences(sentenceList);
dialogue.setSessionId("session-adslsddxxxx");
request.setDialogue(dialogue);
// Field name and description for extraction
List<AnalyzeConversationRequest.AnalyzeConversationRequestFields> fieldList = new ArrayList<>();
AnalyzeConversationRequest.AnalyzeConversationRequestFields field1 = new AnalyzeConversationRequest.AnalyzeConversationRequestFields();
field1.setName("Question Type");
field1.setDesc("The type of question asked by the customer");
fieldList.add(field1);
AnalyzeConversationRequest.AnalyzeConversationRequestFields field2 = new AnalyzeConversationRequest.AnalyzeConversationRequestFields();
field2.setName("Company Name");
field2.setDesc("The name of the insurance company where the agent works");
fieldList.add(field2);
request.setFields(fieldList);
// "fields" indicates a property extraction task
request.setResultTypes(Arrays.asList("fields"));
request.setStream(false);
com.aliyun.contactcenterai20240603.models.AnalyzeConversationResponse response = client.analyzeConversation(workspaceId, appId, request);
System.out.println(JSONObject.toJSONString(response));
}
}