Regionalization and data residency

Dialogflow provides data residency to keep your data-at-rest physically within a geographical region or location. When a region is specified, your data-at-rest is not replicated outside the region. Pricing is the same for all regions.

Regions are used for the following reasons:

  • Your system may have regulatory or policy requirements that govern where your data must reside.
  • Your network latencies may be improved when the data is in the same region as your customers. For example, If UK customers use europe-west2, they can expect better latency.

Data-at-rest

All Dialogflow developer user and end-user data is included in data-at-rest. For example:

  • All agent resources set with console or API (intents, entities, etc.)
  • All agent settings set with console or API
  • Query history
  • Validation results
  • Model creation tasks
  • Training tasks
  • Long-running operation tasks

Available regions

Dialogflow provides the following regions:

Country grouping Geographical location Region ID
Europe Belgium europe-west1
Europe London europe-west2
Asia Pacific Sydney australia-southeast1
Asia Pacific Tokyo asia-northeast1
Global Dialogflow serving is global, data-at-rest is within US global (preferred), us or no region (default)

Select a region with the console

The top left area of the Dialogflow ES Console has a drop-down for region selection. Every agent has an immutable region that is specified upon creation. When you select a region from the console, you can only list or create agents for the selected region. The default region is us.

Select a region with the API

If your agent was created in a non-default region, you must specify that region when calling the API for either design-time or runtime requests.

To provide a region, you supply a location parameter to API requests. For REST calls, do both of the following:

  • Provide the location URL path parameter.
  • Use the region-specific hostname of the form REGION_ID-dialogflow.googleapis.com. For example: asia-northeast1-dialogflow.googleapis.com. If the region specified in the hostname does not match the region specified in the URL path, the request will be rejected.

For client libraries, see the client library documentation. You need to do the following:

  • Set the Dialogflow service endpoint to:

    REGION_ID-dialogflow.googleapis.com:443
    
  • Set the session name to:

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

For example:

REST & CMD LINE

Before using any of the request data below, make the following replacements:

  • PROJECT_ID: your GCP project ID
  • REGION_ID: a region ID, example: europe-west2
  • SESSION_ID: a session ID

HTTP method and URL:

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

Request JSON body:

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

To send your request, expand one of these options:

 

Java


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

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")

Additional languages

C#: Please follow the C# setup instructions on the client libraries page and then visit the Dialogflow reference documentation for .NET.

PHP: Please follow the PHP setup instructions on the client libraries page and then visit the Dialogflow reference documentation for PHP.

Ruby: Please follow the Ruby setup instructions on the client libraries page and then visit the Dialogflow reference documentation for Ruby.

Cloud logging

See the Cloud logging guide to control the region in which logs are stored.

Limitations

When a non-default region is selected in the Dialogflow Console, the following features are not available: