xref: /aosp_15_r20/external/googleapis/google/cloud/dialogflow/v2beta1/context.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
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: If parameter's entity type is a composite entity then use
221  // map, otherwise, depending on the parameter value type, it could be one of
222  // string, number, boolean, null, list or map.
223  // * MapValue value: If parameter's entity type is a composite entity then use
224  // map from composite entity property names to property values, otherwise,
225  // use parameter value.
226  google.protobuf.Struct parameters = 3;
227}
228
229// The request message for
230// [Contexts.ListContexts][google.cloud.dialogflow.v2beta1.Contexts.ListContexts].
231message ListContextsRequest {
232  // Required. The session to list all contexts from. Supported formats:
233  // - `projects/<Project ID>/agent/sessions/<Session ID>,
234  // - `projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session
235  //   ID>`,
236  // - `projects/<Project ID>/agent/environments/<Environment ID>/users/<User
237  //   ID>/sessions/<Session ID>`,
238  // - `projects/<Project ID>/locations/<Location
239  //   ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session
240  //   ID>`,
241  //
242  // If `Location ID` is not specified we assume default 'us' location. If
243  // `Environment ID` is not specified, we assume default 'draft' environment.
244  // If `User ID` is not specified, we assume default '-' user.
245  string parent = 1 [
246    (google.api.field_behavior) = REQUIRED,
247    (google.api.resource_reference) = {
248      child_type: "dialogflow.googleapis.com/Context"
249    }
250  ];
251
252  // Optional. The maximum number of items to return in a single page. By
253  // default 100 and at most 1000.
254  int32 page_size = 2;
255
256  // Optional. The next_page_token value returned from a previous list request.
257  string page_token = 3;
258}
259
260// The response message for
261// [Contexts.ListContexts][google.cloud.dialogflow.v2beta1.Contexts.ListContexts].
262message ListContextsResponse {
263  // The list of contexts. There will be a maximum number of items
264  // returned based on the page_size field in the request.
265  repeated Context contexts = 1;
266
267  // Token to retrieve the next page of results, or empty if there are no
268  // more results in the list.
269  string next_page_token = 2;
270}
271
272// The request message for
273// [Contexts.GetContext][google.cloud.dialogflow.v2beta1.Contexts.GetContext].
274message GetContextRequest {
275  // Required. The name of the context. Supported formats:
276  // - `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context
277  //   ID>`,
278  // - `projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session
279  //   ID>/contexts/<Context ID>`,
280  // - `projects/<Project ID>/agent/environments/<Environment ID>/users/<User
281  //   ID>/sessions/<Session ID>/contexts/<Context ID>`,
282  // - `projects/<Project ID>/locations/<Location
283  //   ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session
284  //   ID>/contexts/<Context ID>`,
285  //
286  // If `Location ID` is not specified we assume default 'us' location. If
287  // `Environment ID` is not specified, we assume default 'draft' environment.
288  // If `User ID` is not specified, we assume default '-' user.
289  string name = 1 [
290    (google.api.field_behavior) = REQUIRED,
291    (google.api.resource_reference) = {
292      type: "dialogflow.googleapis.com/Context"
293    }
294  ];
295}
296
297// The request message for
298// [Contexts.CreateContext][google.cloud.dialogflow.v2beta1.Contexts.CreateContext].
299message CreateContextRequest {
300  // Required. The session to create a context for. Supported formats:
301  // - `projects/<Project ID>/agent/sessions/<Session ID>,
302  // - `projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session
303  //   ID>`,
304  // - `projects/<Project ID>/agent/environments/<Environment ID>/users/<User
305  //   ID>/sessions/<Session ID>`,
306  // - `projects/<Project ID>/locations/<Location
307  //   ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session
308  //   ID>`,
309  //
310  // If `Location ID` is not specified we assume default 'us' location. If
311  // `Environment ID` is not specified, we assume default 'draft' environment.
312  // If `User ID` is not specified, we assume default '-' user.
313  string parent = 1 [
314    (google.api.field_behavior) = REQUIRED,
315    (google.api.resource_reference) = {
316      child_type: "dialogflow.googleapis.com/Context"
317    }
318  ];
319
320  // Required. The context to create.
321  Context context = 2 [(google.api.field_behavior) = REQUIRED];
322}
323
324// The request message for
325// [Contexts.UpdateContext][google.cloud.dialogflow.v2beta1.Contexts.UpdateContext].
326message UpdateContextRequest {
327  // Required. The context to update.
328  Context context = 1 [(google.api.field_behavior) = REQUIRED];
329
330  // Optional. The mask to control which fields get updated.
331  google.protobuf.FieldMask update_mask = 2
332      [(google.api.field_behavior) = OPTIONAL];
333}
334
335// The request message for
336// [Contexts.DeleteContext][google.cloud.dialogflow.v2beta1.Contexts.DeleteContext].
337message DeleteContextRequest {
338  // Required. The name of the context to delete. Supported formats:
339  // - `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context
340  //   ID>`,
341  // - `projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session
342  //   ID>/contexts/<Context ID>`,
343  // - `projects/<Project ID>/agent/environments/<Environment ID>/users/<User
344  //   ID>/sessions/<Session ID>/contexts/<Context ID>`,
345  // - `projects/<Project ID>/locations/<Location
346  //   ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session
347  //   ID>/contexts/<Context ID>`,
348  //
349  // If `Location ID` is not specified we assume default 'us' location. If
350  // `Environment ID` is not specified, we assume default 'draft' environment.
351  // If `User ID` is not specified, we assume default '-' user.
352  string name = 1 [
353    (google.api.field_behavior) = REQUIRED,
354    (google.api.resource_reference) = {
355      type: "dialogflow.googleapis.com/Context"
356    }
357  ];
358}
359
360// The request message for
361// [Contexts.DeleteAllContexts][google.cloud.dialogflow.v2beta1.Contexts.DeleteAllContexts].
362message DeleteAllContextsRequest {
363  // Required. The name of the session to delete all contexts from. Supported
364  // formats:
365  // - `projects/<Project ID>/agent/sessions/<Session ID>,
366  // - `projects/<Project ID>/locations/<Location ID>/agent/sessions/<Session
367  //   ID>`,
368  // - `projects/<Project ID>/agent/environments/<Environment ID>/users/<User
369  //   ID>/sessions/<Session ID>`,
370  // - `projects/<Project ID>/locations/<Location
371  //   ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session
372  //   ID>`,
373  //
374  // If `Location ID` is not specified we assume default 'us' location. If
375  // `Environment ID` is not specified we assume default 'draft' environment. If
376  // `User ID` is not specified, we assume default '-' user.
377  string parent = 1 [
378    (google.api.field_behavior) = REQUIRED,
379    (google.api.resource_reference) = {
380      child_type: "dialogflow.googleapis.com/Context"
381    }
382  ];
383}
384