Updated on 2025-11-07 GMT+08:00

Responding to Questions in a Specific Session

Function

Respond to questions in a specified session.

URI

POST /v2/irobot/sessions/{session_id}/ask

Table 1 Path parameters

Parameter

Mandatory

Type

Description

session_id

Yes

String

Specifies the session ID.

Minimum length: 1

Maximum length: 64

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the user token.

It can be obtained by calling the IAM API (value of X-Subject-Token in the response header).

Minimum length: 1

Maximum length: 5000

x-service-key

Yes

String

Specifies the flag for invoking the intelligent customer service.

Minimum length: 1

Maximum length: 32

x-site

No

String

Specifies the site flag. The options are 0 (Chinese mainland) and 1 (international).

Minimum length: 0

Maximum length: 1

x-language

No

String

Specifies the region language with a language abbreviation. The options are en-us and zh-cn.

Minimum length: 0

Maximum length: 32

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

question

Yes

String

Specifies the question entered by a user.

Minimum length: 1

Maximum length: 1000

domain

No

String

Specifies the domain to which the Q&A belongs.

Minimum length: 0

Maximum length: 65535

top

No

Integer

Specifies the maximum number of returned data records.

Minimum value: 1

Maximum value: 10

themes

No

Array of RelationTheme objects

Specifies the theme list.

Array length: 0 - 10

source_qa_pair_id

No

String

Specifies the Q&A pair ID.

Minimum length: 0

Maximum length: 64

chat_enable

No

Boolean

Specifies whether the manual customer service is required. If it is required, a new round of Q&A will be performed.

product_type_id

No

String

Specifies the product type ID.

Minimum length: 0

Maximum length: 64

Table 4 RelationTheme

Parameter

Mandatory

Type

Description

theme_name

No

String

Specifies the name of the theme.

Minimum length: 0

Maximum length: 65535

relation_type

No

String

Specifies the type of the theme.

Options:

  • NON_PRIMARY

  • PRIMARY

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

answers

Array of AnswerQaPair objects

Specifies the answer list.

Array length: 0 - 9223372036854775807

error_code

String

Specifies the error code.

Minimum length: 0

Maximum length: 32

error_msg

String

Describes the error.

Minimum length: 0

Maximum length: 32

answer_type

Integer

Specifies the answer type. The options are 0 (knowledge base), 1 (skills), 2 (chit-chat), and 3 (Huawei Cloud).

Minimum value: 0

Maximum value: 10

request_id

String

Specifies the request ID.

Minimum length: 0

Maximum length: 65535

Table 6 AnswerQaPair

Parameter

Type

Description

score

Double

Specifies the similarity score.

Minimum value: 0

Maximum value: 1

answer

String

Specifies the answer.

Minimum length: 0

Maximum length: 9223372036854775807

domain

String

Specifies the domain.

Minimum length: 0

Maximum length: 65535

link

String

Specifies the link.

Minimum length: 0

Maximum length: 65535

question

String

Specifies the question.

Minimum length: 0

Maximum length: 65535

qa_pair_id

String

Specifies the Q&A pair ID.

Minimum length: 0

Maximum length: 65535

relevance_details

Array of RelevanceQapair objects

Specifies the list of related question details.

Array length: 0 - 65535

task_complete

Boolean

Specifies whether skill-based intent recognition is completed.

Table 7 RelevanceQapair

Parameter

Type

Description

link

String

Specifies the link.

Minimum length: 0

Maximum length: 65535

question

String

Specifies the standard question.

Minimum length: 0

Maximum length: 9223372036854775807

qa_pair_id

String

Specifies the standard question ID.

Minimum length: 0

Maximum length: 64

Request Example

POST https://{endpoint}/v2/irobot/sessions/session-id/ask

{
  "question" : "How can I purchase ECS?",
  "domain" : "domain"
}

Response Example

Status code: 200

Code 200 is returned if the operation is successful.

{
  "answer_type" : 0,
  "request_id" : "requestId",
  "answers" : [ {
    "score" : 0.85,
    "answer" : "answer",
    "domain" : "ECS",
    "link" : "link",
    "qa_pair_id" : "pair_001",
    "question" : "Question",
    "task_complete" : true,
    "relevance_details" : {
      "link" : "link",
      "question" : "Standard question",
      "qa_pair_id" : "pairId"
    }
  } ]
}

Status Codes

Status Code

Description

200

Code 200 is returned if the operation is successful.

Error Codes

See Error Codes.