Help Center/ Conversational Bot Service/ API Reference/ QABot APIs/ Other APIs/ Labeling and Transferring a Conversation to a Human Agent
Updated on 2023-06-06 GMT+08:00

Labeling and Transferring a Conversation to a Human Agent

Function Description

This API is used to label and transfer a conversation to a human agent after the Q&A bot returns an answer to a question. The question will be added to the list of unresolved questions.

URI

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

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.

Response Parameters

Status code: 200

Table 3 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 a call is handed off to a human agent. 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 4 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/{request_id}/labor
    
    Request Header:
        Content-Type: application/json
        X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...
  • Python request code example
    import requests
    url = "https://{endpoint}/v1/{project_id}/qabots/{qabot_id}/requests/{request_id}/labor"
    token = "Actual token value obtained by the user"
    headers = {'Content-Type': 'application/json', 'X-Auth-Token': token}
    
    response = requests.post(url, headers=headers, 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}/labor");
                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);
    
                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.3254",
    "error_msg":"resource not exist"
}

Status Code

For details about status codes, see Status Code.

Error Code

For details about error codes, see Error Code.