context.proto 16 KB

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