context.proto 14 KB

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