This topic describes how to retrieve Tingwu Agent task results using asynchronous callbacks.
The Tingwu Agent task creation API is asynchronous. You can retrieve the results in two ways:
-
By periodically polling the query API. For more information, see Automotive Sales Service Insights API Reference or Car Buyer Persona API Reference.
-
By configuring callback notifications, which is the focus of this document.
Prerequisites
-
Activate the Tingwu Agent service.
-
If you use EventBridge, you must activate EventBridge and grant the necessary permissions.
Usage notes
-
Callbacks are triggered only by tasks initiated through API or SDK calls. Tasks submitted from the Alibaba Cloud Model Studio console do not trigger callbacks.
-
The
datafield is identical for both HTTP and EventBridge callbacks. -
Both callback methods use the same notification cadence.
Receive callbacks via HTTP
Step 1: Build a callback service
Build an HTTP service to receive callback messages:
package com.alibaba.langpower;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@SpringBootApplication
public class TingwuAgentCallbackDemoApplication {
public static void main(String[] args) {
SpringApplication.run(TingwuAgentCallbackDemoApplication.class, args);
}
@PostMapping("/tingwu-agent/callback")
@ResponseBody
public String receiveTingwuAgentCallbackEvent(@RequestBody String data) {
System.out.println("Received callback data: \n" + data);
return "Callback received!";
}
}
Step 2: Test your callback service
Use cURL to verify that the service is available:
# Replace {your-external-service-url} with your actual URL.
curl --request POST 'http://{your-external-service-url}/tingwu-agent/callback' \
--header 'Content-Type: application/json' \
--data '{
"output": {
"test": "checkSyncConf1753325301***"
},
"requestId": "61b093d1200e4286ae5d5b15448698f2"
}'
Step 3: Configure callback parameters
Log on to the Alibaba Cloud Model Studio console. Create or select an application, and then click Debugging Configuration to open the configuration page. For Callback Method, select HTTP post protocol, enter your callback URL, and then publish the application.
After you configure the callback URL, your server must return a 200 status code for tasks to be created successfully. The example callback message is in JSON format and contains an output object with a test field and a requestId field.
Step 4: Verify the callback result
After creating a task using an SDK (see the SDK documentation), your callback service receives notifications in stages:
-
Stage 1: Receive transcription task information
{ "output": { "transcriptionPath": "https://***.oss-cn-hangzhou.aliyuncs.com/agentic/prepub/CommonDataField/transcription/1627865****/llm-3cx2a3o4n8y****/2025/07/24/5c6117f77a274cf8b795c8749c28b****?Expires=175341****&OSSAccessKeyId=LTAI5tKZP7TuS7QuF8TYN****&Signature=HEXgIeUVMuTbgyJEu8IIZc1k****", "status": 1, "taskInfo": { "appId": "tw_gDEAnYwAIs****", "dataId": "fgVnGZkX5x****", "model": "tingwu-automotive-service-insights", "userId": "1627865****", "userSpaceId": "llm-3cx2a3o4n8y****" } }, "requestId": "5038efee3f3a448bb600fc5617fc****" } -
Stage 2: Receive task results
{ "output": { "transcriptionPath": "https://***.oss-cn-hangzhou.aliyuncs.com/agentic/prepub/CommonDataField/transcription/1627865****/llm-3cx2a3o4n8y****/2025/07/24/5c6117f77a274cf8b795c8749c28b****?Expires=175341****&OSSAccessKeyId=LTAI5tKZP7TuS7QuF8TYN****&Signature=7XmIRXMiRQCmy%2B7tkvqiw76****", "status": 0, "saleInsightsPath": "https://***.oss-cn-hangzhou.aliyuncs.com/agentic/prepub/CommonDataField/saleInspec/1627865****/llm-3cx2a3o4n8y****/2025/07/24/7b6271d72bc4408b8e2801ebfcf2****?Expires=175341****&OSSAccessKeyId=LTAI5tKZP7TuS7QuF8TYN****&Signature=HEVhbNDZw%2FTwrI0eLdnCs90****", "serviceInsightsPath": "https://***.oss-cn-hangzhou.aliyuncs.com/agentic/prepub/CommonDataField/servInspec/1627865****/llm-3cx2a3o4n8y****/2025/07/24/b8574b1b92184d4caae003408896****?Expires=175341****&OSSAccessKeyId=LTAI5tKZP7TuS7QuF8TYN****&Signature=YzlF2SYFbG4LhtDTWisMgN7A****", "taskInfo": { "appId": "tw_gDEAnYwAIs****", "dataId": "fgVnGZkX5x****", "model": "tingwu-automotive-service-insights", "userId": "1627865****", "userSpaceId": "llm-3cx2a3o4n8y****" } }, "requestId": "6005f5c621794168a508cb2dff3a****" }The value of the top-level data field is the same for events sent by the HTTP notification protocol and events sent to an event bus. You can refer to the protocol of the event bus.
HTTP callbacks use a retry strategy with exponential backoff. If a delivery fails, the system retries six times with the following intervals: 1 second, 2 seconds, 5 seconds, 10 seconds, 30 seconds, and 60 seconds.
Retry failed tasks
If the value of the status field in the callback message is not 0 (success), the task has failed. You can implement automatic retry logic in your callback service based on the task status.
Procedure:
-
In your callback service, parse the
statusfield from the callback message. Astatusof0indicates success, while any non-0value indicates failure. -
If a task fails, extract the
appIdand original request parameters from thetaskInfoobject in the callback message. Then, call the task creation API to resubmit the task. -
When retrying, use an exponential backoff strategy (for example, with intervals of 5, 10, and 30 seconds) to avoid triggering rate limits from a high volume of retries in a short period.
If you use EventBridge callbacks, the corresponding failure event type is tingwuagent:TaskStateUpdated:AgentTaskFailed. The processing logic is the same.
Receive callbacks via EventBridge
Step 1: Create an event rule
-
Select the China (Beijing) region.
-
Click Create Rule and configure the basic information.
In the region selector at the top, select China (Beijing). In the left-side navigation pane, go to the event rules page for the default event bus.
The event bus defaults to
default(read-only). Set Name totingwuEBNotificationDemoand Description totingwuEBNotificationDemo. -
Configure the event pattern.
-
Event Source:
acs.tingwuagent -
Event Type: Select as needed.
For this example, select the following three event types:
tingwuagent:TaskStateUpdated:AgentSubTaskCompleted,tingwuagent:TaskStateUpdated:AgentTaskFailed, andtingwuagent:TaskStateUpdated:AgentWholeTaskCompleted. -
-
Configure the event target. This example uses Message Queue for Apache RocketMQ as the target. EventBridge routes callback messages from Tingwu Agent to the specified instance.
For Version, select RocketMQ 5.x. Select the target instance ID and a topic named tingwuEBNotificationDemo. Configure the VPC and vSwitch. For Message Body, select Complete Event, and then click Create.
-
Click the Create button.
Step 2: Configure the callback method
Log on to the Alibaba Cloud Model Studio console. Create or select an application, and then click Debugging Configuration to open the configuration page. For Callback Method, select event bus, and then publish the application.
Task results are sent to your service based on the default configuration of the event bus in the China (Beijing) region. You must activate EventBridge first.
Step 3: Verify the callback result
-
Create a customer persona analysis task using an SDK. Then, in the default event bus in EventBridge, you should see two callback messages from Tingwu Agent.
On the event trace page, set the event source to
acs.tingwuagentand search. You should see two events with the typestingwuagent:TaskStateUpdated:AgentWholeTaskCompleted(entire task completed) andtingwuagent:TaskStateUpdated:AgentSubTaskCompleted(subtask completed). -
In the configured RocketMQ instance, check the messages that were routed by EventBridge.
In the Message Queue for Apache RocketMQ console, navigate to Instance List > Topic Management > Topic Details. Click the Message Query tab. Set the query method to Query by Topic and the time range to Last 1 Hour, and then click Query. If message records appear in the results table, the EventBridge callback was successful.
Event types and callback schema
Automotive, car buyer, and general service agents
|
Event type |
Description |
Schema reference |
|
tingwuagent:TaskStateUpdated:AgentSubTaskCompleted |
Callback message sent after a subtask is completed. |
Automotive sales service quality inspection, car buyer persona, and general service insights agents |
|
tingwuagent:TaskStateUpdated:AgentTaskFailed |
Callback message sent when a task fails. |
|
|
tingwuagent:TaskStateUpdated:AgentWholeTaskCompleted |
Callback message sent after the entire task is completed. |
Meeting minutes agent
|
Event type |
Description |
Schema reference |
|
tingwuagent:TaskStateUpdated:MeetingAgentSubTaskCompleted |
Callback message sent after a subtask is completed. |
|
|
tingwuagent:TaskStateUpdated:MeetingAgentTaskFailed |
Callback message sent when a task fails. |
|
|
tingwuagent:TaskStateUpdated:MeetingAgentWholeTaskCompleted |
Callback message sent after the entire task is completed. |
EventBridge notification cadence
Automotive, car buyer, and general service agents
Agent results are returned in stages. The following list describes the notification cadence for each agent.
-
If the task succeeds:
-
tingwuagent:TaskStateUpdated:AgentSubTaskCompleted: Triggered when the transcription subtask is complete.
-
tingwuagent:TaskStateUpdated:AgentWholeTaskCompleted: Triggered when the entire task is complete.
-
-
Task failed: A tingwuagent:TaskStateUpdated:AgentTaskFailed callback notification is received.
Meeting minutes agent
-
If the task succeeds:
-
tingwuagent:TaskStateUpdated:MeetingAgentSubTaskCompleted: Triggered when a subtask of the meeting minutes task is complete.
-
tingwuagent:TaskStateUpdated:MeetingAgentWholeTaskCompleted: Triggered when the entire meeting minutes task is complete.
-
-
Task failed: A tingwuagent:TaskStateUpdated:AgentTaskFailed callback notification is received.