1// Copyright 2023 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.cloud.dialogflow.v2beta1; 18 19import "google/api/annotations.proto"; 20import "google/api/client.proto"; 21import "google/api/field_behavior.proto"; 22import "google/api/resource.proto"; 23import "google/protobuf/empty.proto"; 24import "google/protobuf/field_mask.proto"; 25import "google/protobuf/struct.proto"; 26 27option cc_enable_arenas = true; 28option csharp_namespace = "Google.Cloud.Dialogflow.V2Beta1"; 29option go_package = "cloud.google.com/go/dialogflow/apiv2beta1/dialogflowpb;dialogflowpb"; 30option java_multiple_files = true; 31option java_outer_classname = "ContextProto"; 32option java_package = "com.google.cloud.dialogflow.v2beta1"; 33option objc_class_prefix = "DF"; 34 35// Service for managing [Contexts][google.cloud.dialogflow.v2beta1.Context]. 36service Contexts { 37 option (google.api.default_host) = "dialogflow.googleapis.com"; 38 option (google.api.oauth_scopes) = 39 "https://www.googleapis.com/auth/cloud-platform," 40 "https://www.googleapis.com/auth/dialogflow"; 41 42 // Returns the list of all contexts in the specified session. 43 rpc ListContexts(ListContextsRequest) returns (ListContextsResponse) { 44 option (google.api.http) = { 45 get: "/v2beta1/{parent=projects/*/agent/sessions/*}/contexts" 46 additional_bindings { 47 get: "/v2beta1/{parent=projects/*/agent/environments/*/users/*/sessions/*}/contexts" 48 } 49 additional_bindings { 50 get: "/v2beta1/{parent=projects/*/locations/*/agent/sessions/*}/contexts" 51 } 52 additional_bindings { 53 get: "/v2beta1/{parent=projects/*/locations/*/agent/environments/*/users/*/sessions/*}/contexts" 54 } 55 }; 56 option (google.api.method_signature) = "parent"; 57 } 58 59 // Retrieves the specified context. 60 rpc GetContext(GetContextRequest) returns (Context) { 61 option (google.api.http) = { 62 get: "/v2beta1/{name=projects/*/agent/sessions/*/contexts/*}" 63 additional_bindings { 64 get: "/v2beta1/{name=projects/*/agent/environments/*/users/*/sessions/*/contexts/*}" 65 } 66 additional_bindings { 67 get: "/v2beta1/{name=projects/*/locations/*/agent/sessions/*/contexts/*}" 68 } 69 additional_bindings { 70 get: "/v2beta1/{name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/contexts/*}" 71 } 72 }; 73 option (google.api.method_signature) = "name"; 74 } 75 76 // Creates a context. 77 // 78 // If the specified context already exists, overrides the context. 79 rpc CreateContext(CreateContextRequest) returns (Context) { 80 option (google.api.http) = { 81 post: "/v2beta1/{parent=projects/*/agent/sessions/*}/contexts" 82 body: "context" 83 additional_bindings { 84 post: "/v2beta1/{parent=projects/*/agent/environments/*/users/*/sessions/*}/contexts" 85 body: "context" 86 } 87 additional_bindings { 88 post: "/v2beta1/{parent=projects/*/locations/*/agent/sessions/*}/contexts" 89 body: "context" 90 } 91 additional_bindings { 92 post: "/v2beta1/{parent=projects/*/locations/*/agent/environments/*/users/*/sessions/*}/contexts" 93 body: "context" 94 } 95 }; 96 option (google.api.method_signature) = "parent,context"; 97 } 98 99 // Updates the specified context. 100 rpc UpdateContext(UpdateContextRequest) returns (Context) { 101 option (google.api.http) = { 102 patch: "/v2beta1/{context.name=projects/*/agent/sessions/*/contexts/*}" 103 body: "context" 104 additional_bindings { 105 patch: "/v2beta1/{context.name=projects/*/agent/environments/*/users/*/sessions/*/contexts/*}" 106 body: "context" 107 } 108 additional_bindings { 109 patch: "/v2beta1/{context.name=projects/*/locations/*/agent/sessions/*/contexts/*}" 110 body: "context" 111 } 112 additional_bindings { 113 patch: "/v2beta1/{context.name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/contexts/*}" 114 body: "context" 115 } 116 }; 117 option (google.api.method_signature) = "context,update_mask"; 118 option (google.api.method_signature) = "context"; 119 } 120 121 // Deletes the specified context. 122 rpc DeleteContext(DeleteContextRequest) returns (google.protobuf.Empty) { 123 option (google.api.http) = { 124 delete: "/v2beta1/{name=projects/*/agent/sessions/*/contexts/*}" 125 additional_bindings { 126 delete: "/v2beta1/{name=projects/*/agent/environments/*/users/*/sessions/*/contexts/*}" 127 } 128 additional_bindings { 129 delete: "/v2beta1/{name=projects/*/locations/*/agent/sessions/*/contexts/*}" 130 } 131 additional_bindings { 132 delete: "/v2beta1/{name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/contexts/*}" 133 } 134 }; 135 option (google.api.method_signature) = "name"; 136 } 137 138 // Deletes all active contexts in the specified session. 139 rpc DeleteAllContexts(DeleteAllContextsRequest) 140 returns (google.protobuf.Empty) { 141 option (google.api.http) = { 142 delete: "/v2beta1/{parent=projects/*/agent/sessions/*}/contexts" 143 additional_bindings { 144 delete: "/v2beta1/{parent=projects/*/agent/environments/*/users/*/sessions/*}/contexts" 145 } 146 additional_bindings { 147 delete: "/v2beta1/{parent=projects/*/locations/*/agent/sessions/*}/contexts" 148 } 149 additional_bindings { 150 delete: "/v2beta1/{parent=projects/*/locations/*/agent/environments/*/users/*/sessions/*}/contexts" 151 } 152 }; 153 option (google.api.method_signature) = "parent"; 154 } 155} 156 157// Dialogflow contexts are similar to natural language context. If a person says 158// to you "they are orange", you need context in order to understand what "they" 159// is referring to. Similarly, for Dialogflow to handle an end-user expression 160// like that, it needs to be provided with context in order to correctly match 161// an intent. 162// 163// Using contexts, you can control the flow of a conversation. You can configure 164// contexts for an intent by setting input and output contexts, which are 165// identified by string names. When an intent is matched, any configured output 166// contexts for that intent become active. While any contexts are active, 167// Dialogflow is more likely to match intents that are configured with input 168// contexts that correspond to the currently active contexts. 169// 170// For more information about context, see the 171// [Contexts guide](https://cloud.google.com/dialogflow/docs/contexts-overview). 172message Context { 173 option (google.api.resource) = { 174 type: "dialogflow.googleapis.com/Context" 175 pattern: "projects/{project}/agent/sessions/{session}/contexts/{context}" 176 pattern: "projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context}" 177 pattern: "projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context}" 178 pattern: "projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context}" 179 }; 180 181 // Required. The unique identifier of the context. Supported formats: 182 // - `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context 183 // ID>`, 184 // - `projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session 185 // ID>/contexts/<Context ID>`, 186 // - `projects/<Project ID>/agent/environments/<Environment ID>/users/<User 187 // ID>/sessions/<Session ID>/contexts/<Context ID>`, 188 // - `projects/<Project ID>/locations/<Location 189 // ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session 190 // ID>/contexts/<Context ID>`, 191 // 192 // The `Context ID` is always converted to lowercase, may only contain 193 // characters in a-zA-Z0-9_-% and may be at most 250 bytes long. 194 // 195 // If `Environment ID` is not specified, we assume default 'draft' 196 // environment. If `User ID` is not specified, we assume default '-' user. 197 // 198 // The following context names are reserved for internal use by Dialogflow. 199 // You should not use these contexts or create contexts with these names: 200 // 201 // * `__system_counters__` 202 // * `*_id_dialog_context` 203 // * `*_dialog_params_size` 204 string name = 1; 205 206 // Optional. The number of conversational query requests after which the 207 // context expires. The default is `0`. If set to `0`, the context expires 208 // immediately. Contexts expire automatically after 20 minutes if there 209 // are no matching queries. 210 int32 lifespan_count = 2; 211 212 // Optional. The collection of parameters associated with this context. 213 // 214 // Depending on your protocol or client library language, this is a 215 // map, associative array, symbol table, dictionary, or JSON object 216 // composed of a collection of (MapKey, MapValue) pairs: 217 // 218 // - MapKey type: string 219 // - MapKey value: parameter name 220 // - MapValue type: 221 // - If parameter's entity type is a composite entity: map 222 // - Else: depending on parameter value type, could be one of string, 223 // number, boolean, null, list or map 224 // - MapValue value: 225 // - If parameter's entity type is a composite entity: 226 // map from composite entity property names to property values 227 // - Else: parameter value 228 google.protobuf.Struct parameters = 3; 229} 230 231// The request message for 232// [Contexts.ListContexts][google.cloud.dialogflow.v2beta1.Contexts.ListContexts]. 233message ListContextsRequest { 234 // Required. The session to list all contexts from. Supported formats: 235 // - `projects/<Project ID>/agent/sessions/<Session ID>, 236 // - `projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session 237 // ID>`, 238 // - `projects/<Project ID>/agent/environments/<Environment ID>/users/<User 239 // ID>/sessions/<Session ID>`, 240 // - `projects/<Project ID>/locations/<Location 241 // ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session 242 // ID>`, 243 // 244 // If `Location ID` is not specified we assume default 'us' location. If 245 // `Environment ID` is not specified, we assume default 'draft' environment. 246 // If `User ID` is not specified, we assume default '-' user. 247 string parent = 1 [ 248 (google.api.field_behavior) = REQUIRED, 249 (google.api.resource_reference) = { 250 child_type: "dialogflow.googleapis.com/Context" 251 } 252 ]; 253 254 // Optional. The maximum number of items to return in a single page. By 255 // default 100 and at most 1000. 256 int32 page_size = 2; 257 258 // Optional. The next_page_token value returned from a previous list request. 259 string page_token = 3; 260} 261 262// The response message for 263// [Contexts.ListContexts][google.cloud.dialogflow.v2beta1.Contexts.ListContexts]. 264message ListContextsResponse { 265 // The list of contexts. There will be a maximum number of items 266 // returned based on the page_size field in the request. 267 repeated Context contexts = 1; 268 269 // Token to retrieve the next page of results, or empty if there are no 270 // more results in the list. 271 string next_page_token = 2; 272} 273 274// The request message for 275// [Contexts.GetContext][google.cloud.dialogflow.v2beta1.Contexts.GetContext]. 276message GetContextRequest { 277 // Required. The name of the context. Supported formats: 278 // - `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context 279 // ID>`, 280 // - `projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session 281 // ID>/contexts/<Context ID>`, 282 // - `projects/<Project ID>/agent/environments/<Environment ID>/users/<User 283 // ID>/sessions/<Session ID>/contexts/<Context ID>`, 284 // - `projects/<Project ID>/locations/<Location 285 // ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session 286 // ID>/contexts/<Context ID>`, 287 // 288 // If `Location ID` is not specified we assume default 'us' location. If 289 // `Environment ID` is not specified, we assume default 'draft' environment. 290 // If `User ID` is not specified, we assume default '-' user. 291 string name = 1 [ 292 (google.api.field_behavior) = REQUIRED, 293 (google.api.resource_reference) = { 294 type: "dialogflow.googleapis.com/Context" 295 } 296 ]; 297} 298 299// The request message for 300// [Contexts.CreateContext][google.cloud.dialogflow.v2beta1.Contexts.CreateContext]. 301message CreateContextRequest { 302 // Required. The session to create a context for. Supported formats: 303 // - `projects/<Project ID>/agent/sessions/<Session ID>, 304 // - `projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session 305 // ID>`, 306 // - `projects/<Project ID>/agent/environments/<Environment ID>/users/<User 307 // ID>/sessions/<Session ID>`, 308 // - `projects/<Project ID>/locations/<Location 309 // ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session 310 // ID>`, 311 // 312 // If `Location ID` is not specified we assume default 'us' location. If 313 // `Environment ID` is not specified, we assume default 'draft' environment. 314 // If `User ID` is not specified, we assume default '-' user. 315 string parent = 1 [ 316 (google.api.field_behavior) = REQUIRED, 317 (google.api.resource_reference) = { 318 child_type: "dialogflow.googleapis.com/Context" 319 } 320 ]; 321 322 // Required. The context to create. 323 Context context = 2 [(google.api.field_behavior) = REQUIRED]; 324} 325 326// The request message for 327// [Contexts.UpdateContext][google.cloud.dialogflow.v2beta1.Contexts.UpdateContext]. 328message UpdateContextRequest { 329 // Required. The context to update. 330 Context context = 1 [(google.api.field_behavior) = REQUIRED]; 331 332 // Optional. The mask to control which fields get updated. 333 google.protobuf.FieldMask update_mask = 2 334 [(google.api.field_behavior) = OPTIONAL]; 335} 336 337// The request message for 338// [Contexts.DeleteContext][google.cloud.dialogflow.v2beta1.Contexts.DeleteContext]. 339message DeleteContextRequest { 340 // Required. The name of the context to delete. Supported formats: 341 // - `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context 342 // ID>`, 343 // - `projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session 344 // ID>/contexts/<Context ID>`, 345 // - `projects/<Project ID>/agent/environments/<Environment ID>/users/<User 346 // ID>/sessions/<Session ID>/contexts/<Context ID>`, 347 // - `projects/<Project ID>/locations/<Location 348 // ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session 349 // ID>/contexts/<Context ID>`, 350 // 351 // If `Location ID` is not specified we assume default 'us' location. If 352 // `Environment ID` is not specified, we assume default 'draft' environment. 353 // If `User ID` is not specified, we assume default '-' user. 354 string name = 1 [ 355 (google.api.field_behavior) = REQUIRED, 356 (google.api.resource_reference) = { 357 type: "dialogflow.googleapis.com/Context" 358 } 359 ]; 360} 361 362// The request message for 363// [Contexts.DeleteAllContexts][google.cloud.dialogflow.v2beta1.Contexts.DeleteAllContexts]. 364message DeleteAllContextsRequest { 365 // Required. The name of the session to delete all contexts from. Supported 366 // formats: 367 // - `projects/<Project ID>/agent/sessions/<Session ID>, 368 // - `projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session 369 // ID>`, 370 // - `projects/<Project ID>/agent/environments/<Environment ID>/users/<User 371 // ID>/sessions/<Session ID>`, 372 // - `projects/<Project ID>/locations/<Location 373 // ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session 374 // ID>`, 375 // 376 // If `Location ID` is not specified we assume default 'us' location. If 377 // `Environment ID` is not specified we assume default 'draft' environment. If 378 // `User ID` is not specified, we assume default '-' user. 379 string parent = 1 [ 380 (google.api.field_behavior) = REQUIRED, 381 (google.api.resource_reference) = { 382 child_type: "dialogflow.googleapis.com/Context" 383 } 384 ]; 385} 386