Message queue
Before you begin, activate the Message Queue for Apache RocketMQ service.
Overview
Smart Conversation Analysis acts as a message producer and sends messages to your Message Queue for Apache RocketMQ service. As a message consumer, you can receive and process these messages. This method facilitates low-latency, high-concurrency, and high-availability message pushes.
Authorization
To allow Smart Conversation Analysis to send messages to Message Queue for Apache RocketMQ, you must grant authorization. Log on to the Smart Conversation Analysis console using your Alibaba Cloud account. In the navigation pane on the left, choose Basic Settings > Message Queue. As shown in the following figure, click the Go to Authorize button. Read the content in the pop-up window and click Confirm to complete the authorization.

Message queue configuration

After the authorization is successful, the page shown in the preceding figure appears. Click Edit to open the Message queue configuration page.
Obtain the configuration information from the Message Queue for Apache RocketMQ console. Note that the Message Queue for Apache RocketMQ instance must be in an Internet region.
Endpoint: Enter the Transmission Control Protocol (TCP) endpoint address. Messages are sent using the TCP protocol, which is officially recommended by RocketMQ.
Instance ID: The ID of the message queue instance. The instance must be in an Internet region.
Topic: When you create the topic, set the message type to Ordered Message - Globally ordered message.
Group ID:
After you enter the configuration information, click Test to check whether the message queue service configuration is active. A test message is sent to verify service connectivity. The result is shown in the following figure:

The following three types of messages can be sent:
Real-time quality check single-sentence speech recognition result: This message is pushed multiple times during a real-time quality check session. A single-sentence speech recognition result is pushed each time the SyncQualityCheck API is called.
Real-time quality check full-text speech recognition result: This message is pushed once after a call ends and contains the complete speech recognition result for the session. The message is pushed after the UpdateSyncQualityCheckData API is called.
Real-time quality check conversation analysis result: This message contains the quality check result, including rule hit information. This result cannot be sent alone. It must be sent with either a real-time quality check single-sentence speech recognition result message or a real-time quality check full-text speech recognition result message. The quality check result is included in the speech recognition result message.
Message types and structure
The following figure shows the result of a message query in the Message Queue for Apache RocketMQ console. Smart Conversation Analysis pushes messages with three different tags. You can process these messages based on their tags.

