RealTimeDialog

Updated at:

Starts a real-time session. After you create a session by calling the CreateDialog API, use this API to conduct the real-time interaction.

Operation description

Before using this API, make sure you understand the billing methods and pricing of the Tongyi Gold service.

Prerequisites

Alibaba Cloud Model Studio and the Tongyi Gold service are activated.

Obtain a workspaceId. For more information, see Get an app ID and workspace.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.
    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.
  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

dianjin:RealTimeDialog

none

*All Resource

*

NoneNone

Request syntax

POST /{workspaceId}/api/realtime/dialog/chat HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

workspaceId

string

Yes

The workspace ID.

llm-xxxxx

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The request body parameters.

bizType

string

No

The business type. The default value is mixIntentChat.

mixIntentChat

analysis

boolean

No

Specifies whether to perform analysis.

false

recommend

boolean

No

The recommended intent.

false

metaData

object

No

The metadata used to encapsulate prompts.

{ "phoneTailNumber": "Phone tail number: 98X1", "preScreeningQuota": "Pre-screening quota: 30,000", "generalInterest": "Platform general interest rate: 20.4%" }

stream

boolean

No

Specifies whether to return the response in a stream.

false

conversationModel

array<object>

Yes

The list of conversations.

object

No

A conversation.

role

integer

Yes

The role. 0 indicates the customer, and 1 indicates the customer service representative.

0

intentionCode

string

No

The intent code.

198379874354

customerServiceType

string

No

The type of the customer service representative. 0: bot, 1: human.

0

customerServiceId

string

No

The ID of the customer service representative. This parameter is required.

1374683645635

customerId

string

No

The unique ID of the conversation role. This parameter is required.

98457834685635

content

string

Yes

The specific content of the conversation.

Human customer service

type

string

Yes

The type of the conversation content. Valid values: text, audio, and image.

audio

beginTime

string

No

The start time of this sentence.

2024-11-08 09:51:16

begin

integer

No

The start time of the sentence, in milliseconds, relative to the start of the session.

5

end

integer

No

The end time of the sentence, in milliseconds, relative to the start of the session.

10

sessionId

string

Yes

The session ID.

237645726354

dialogMemoryTurns

integer

No

The number of historical conversation turns to include.

3

userVad

boolean

No

Specifies whether the user interrupted the conversation.

true

scriptContentPlayed

string

No

The part of the previous script from the customer service representative that has been played.

Hello, I am

opType

string

No

The operation type. Only common and hierarchical are supported.

common

Response elements

Element

Type

Description

Example

object

IntentionChatResp

id

string

The unique identifier for this call. Each chunk object has the same ID.

eb2b6139-ddf1-91a0-a47f-df7617ae9032

choices

array<object>

An array of generated content. It can contain one or more choice objects.

array<object>

The generated content.

index

integer

The sequence number in the choices list.

0

finishReason

string

The value is `stop` if the session ends. The value is `null` if the session is in progress. If `success` is `false`, this parameter returns an error message.

stop

message

object

The full result returned for non-streaming responses. This is empty for streaming responses.

intentionCode

string

The intent code.

1853360771162058752

intentionScript

string

The intent script.

Sorry, I did not understand your meaning. Alternatively, you can call our customer service hotline and our customer service staff will assist you.

intentionName

string

The intent name.

Other

recommendIntention

string

The recommended intent.

null

recommendScript

string

The recommended script.

null

analysisProcess

string

The analysis process.

null

selfDirectedScript

string

The script for the Q&A pair. This is incremental data. This is empty for streaming responses.

null

callTime

string

The time.

1735139569523

hangUpDialog

boolean

Hang up the dialog.

false

selfDirectedScriptFullContent

string

The script for the Q&A pair. This is the full data.

Regarding the size of the universe, this is a very profound scientific topic

interrupt

boolean

Specifies whether the conversation was interrupted.

false

skipCurrentRecognize

boolean

Specifies whether to skip the current recognition.

delta

object

The incremental result returned for streaming responses. This is empty for non-streaming responses.

intentionCode

string

The intent code.

1853360771162058752

intentionScript

string

The intent script.

Sorry, I did not understand your meaning. Alternatively, you can call our customer service hotline and our customer service staff will assist you.

intentionName

string

The intent name.

Other

recommendIntention

string

The recommended intent.

null

recommendScript

string

The recommended script.

null

analysisProcess

string

The analysis process.

null

selfDirectedScript

string

The script for the Q&A pair. This is incremental data.

Topic

callTime

string

The time.

null

hangUpDialog

boolean

Hangs up the dialog.

false

selfDirectedScriptFullContent

string

The script for the Q&A pair. This is the full data.

Regarding the size of the universe, this is a very profound scientific topic

interrupt

boolean

Specifies whether the conversation was interrupted.

false

skipCurrentRecognize

boolean

Specifies whether to skip the current recognition.

false

created

string

The timestamp when this request was created.

1735139569523

success

boolean

Indicates whether the request was successful.

true

requestId

string

The request ID.

5E3FBAF1-17AF-53B7-AF0A-CDCEEB6DE658

Examples

Success response

JSON format

{
  "id": "eb2b6139-ddf1-91a0-a47f-df7617ae9032",
  "choices": [
    {
      "index": 0,
      "finishReason": "stop",
      "message": {
        "intentionCode": "1853360771162058752",
        "intentionScript": "抱歉,我没有明白您的意思,或者您可以拨打我们的客服热线,请客服人员为您解答。",
        "intentionName": "其它",
        "recommendIntention": "null",
        "recommendScript": "null",
        "analysisProcess": "null",
        "selfDirectedScript": "null",
        "callTime": "1735139569523",
        "hangUpDialog": false,
        "selfDirectedScriptFullContent": "关于宇宙的大小,这是一个非常深奥的科学话题\n",
        "interrupt": false,
        "skipCurrentRecognize": false
      },
      "delta": {
        "intentionCode": "1853360771162058752",
        "intentionScript": "抱歉,我没有明白您的意思,或者您可以拨打我们的客服热线,请客服人员为您解答。",
        "intentionName": "其他",
        "recommendIntention": "null",
        "recommendScript": "null",
        "analysisProcess": "null",
        "selfDirectedScript": "话题",
        "callTime": "null",
        "hangUpDialog": false,
        "selfDirectedScriptFullContent": "关于宇宙的大小,这是一个非常深奥的科学话题",
        "interrupt": false,
        "skipCurrentRecognize": false
      }
    }
  ],
  "created": "1735139569523",
  "success": true,
  "requestId": "5E3FBAF1-17AF-53B7-AF0A-CDCEEB6DE658"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.