지역화 및 데이터 상주

Dialogflow는 지리적 리전 또는 위치내에서 실제로 저장 데이터를 유지하기 위해 데이터 상주를 제공합니다. 리전을 지정하면 저장 데이터가 리전 외부로 복제되지 않습니다. 가격은 모든 리전에서 동일합니다.

리전은 다음과 같은 이유로 사용됩니다.

  • 시스템에 데이터 저장 위치를 제어하는 규정 또는 정책 요구사항이 있을 수 있습니다.
  • 데이터가 고객과 동일한 리전에 있으면 네트워크 지연 시간이 향상될 수 있습니다. 예를 들어 영국 고객이 europe-west2를 사용하면 지연 시간이 더 좋아질 수 있습니다.

저장 데이터

모든 Dialogflow 개발자 사용자 및 최종 사용자 데이터는 저장 데이터에 포함됩니다. 예를 들면 다음과 같습니다.

  • 콘솔 또는 API로 설정된 모든 에이전트 리소스(인텐트, 항목 등)
  • 콘솔 또는 API로 설정된 모든 에이전트 설정
  • 쿼리 기록
  • 유효성 검사 결과
  • 모델 만들기 태스크
  • 학습 태스크
  • 장기 실행 작업

사용 가능한 리전

Dialogflow는 다음 리전에서 제공됩니다.

국가 그룹 지리적 위치 리전 ID
유럽 벨기에 europe-west1
유럽 런던 europe-west2
아시아 태평양 시드니 australia-southeast1
아시아 태평양 도쿄 asia-northeast1
전역 Dialogflow 제공은 전역이며, 저장 데이터이며 미국 내입니다. global(권장), us(지원 중단됨) 또는 리전 없음(기본값)

콘솔을 사용하여 리전 선택

Dialogflow ES 콘솔의 왼쪽 위 영역에 리전 선택 드롭다운이 있습니다. 모든 에이전트에는 만들 때 지정되는 변경할 수 없는 리전이 있습니다. 콘솔에서 리전을 선택할 때는 선택한 리전에 대한 에이전트만 나열하거나 만들 수 있습니다. 기본 리전은 us입니다.

API를 사용하여 리전 선택

에이전트가 기본이 아닌 리전에서 생성된 경우 설계 시 또는 런타임 요청에 대한 API를 호출할 때 해당 리전을 지정해야 합니다.

리전을 제공하려면 API 요청에 location 매개변수를 제공합니다. REST 호출의 경우 다음을 모두 수행합니다.

  • location URL 경로 매개변수를 제공합니다.
  • REGION_ID-dialogflow.googleapis.com 형식의 리전별 호스트 이름을 사용합니다. 예를 들면 asia-northeast1-dialogflow.googleapis.com입니다. 호스트 이름에 지정된 리전이 URL 경로에 지정된 리전과 일치하지 않으면 요청이 거부됩니다.

클라이언트 라이브러리의 경우 클라이언트 라이브러리 문서를 참조하세요. 다음 조치를 취하세요.

  • Dialogflow 서비스 엔드포인트를 다음과 같이 설정합니다.

    REGION_ID-dialogflow.googleapis.com:443
    
  • 세션 이름을 다음과 같이 설정합니다.

    projects/PROJECT_ID/locations/REGION_ID/agent/sessions/SESSION_ID
    

예를 들면 다음과 같습니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: Google Cloud 프로젝트 ID
  • REGION_ID: 리전 ID(예: europe-west2)
  • SESSION_ID: 세션 ID

HTTP 메서드 및 URL:

POST https://REGION_ID-dialogflow.googleapis.com/v2/projects/PROJECT_ID/locations/REGION_ID/agent/sessions/SESSION_ID:detectIntent

JSON 요청 본문:

{
  "query_input": {
    "text": {
      "text": "I want a pony.",
      "language_code": "en-US"
    }
  }
}

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

 

Java

CTS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


import com.google.api.gax.rpc.ApiException;
import com.google.cloud.dialogflow.v2beta1.DetectIntentResponse;
import com.google.cloud.dialogflow.v2beta1.QueryInput;
import com.google.cloud.dialogflow.v2beta1.QueryResult;
import com.google.cloud.dialogflow.v2beta1.SessionName;
import com.google.cloud.dialogflow.v2beta1.SessionsClient;
import com.google.cloud.dialogflow.v2beta1.SessionsSettings;
import com.google.cloud.dialogflow.v2beta1.TextInput;
import com.google.common.collect.Maps;
import java.io.IOException;
import java.util.List;
import java.util.Map;

