Updated on 2023-06-06 GMT+08:00

Q&A Satisfaction Evaluation

Function Description

After a user raises a question, the user evaluates whether the result returned by the intelligent Q&A is satisfactory. The API request parameter degree can be satisfied or dissatisfied. This API can be added to the answers returned by QABot to collect user feedback.

URI

POST https://{endpoint}/v1/{project_id}/qabots/{qabot_id}/requests/{request_id}/satisfaction

Table 1 Path parameters

Parameter

Mandatory

Type

Description

endpoint

Yes

String

Endpoint, which is the request address for calling an API.

The endvertex varies depending on the service and region. You can obtain it from Endpoints.

project_id

Yes

String

Project ID, which is used for resource isolation. For details, see Obtaining a Project ID.

qabot_id

Yes

String

Q&A bot ID, which is in the UUID format. For example, 303a0a00-c88a-43e3-aa2f-d5b8b9832b02.

This parameter is displayed in the Q&A Bot Name/ID column of the QABot console.

request_id

Yes

String

Request ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

It is used to obtain the permission to call APIs. The value of X-Subject-Token in the Interface for Obtaining a Token response header is the token.

Content-Type

Yes

String

Message body type (format). The value is application/json.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

degree

Yes

Integer

Satisfaction score. Currently, the value can be 1 (satisfied) or -1 (dissatisfied). Questions with dissatisfied answers will be added to the list of unresolved questions.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

request_id

String

Request ID returned when the API is successfully called.

This parameter is not included when the API fails to be called.

updated_time

String

Date and time when the satisfaction score is returned. The format is yyyy-MM-dd THH:mm:ssZ. T is the separator between the calendar and the hourly notation of time. Z indicates Coordinated Universal Time (UTC).

This parameter is not included when the API fails to be called.

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Error code returned when the API fails to be called. This parameter is not included when the API is successfully called.

error_msg

String

Error message returned when the API fails to be called. This parameter is not included when the API is successfully called.

Example Requests

  • Example request
    POST https://{endpoint}/v1/1604d8170cd84440a81281e5a3a04f8b/qabots/303a0a00-c88a-43e3-aa2f-d5b8b9832b02/requests/303a0a00-c88a/satisfaction
    
    Request Header:
        Content-Type: application/json
        X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...
    
    Request Body:
    {
        "degree":1
    }
  • Python request code example
    import requests
    url = "https://{endpoint}/v1/{project_id}/qabots/{qabot_id}/requests/{request_id}/satisfaction"
    body = {"degree":1}
    token = "Actual token value obtained by the user"
    headers = {'Content-Type': 'application/json', 'X-Auth-Token': token}
    
    response = requests.post(url, headers=headers, json=body, verify=False)
    print(response.text)
  • Java request code example
    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.net.HttpURLConnection;
    import java.net.URL;
    
    public class CBSDemo {
    
        public void cbsDemo() {
            try {
                //Replace endpoint, projectId, and qabot_id with the actual ones.
                URL url = new URL("https://{endpoint}/v1/{project_id}/qabots/{qabot_id}/requests/{request_id}/satisfaction");
                String token = "Actual token value obtained by the user";
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                connection.setRequestMethod("POST");
                connection.setDoInput(true);
                connection.setDoOutput(true);
                connection.addRequestProperty("Content-Type", "application/json");
                connection.addRequestProperty("X-Auth-Token", token);
    
                //Input parameters
                String body = "{\"degree\":1}";
    
                OutputStreamWriter osw = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
                osw.append(body);
                osw.flush();
                InputStream is = connection.getInputStream();
                BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
                while (br.ready()) {
                    System.out.println(br.readLine());
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        public static void main(String[] args) {
            CBSDemo CBSDemo = new CBSDemo();
            CBSDemo.cbsDemo();
        }
    }

Example Responses

Status code: 200

Example of a successful response

{
    "request_id":"303a0a00-c88a",
    "updated_time":"2017-02-07T17:34:02Z"
}

Status code: 400

Example of a failed response

{
  "error_code": "CBS.0099",
  "error_msg": "request body invalid."
}

Status Code

For details about status codes, see Status Code.

Error Code

For details about error codes, see Error Code.