全部产品

电销场景对话风险识别

电销场景对话风险识别服务适用于电话销售外呼场景,针对对话内容,识别风险(辱骂、投诉、威胁等),可应用于语音质检。使用示例如下。

Java代码示例

  1. class MsgDO{
  2. private String role;
  3. private String words;
  4. public MsgDO(String role,String words) {
  5. this.role = role;
  6. this.words = words;
  7. }
  8. public String getRole() {
  9. return role;
  10. }
  11. public void setRole(String role) {
  12. this.role = role;
  13. }
  14. public String getWords() {
  15. return words;
  16. }
  17. public void setWords(String words) {
  18. this.words = words;
  19. }
  20. }
  21. DefaultProfile defaultProfile = DefaultProfile.getProfile("cn-hangzhou","your-access-id-key","your-access-id-secret");
  22. IAcsClient client = new DefaultAcsClient(defaultProfile);
  23. Map<String, Object> obj = new HashMap<String, Object>();
  24. List<MsgDO> msgs = new ArrayList<MsgDO>();
  25. msgs.add(new MsgDO("客服","李某某。"));
  26. msgs.add(new MsgDO("客服","说你是大傻逼吗?"));
  27. obj.put("msgs",msgs);
  28. obj.put("session_id",123);
  29. RunPreTrainServiceRequest request = new RunPreTrainServiceRequest();
  30. request.setServiceName("暂不直接开放,请加 阿里云NLP自学习平台用户答疑群23142693 联系获取");
  31. request.setPredictContent(JSON.toJSONString(obj));
  32. RunPreTrainServiceResponse response = client.getAcsResponse(request);
  33. System.out.println(response.getPredictResult());

Python代码示例

  1. # 安装依赖
  2. pip install aliyun-python-sdk-core
  3. pip install aliyun-python-sdk-nlp-automl
  1. # -*- coding: utf8 -*-
  2. import json
  3. from aliyunsdkcore.client import AcsClient
  4. from aliyunsdkcore.acs_exception.exceptions import ClientException
  5. from aliyunsdkcore.acs_exception.exceptions import ServerException
  6. from aliyunsdknlp_automl.request.v20191111 import RunPreTrainServiceRequest
  7. # Initialize AcsClient instance
  8. client = AcsClient(
  9. "<your-access-key-id>",
  10. "<your-access-key-secret>",
  11. "cn-hangzhou"
  12. );
  13. content = {
  14. "session_id": 123,
  15. "msgs":[
  16. {
  17. "role": "客服",
  18. "words": "李某某。"
  19. },
  20. {
  21. "role": "客服",
  22. "words": "说你是大傻逼吗?"
  23. }
  24. ]
  25. }
  26. # Initialize a request and set parameters
  27. request = RunPreTrainServiceRequest.RunPreTrainServiceRequest()
  28. request.set_ServiceName("暂不直接开放,请加 阿里云NLP自学习平台用户答疑群23142693 联系获取")
  29. request.set_PredictContent(json.dumps(content))
  30. # Print response
  31. response = client.do_action_with_exception(request)
  32. resp_obj = json.loads(response)
  33. predict_result = json.loads(resp_obj['PredictResult'])
  34. print(predict_result)

PredictContent内容示例

  1. {
  2. "session_id": 123,
  3. "msgs": [
  4. {
  5. "role": "客服",
  6. "words": "李某某。"
  7. },
  8. {
  9. "role": "客服",
  10. "words": "说你是大傻逼吗?"
  11. }
  12. ]
  13. }

PredictResult内容示例

  1. {
  2. "session_id": "9e961ffb96ce9b411bc06ef8b69b30da7014oe",
  3. "cost": "402.725ms",
  4. "result": [
  5. {
  6. "risks": [
  7. {
  8. "label": "无风险",
  9. "prob": 0.071
  10. },
  11. {
  12. "label": "客服辱骂",
  13. "prob": 0.941
  14. },
  15. {
  16. "label": "投诉",
  17. "prob": 0.0
  18. },
  19. {
  20. "label": "客户辱骂",
  21. "prob": 0.001
  22. },
  23. {
  24. "label": "客户威胁",
  25. "prob": 0.0
  26. },
  27. {
  28. "label": "涉黄",
  29. "prob": 0.0
  30. },
  31. {
  32. "label": "客服威胁",
  33. "prob": 0.0
  34. },
  35. {
  36. "label": "违禁",
  37. "prob": 0.0
  38. },
  39. {
  40. "label": "赌博",
  41. "prob": 0.0
  42. },
  43. {
  44. "label": "涉政",
  45. "prob": 0.0
  46. },
  47. {
  48. 'label': '疑似诈骗',
  49. 'prob': 0.0
  50. }
  51. ]
  52. }
  53. ],
  54. "code": "SUCCESS"
  55. }

入参说明

参数 说明
session_id 当前请求唯一标识(字符串),为便于排查问题,请务必加上。可以是md5,或者随机数加时间戳。(必选字段)
msgs 对话内容(必选字段)
role 说话人的角色,当前仅客服、客户两种角色
words 说话人的说话内容

出参说明

参数 说明
session_id 唯一标识
result 对话风险分类结果,以(风险标签label,概率prob)二元组列表形式返回,主要支持类别(无风险、客服辱骂、投诉、客服威胁、客户辱骂、客户威胁、涉黄、违禁、涉政、赌博、疑似诈骗等10种风险类型)
code 查询状态,SUCCESS为成功,INVALID_INPUT_FORMAT 为输入格式错误,FIELD_MISSING 为必选字段缺失,INVALID_TEXT_VALUE 为msgs字段无有效值
cost 查询耗时