testEvent: A test message sent by Smart Conversation Analysis to verify your message queue configuration. You can discard these messages because no processing is required. The following is a sample message:
{ "eventType":"testEvent" }
SyncResult: The result of a real-time quality check for a single sentence. The following is a sample message:
{ "checkResult":{ "rules":[ { "highlight":[ { "3868":[ { "val":"Alibaba Cloud", "pid":0, "from":6, "to":9, "tid":"202010***", "cid":"3***" } ], "cid":"31***" } ], "hit":[ { "phrase":{ "role":"Agent", "identity":"An agent", "words":"Hello, this is the Alibaba Cloud Customer Service Center. How can I help you?", "emotionValue":7, "end":3930, "pid":0, "begin":410 }, "cid":[ "31***" ] } ], "rid":"2***" } ] }, "event":"SyncResult", "syncQualityCheckObject":{ "beginTime":1603959093000, "callId":"20201028***", "callType":3, "callee":"1760066***", "caller":"268822***", "customerServiceId":"20526561358***", "customerServiceName":"a***", "dialogue":{ "begin":410, "channelId":0, "emotionValue":7, "end":3930, "hourMinSec":"00:00", "identity":"An agent", "role":"Agent", "speechRate":443, "words":"Hello, this is the Alibaba Cloud Customer Service Center. How can I help you?" }, "dialogueStatus":2, "dialogueTaskUuid":"202010297009ba73-635e-40a2-8245-16315***", "ruleIds":[ "254***", "255***", "251***" ], "skillGroupId":"zc1", "skillGroupName":"Workplace 1", "sourceType":1, "taskId":"20201029C963BA7A-0DD5-45EC-AA40-4A46DC0***", "tid":"202010***" } }
SyncAllResult: The result of a real-time quality check for the full text. The following is a sample message:
{ "checkResult":{ "result":[ { "rules":[ { "highlight":[ { "38***":[ { "val":"Alibaba Cloud", "from":6, "pid":0, "to":9, "tid":"202010***", "cid":"31***" } ], "cid":"31***" } ], "hit":[ { "keyWords":[ { "val":"Alibaba Cloud", "from":6, "pid":0, "to":9, "tid":"202010***", "cid":"31***" } ], "phrase":{ "role":"Agent", "emotionValue":7, "words":"Hello, this is the Alibaba Cloud Customer Service Center. How can I help you?", "pid":0, "identity":"An agent", "end":3930, "begin":410 }, "cid":[ "31***" ] } ], "rid":"25***" }, { "highlight":[ { "38***":[ { "val":"public preview", "from":13, "pid":1, "to":15, "tid":"202010***", "cid":"31***" } ], "cid":"31***" } ], "hit":[ { "keyWords":[ { "val":"public preview", "from":13, "pid":1, "to":15, "tid":"202010***", "cid":"31***" } ], "phrase":{ "role":"Customer", "emotionValue":6, "words":"I want to apply for the public preview of product XXX.", "pid":1, "identity":"A customer", "end":8000, "begin":5940 }, "cid":[ "31***" ] } ], "rid":"25***" } ], "tid":"202010***" } ], "app_key":"1", "status":200 }, "event":"SyncAllResult", "syncQualityCheckObject":{ "beginTime":1603959093000, "dialogueList":[ { "begin":410, "channelId":0, "emotionValue":7, "end":3930, "hourMinSec":"00:00", "identity":"An agent", "pid":0, "role":"Agent", "speechRate":443, "words":"Hello, this is the Alibaba Cloud Customer Service Center. How can I help you?" }, { "begin":5940, "channelId":1, "emotionValue":6, "end":8000, "hourMinSec":"00:23", "identity":"A customer", "pid":1, "role":"Customer", "speechRate":192, "words":"I want to apply for the public preview of product XXX." }, { "begin":11000, "channelId":0, "emotionValue":5, "end":15680, "hourMinSec":"00:25", "identity":"An agent", "pid":2, "role":"Agent", "speechRate":30, "words":"Okay, I have noted it. A specialist will contact you later." } ], "dialogueStatus":3, "dialogueTaskUuid":"20201029a8b0ccc5d07c43e780aa702da***", "fileName":"202010***.wav", "taskId":"2020102908657590-73e0-4e4c-a34c-750***", "tid":"202010***", "voiceFileUrl":"https://sca-buck***.oss-cn-beijing.aliyuncs.com/a***st.wav" } }
The message content is in JSON format. The data structure is described as follows:
Field |
Type |
Example value |
Description |
event |
String |
SyncResult |
Message type. Possible values:
|
checkResult |
Object |
{} |
Quality check result. For more information, see the checkResult structure section below. |
syncQualityCheckObject |
Object |
{} |
Real-time quality check object. This includes call information and transcription results. For more information, see the syncQualityCheckObject structure section below. |
syncQualityCheckObject structure
Field |
Type |
Sample value |
Description |
dialogueStatus |
Integer |
2 |
Indicates the start and end of a real-time quality check session. Possible values: 1 (Start), 2 (In progress). |
taskId |
String |
20201029C963BA7A-0DD5-45EC-AA40-4A46DC0*** |
Task ID. |
tid |
String |
202010*** |
Unique call ID. |
customerServiceId |
Long |
20526561358*** |
Agent ID. You can obtain this ID from the Basic Settings > User Management page in the console. If you enter the correct agent ID, the agent can view their associated recording files when they log on to the console. |
customerServiceName |
String |
agent |
Agent name. |
skillGroupId |
Long |
1231324234* |
Skill group ID. |
skillGroupName |
String |
Pre-sales skill group |
Skill group name. |
callType |
Integer |
1 |
Call type. Possible values: 1 (Outbound) (Default), 3 (Inbound), 4 (Other). |
callee |
String |
1760066*** |
The called number. For outbound calls, this is the customer's number. For inbound calls, this is the agent's number. |
caller |
String |
0211234**** |
The calling number. For outbound calls, this is the agent's number. For inbound calls, this is the customer's number. |
callId |
String |
2020102*** |
The call ID (acid). This can be the call ID from the call center system or another ID that identifies the call. If a call is transferred between agents 1 to n, the callId remains the same, but the tid is different. |
dialogue |
Object |
Yes |
Real-time quality check single-sentence speech recognition result. For more information, see the dialogue structure section below. |
dialogueList |
Array |
Yes |
Real-time quality check full-text speech recognition result. For more information, see the dialogue structure section below. |
ruleIds |
Array |
[1321,23321] |
A list of rule IDs used for the quality check. |
Dialog description
Property |
Value type |
Example |
Description |
role |
String |
Agent |
The role of the speaker. Values: Agent, Customer, System. |
identity |
String |
123** |
The specific identity of the role, such as an agent ID or customer ID. |
words |
String |
Hello, welcome to ** |
A sentence spoken by this role. |
begin |
Integer |
3400 |
The start time offset from the beginning of the recording, in milliseconds. |
end |
Integer |
5688 |
The end time offset from the beginning of the recording, in milliseconds. |
emotionValue |
Integer |
6 |
The emotion energy value, from 1 to 10. A higher value indicates a stronger emotion. |
speechRate |
Integer |
279 |
The average speech rate for this sentence, in words per minute. |
checkResult structure
Field |
Type |
Sample value |
Description |
rules |
Array |
[{}] |
A list of hit rules. For more information, see the rules structure section below. |
rules structure
Field |
Type |
Example value |
Description |
highlight |
Array |
[] |
A list of highlight objects. For more information, see the HighlightObject structure section below. |
hit |
Array |
[] |
A list of hit sentences. For more information, see the HitObject structure section below. |
rid |
Long |
23** |
Rule ID. |
HighlightObject structure
Field |
Type |
Example |
Description |
cid |
Long |
34*** |
Operator ID. |
Operator ID |
Array |
23** |
This operator hits positions in the current sentence and returns a list of these positions for highlighting, with a structure as detailed in the Highlight Position Structure Description below. |
Highlight position structure
Field |
Type |
Example value |
Description |
val |
String |
Alibaba Cloud |
The highlighted text. |
from |
Integer |
6 |
Start position. |
to |
Integer |
9 |
End position. |
cid |
Long |
32** |
Condition ID. |
pid |
Integer |
1 |
The position index of the sentence. This is the index of the hit sentence in the list of all sentences. 0 is the first sentence, 1 is the second, and so on. |
HitObject structure
Field |
Type |
Example |
Description |
phrase |
Object |
{} |
Details of the hit sentence. For more information, see the phrase structure section below. |
cid |
Array |
[34**,32**] |
A list of hit condition IDs. |
phrase structure
Field |
Type |
Sample value |
Description |
words |
String |
Hello, welcome to ** |
The content of the sentence. |
begin |
Integer |
3477 |
Start time relative to the beginning of the recording, in milliseconds. |
end |
Integer |
6890 |
End time relative to the beginning of the recording, in milliseconds. |
role |
String |
Agent |
Role. Possible values: Agent, Customer. |
pid |
Integer |
1 |
The position index of the sentence. This is the index of the hit sentence in the list of all sentences. 0 is the first sentence, 1 is the second, and so on. |