The conversation fraud detection service detects potential fraud in outbound telemarketing calls. You can use this service for voice quality inspection.
This service is provided by the NLP Self-Learning Platform. You can use the service by calling the API directly.
Service activation and resource plan purchase
Before you use the service, confirm that it is activated. After the service is activated, you can purchase a resource plan.
Service activation: Activation page
Resource plan purchase: Purchase page
Service invocation and debugging
For more information about model invocation, see Model Invocation.
For more information about software development kit (SDK) examples, see SDK Examples.
Debug
Configure access credentials (AKSK) using environment variables
Notes:
An Alibaba Cloud account AccessKey has full permissions for all APIs, which poses a high security risk. We strongly recommend that you create and use a Resource Access Management (RAM) user for API access or daily operations and maintenance (O&M). To create a RAM user, log on to the RAM console.
Do not hard-code your AccessKey ID and AccessKey secret in your code. This practice can lead to key leakage. Instead, configure environment variables to store and access your AccessKey pair.
Configuration method for Linux and macOS
export NLP_AK_ENV=<ACCESS_KEY_ID> export NLP_SK_ENV=<access_key_secret>Replace <access_key_id> with your AccessKey ID and <access_key_secret> with your AccessKey secret. For more information about how to obtain an AccessKey ID and an AccessKey secret, see Step 2: Obtain an AccessKey for an account.
Method for configuring Windows
Create an environment variable file. Add the
NLP_AK_ENVandNLP_SK_ENVenvironment variables, and set their values to your AccessKey ID and AccessKey secret.Restart the Windows operating system.
Java code example
class MsgDO{
private String role;
private String words;
public MsgDO(String role,String words) {
this.role = role;
this.words = words;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getWords() {
return words;
}
public void setWords(String words) {
this.words = words;
}
}
/**
* An Alibaba Cloud account AccessKey has permissions to access all APIs. This poses a high security risk. We strongly recommend that you create and use a RAM user to make API calls or perform routine O&M. To create a RAM user, log on to the RAM console.
* This example shows how to store the AccessKey ID and AccessKey secret in environment variables. You can also store them in a configuration file as needed.
* We strongly recommend that you do not hard-code your AccessKey ID and AccessKey secret into your code. This can lead to security risks if the keys are leaked.
*/
String accessKeyId = System.getenv("NLP_AK_ENV");
String accessKeySecret = System.getenv("NLP_SK_ENV");
DefaultProfile defaultProfile = DefaultProfile.getProfile("cn-hangzhou",accessKeyId,accessKeySecret);
IAcsClient client = new DefaultAcsClient(defaultProfile);
Map<String, Object> obj = new HashMap<String, Object>();
List<MsgDO> msgs = new ArrayList<MsgDO>();
msgs.add(new MsgDO("Customer Service","This is the police department."));
msgs.add(new MsgDO("Customer","Hello"));
msgs.add(new MsgDO("Customer Service","Can I add you on QQ?"));
obj.put("msgs",msgs);
obj.put("session_id",123);
RunPreTrainServiceRequest request = new RunPreTrainServiceRequest();
request.setServiceName("NLP-Dialog-Fraud");
request.setPredictContent(JSON.toJSONString(obj));
RunPreTrainServiceResponse response = client.getAcsResponse(request);
System.out.println(response.getPredictResult());Python code example
# Install dependencies
pip install aliyun-python-sdk-core
pip install aliyun-python-sdk-nlp-automl# -*- coding: utf8 -*-
import json
import os
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdknlp_automl.request.v20191111 import RunPreTrainServiceRequest
/**
* An Alibaba Cloud account AccessKey has permissions to access all APIs. This poses a high security risk. We strongly recommend that you create and use a RAM user to make API calls or perform routine O&M. To create a RAM user, log on to the RAM console.
* This example shows how to store the AccessKey ID and AccessKey secret in environment variables. You can also store them in a configuration file as needed.
* We strongly recommend that you do not hard-code your AccessKey ID and AccessKey secret into your code. This can lead to security risks if the keys are leaked.
*/
access_key_id = os.environ['NLP_AK_ENV']
access_key_secret = os.environ['NLP_SK_ENV']
# Initialize AcsClient instance
client = AcsClient(
access_key_id,
access_key_secret,
"cn-hangzhou"
);
content = {
"session_id": 123,
"msgs":[
{
"role": "Customer Service",
"words": "This is the police department."
},
{
"role": "Customer",
"words": "Hello "
},
{
"role": "Customer Service",
"words": "Can I add you on QQ? "
}
]
}
# Initialize a request and set parameters
request = RunPreTrainServiceRequest.RunPreTrainServiceRequest()
request.set_ServiceName("NLP-Dialog-Fraud")
request.set_PredictContent(json.dumps(content))
# Print response
response = client.do_action_with_exception(request)
resp_obj = json.loads(response)
predict_result = json.loads(resp_obj['PredictResult'])
print(predict_result)PredictContent example
{
"session_id": 123,
"msgs":[
{
"role": "Customer Service",
"words": "This is the police department."
},
{
"role": "Customer",
"words": "Hello "
},
{
"role": "Customer Service",
"words": "Can I add you on QQ? "
}
]
}PredictResult example
{
'session_id': '123',
'cost': '82.554ms',
'result': 'Suspected Fraud',
'code': 'SUCCESS'
}Request parameters
Parameter | Description |
session_id | A unique ID for the current request. This parameter is a string. Include this parameter to help with troubleshooting. The value can be an MD5 hash, or a random number plus a timestamp. This parameter is required. |
msgs | The conversation content. This parameter is required. |
role | The role of the speaker. Valid values are `Customer Service` and `Customer`. |
words | The content spoken by the speaker. |
Response parameters
Parameter | Description |
session_id | The unique ID. |
result | `Normal` or `Suspected Fraud`. |
code | The status of the query. `SUCCESS` indicates a successful query. `INVALID_INPUT_FORMAT` indicates an invalid input format. `FIELD_MISSING` indicates that a required field is missing. `INVALID_TEXT_VALUE` indicates that the `msgs` field has no valid value. |
cost | The time taken for the query. |