logo
On this page

Receiving Callback

Warning
The callback service cannot guarantee complete reliability. Please carefully consider the risks of building core business processes using the callback solution.

With this callback, you can listen to events that occur during user conversations with the agent, including ASR results, LLM results, exception events, agent interruption events, user speaking actions, agent speaking actions, and user speaking audio data.

Note

To receive different types of callback results, configure the corresponding CallbackConfig parameter to 1 when creating an agent instance:

  • ASR results: CallbackConfig.ASRResult
  • LLM results: CallbackConfig.LLMResult
  • Agent interruption events: CallbackConfig.Interrupted
  • User speaking actions: CallbackConfig.UserSpeakAction
  • Agent speaking actions: CallbackConfig.AgentSpeakAction
  • User speaking audio data: CallbackConfig.UserAudioData

Callback Description

  • Request method: POST.
    Note
    The callback data format is JSON. You need to perform UrlDecode decoding on it.
  • Request URL: Please contact ZEGOCLOUD Technical Support for configuration.
  • Transmission protocol: HTTPS/HTTP, it is recommended to use HTTPS.

Callback Parameters

Note
ZEGOCLOUD will continuously optimize and update the relevant callback parameters in future iteration plans (for example: adding new fields or adding parameter values for certain fields). When developers integrate, please avoid hardcoding to ensure compatibility with new versions after updates.
ParameterTypeDescription
AppIdNumberThe unique identifier for the developer's APP provided by ZEGOCLOUD.
EventStringNotification type of event.
  • ASRResult: Callback for ASR results.
  • LLMResult: Callback for LLM results.
  • Exception: Exception event.
  • Interrupted: Callback for agent interruption results.
  • UserSpeakAction: Callback for user speaking events.
  • AgentSpeakAction: Callback for agent speaking events.
  • UserAudioData: Callback for user speaking audio data.
NonceStringA random number used for signature calculation.
TimestampNumberUnix timestamp (in milliseconds) when the callback was sent, used for signature calculation.
SignatureStringVerification string to confirm the identity of the sender of the callback.
AgentInstanceIdStringThe unique identifier for the AI agent instance.
AgentUserIdStringThe user ID of the AI agent.
RoomIdStringThe room ID.
SequenceNumberThe sequence number of the callback, ensuring orderliness but not necessarily continuity.
DataObjectDetailed information about the event. For details, see Data.

Data

Depending on the different values of Event, the parameters included in Data are different.

Callback Examples

Below are callback examples for each Event type.

Signature Verification

To enhance data security, developers should perform local signature calculations when receiving callbacks from the ZEGOCLOUD server, and compare them with the provided signature to determine if the request is legitimate.

The verification process is as follows:

1
Sort parameters

Sort the three parameters callbacksecret, timestamp, and nonce in dictionary order

2
Calculate SHA1

Concatenate the sorted callbacksecret, timestamp, and nonce into a string and calculate SHA1

3
Compare signature

Compare the calculated hash string with signature, if they match, the request is from ZEGOCLOUD

The parameters are described as follows:

ParameterDescription
callbacksecretServer verification key. Generated when registering a project in the ZEGOCLOUD Console. You can view it in "Console > Project Configuration > Project Information > Configuration Information".
timestampUnix timestamp.
nonceRandom number.

Return Response

After you receive the callback, please return an HTTP status code of 2XX (e.g., 200) to indicate successful receipt. Any other response will be considered a failure.

Callback Retry Policy

If the ZEGOCLOUD server does not receive a response, or if the received HTTP status code is not 2XX (e.g., 200), it will attempt to retry, with a maximum of 5 retries. The interval between each retry request and the previous request will be 2s, 4s, 8s, 16s, and 32s respectively. If the 5th retry still fails, no further retries will be attempted, and the callback will be lost.

Previous

Reset Agent Instance Context

Next

Exception Event Codes