Global service

Updated at:

This document describes how to create a new global service.

Overview

A global service lets you call external services. To add a new global service, configure a service interface. FAQ and multi-turn conversation can directly reference a global service to obtain information or functionality from external services.

Important

Before deleting a global service, you must remove all references to it.

Access the feature

  1. Log on to the Cloud Contact Center console. In the left-side navigation pane, choose Instance Management-V2, and then click the Access Address of a specific instance to open the instance console.

    image

  2. Click the menu button in the upper-right corner of the page and select digital employee to open the digital employee business console. In the left-side navigation pane, choose AI Platform > Global Service.

    image

Create a service

On the global service management page, click New Service. Enter the required information based on your business needs and click OK.

image

Name and type

To create a new service, first specify its name and type. The available service types include HTTP service, Function Compute, and SMS service.

  • Service Name: The name of the service. It can contain only Chinese characters, letters, digits, underscores (_), and hyphens (-), and it cannot start with a digit.

  • Service Type:

    • HTTP service: An HTTP service provides interfaces based on the HTTP protocol. You can access these interfaces by sending HTTP requests, passing parameters, and receiving a response.

    • Function Compute: An event-driven, serverless compute service. It runs code as functions and automatically invokes them in response to events. Write and upload your code without managing the underlying server resources.

    • SMS service: A service that provides features for sending and receiving SMS messages. It allows you to send messages to mobile phones and receive replies via an API or the console.

image

Invocation method

In the invocation method settings, choose a synchronous or asynchronous method and set the service timeout.

  • Invocation Method

    • Synchronous: The service call waits for the operation to complete and returns the result to the caller. This means the calling process is blocked until it receives a response.

    • Asynchronous: The system triggers the service call immediately and returns control to the caller without waiting for the operation to complete. The calling process can then proceed with other tasks. This method is typically used for long-running services, batch processing, or background tasks.

  • Service Timeout

    • Timeout: The maximum time to wait for a service to respond or complete an operation. If the service fails to return a result within this period, the system returns a timeout message to the caller. The timeout duration should be set based on your business requirements and the service's expected execution time.

image

Request parameters

Configure the request parameters for the service as follows:

  • Parameter Name: Specify a unique name for each parameter. This name is used to identify and reference the parameter. For example: "username", "email", or "message".

  • Description: Provide a description for each parameter to explain its purpose and usage. For example, for a parameter named "username", the description could be "The user's username".

image

Function configuration

When configuring the function, you can set the service interface and request parameters. These settings define the interface type and how the service receives parameters.

  • Service Interface: Specifies how a client communicates with the service. Common options include GET, POST, and the body parameter (used only with POST requests).

    • GET: With GET, the client sends an HTTP GET request to the service. GET is typically used to retrieve data, and its parameters are passed in the URL query string.

    • POST: With POST, the client sends an HTTP POST request to the service. POST is typically used to submit data, and its parameters can be passed in the request body or as form data.

  • Request Parameters: Specifies the parameters a client includes in a request and how they are passed. Common methods for passing request parameters include Query and Header.

    • Query: Parameters are passed as key-value pairs appended to the request URL in a query string. For example: http://example.com/api?param1=value1&param2=value2.

    • Header: Parameters are passed in the HTTP request headers. The client adds parameters to the request headers, and the service extracts parameter values from the headers.

    • body parameter: For POST requests only, parameters are passed in the request body. This method is typically used for passing complex structured data, such as data in JSON or XML format. The request body can contain multiple parameters, and the specific format and content depend on the API design.

image

Response parameters

Response parameters are the data that an interface returns to the caller after processing a request. When configuring response parameters, you can specify the encoding format and data type, and use variables to reference specific fields in the response. The following describes how to configure and use response parameters:

  • Encoding Format: Ensure the interface response uses UTF-8 encoding to support a wide range of character sets and special characters.

  • Data Type: Set the data type of the response to string to ensure the result is returned as a string.

  • Reference the response: Use variables to reference specific fields in the response. For example, ${serviceOutput} assigns the entire interface response to the result parameter, making it accessible to the calling module. If the response is a JSON object, you can use ${serviceOutput.name} to get the value of the name field.

image

Signature authentication

In a global service, signature authentication is a security mechanism that validates the authenticity and identity of a request. It ensures that requests originate from a legitimate sender and protects against tampering and replay attacks. For more information, see the Signature calculation guide.

image