public class DetectIntentWithLocation {

  // DialogFlow API Detect Intent sample with text inputs.
  public static Map<String, QueryResult> detectIntentWithLocation(
      String projectId,
      String locationId,
      List<String> texts,
      String sessionId,
      String languageCode)
      throws IOException, ApiException {
    SessionsSettings sessionsSettings =
        SessionsSettings.newBuilder()
            .setEndpoint(locationId + "-dialogflow.googleapis.com:443")
            .build();
    Map<String, QueryResult> queryResults = Maps.newHashMap();
    // Instantiates a client
    try (SessionsClient sessionsClient = SessionsClient.create(sessionsSettings)) {
      // Set the session name using the projectId (my-project-id), locationId and sessionId (UUID)
      SessionName session =
          SessionName.ofProjectLocationSessionName(projectId, locationId, sessionId);
      System.out.println("Session Path: " + session.toString());

      // Detect intents for each text input
      for (String text : texts) {
        // Set the text (hello) and language code (en-US) for the query
        TextInput.Builder textInput =
            TextInput.newBuilder().setText(text).setLanguageCode(languageCode);

        // Build the query with the TextInput
        QueryInput queryInput = QueryInput.newBuilder().setText(textInput).build();

        // Performs the detect intent request
        DetectIntentResponse response = sessionsClient.detectIntent(session, queryInput);

        // Display the query result
        QueryResult queryResult = response.getQueryResult();

        System.out.println("====================");
        System.out.format("Query Text: '%s'\n", queryResult.getQueryText());
        System.out.format(
            "Detected Intent: %s (confidence: %f)\n",
            queryResult.getIntent().getDisplayName(), queryResult.getIntentDetectionConfidence());
        System.out.format(
            "Fulfillment Text: '%s'\n",
            queryResult.getFulfillmentMessagesCount() > 0
                ? queryResult.getFulfillmentMessages(0).getText()
                : "Triggered Default Fallback Intent");

        queryResults.put(text, queryResult);
      }
    }
    return queryResults;
  }
}

Python

CTS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

def detect_intent_texts_with_location(
    project_id, location_id, session_id, texts, language_code
):
    """Returns the result of detect intent with texts as inputs.

    Using the same `session_id` between requests allows continuation
    of the conversation."""
    from google.cloud import dialogflow

    session_client = dialogflow.SessionsClient(
        client_options={"api_endpoint": f"{location_id}-dialogflow.googleapis.com"}
    )

    session = (
        f"projects/{project_id}/locations/{location_id}/agent/sessions/{session_id}"
    )
    print(f"Session path: {session}\n")

    for text in texts:
        text_input = dialogflow.TextInput(text=text, language_code=language_code)

        query_input = dialogflow.QueryInput(text=text_input)

        response = session_client.detect_intent(
            request={"session": session, "query_input": query_input}
        )

        print("=" * 20)
        print(f"Query text: {response.query_result.query_text}")
        print(
            f"Detected intent: {response.query_result.intent.display_name} (confidence: {response.query_result.intent_detection_confidence,})\n"
        )
        print(f"Fulfillment text: {response.query_result.fulfillment_text}\n")

추가 언어

C#: 클라이언트 라이브러리 페이지의 C# 설정 안내를 따른 다음 .NET용 Dialogflow 참조 문서를 참조하세요.

PHP: 클라이언트 라이브러리 페이지의 PHP 설정 안내를 따른 다음 PHP용 Dialogflow 참조 문서를 참조하세요.

Ruby: 클라이언트 라이브러리 페이지의 Ruby 설정 안내를 따른 다음 Ruby용 Dialogflow 참조 문서를 참조하세요.

Cloud Logging

로그가 저장되는 리전을 제어하는 방법은 Cloud Logging 가이드를 참조하세요.

제한사항

Dialogflow 콘솔에서 기본이 아닌 리전이 선택되면 다음 기능을 사용할 수 없습니다.

많은 REST 참조 문서에 있는 API 탐색기는 API 호출에 global 리전만 지원합니다.