Industry classification for telesales conversation scenarios

更新时间:
复制 MD 格式

The industry classification service for telesales conversation scenarios is designed for outbound telemarketing calls. This service classifies conversational applications by industry and scenario and can be used for voice quality inspection.

Note

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 start, ensure that the service is activated. After the service is activated, you can purchase a resource plan.

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

You can run this operation directly in OpenAPI Explorer to avoid calculating signatures. After a successful call, OpenAPI Explorer automatically generates SDK code examples.

Configure access credentials using environment variables

  1. Notes:

    1. The AccessKey pair of an Alibaba Cloud account has permissions to call all API operations. This poses a high security risk. For improved security, we recommend that you create and use a Resource Access Management (RAM) user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console.

    2. To prevent security risks that arise from key leaks, do not hard-code your AccessKey ID and AccessKey secret in your code. Instead, configure them as environment variables.

  2. Configuring 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 pair.

  3. Configure a Windows system

    1. Create an environment variable file. Add the NLP_AK_ENV and NLP_SK_ENV environment variables and write your AccessKey ID and AccessKey secret to the file.

    2. Restart Windows.

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 AccessKey pair of an Alibaba Cloud account has permissions to call all API operations. This poses a high security threat. For better security, create and use a RAM user to call API operations 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.
 * To prevent key leaks, do not hard-code your AccessKey ID and AccessKey secret in your code.
 */
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","Hello?"));
msgs.add(new MsgDO("Agent","Hi, this is Jiami Arts."));
msgs.add(new MsgDO("Agent","We have a creative painting workshop for children coming up. We would like to invite you to our location at Chengshi Jiayuan on Chengshan Road in the Chongchuan district."));
msgs.add(new MsgDO("Agent","We would like to invite you to our location at Chengshi Jiayuan on Chengshan Road in the Chongchuan district."));
msgs.add(new MsgDO("Customer","Where is that?"));
msgs.add(new MsgDO("Customer","Oh, that's not convenient for me. Okay, thanks. Goodbye."));
obj.put("msgs",msgs);
obj.put("session_id",123);
RunPreTrainServiceRequest request = new RunPreTrainServiceRequest();
request.setServiceName("NLP-Dialog-Industry");
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 AccessKey pair of an Alibaba Cloud account has permissions to call all API operations. This poses a high security threat. For better security, create and use a RAM user to call API operations 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.
 * To prevent key leaks, do not hard-code your AccessKey ID and AccessKey secret in your code.
 */
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",
      "words": "Hello?"
    },
    {
      "role": "Agent",
      "words": "Hi, this is Jiami Arts."
    },
    {
      "role": "Agent",
      "words": "We have a creative painting workshop for children coming up. We would like to invite you to our location at Chengshi Jiayuan on Chengshan Road in the Chongchuan district."
    },
    {
      "role": "Agent",
      "words": "We would like to invite you to our location at Chengshi Jiayuan on Chengshan Road in the Chongchuan district."
    },
    {
      "role": "Customer",
      "words": "Where is that?"
    },
    {
      "role": "Customer",
      "words": "Oh, that's not convenient for me. Okay, thanks. Goodbye."
    }
  ]
}
# Initialize a request and set parameters
request = RunPreTrainServiceRequest.RunPreTrainServiceRequest()
request.set_ServiceName('NLP-Dialog-Industry')
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",
      "words": "Hello?"
    },
    {
      "role": "Agent",
      "words": "Hi, this is Jiami Arts."
    },
    {
      "role": "Agent",
      "words": "We have a creative painting workshop for children coming up. We would like to invite you to our location at Chengshi Jiayuan on Chengshan Road in the Chongchuan district."
    },
    {
      "role": "Agent",
      "words": "We would like to invite you to our location at Chengshi Jiayuan on Chengshan Road in the Chongchuan district."
    },
    {
      "role": "Customer",
      "words": "Where is that?"
    },
    {
      "role": "Customer",
      "words": "Oh, that's not convenient for me. Okay, thanks. Goodbye."
    }
  ]
}

PredictResult example

{
  'session_id': 123,
  'result': [{'prob': 0.5665, 'industry': 'Product Promotion', 'scene': 'Food & Fresh Produce'}], 
  'cost': '1268.513ms',
  'code': 'SUCCESS'
}

Request parameters

Parameter

Description

session_id

A unique string that identifies the current request. This parameter is required. Include this parameter in your requests to help with troubleshooting. The value can be an MD5 hash or a combination of a random number and a timestamp.

msgs

The conversation content. This parameter is required.

role

The role of the speaker. Valid values: `Customer` and `Agent`.

words

The utterance of the speaker.

Response parameters

Parameter

Description

session_id

Unique identity

result

The single-label classification result, which includes the industry, scene, and probability (prob).

code

The status of the query. `SUCCESS` indicates that the request was successful. `INVALID_INPUT_FORMAT` indicates that the input format is invalid. `FIELD_MISSING` indicates that a required field is missing. `INVALID_TEXT_VALUE` indicates that the `msgs` field has no valid value.

cost

The time it took to process the query.