conversation.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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/cloud/dialogflow/v2/participant.proto";
  21. import "google/protobuf/timestamp.proto";
  22. option cc_enable_arenas = true;
  23. option csharp_namespace = "Google.Cloud.Dialogflow.V2";
  24. option go_package = "google.golang.org/genproto/googleapis/cloud/dialogflow/v2;dialogflow";
  25. option java_multiple_files = true;
  26. option java_outer_classname = "ConversationProto";
  27. option java_package = "com.google.cloud.dialogflow.v2";
  28. option objc_class_prefix = "DF";
  29. // Service for managing [Conversations][google.cloud.dialogflow.v2.Conversation].
  30. service Conversations {
  31. option (google.api.default_host) = "dialogflow.googleapis.com";
  32. option (google.api.oauth_scopes) =
  33. "https://www.googleapis.com/auth/cloud-platform,"
  34. "https://www.googleapis.com/auth/dialogflow";
  35. // Creates a new conversation. Conversations are auto-completed after 24
  36. // hours.
  37. //
  38. // Conversation Lifecycle:
  39. // There are two stages during a conversation: Automated Agent Stage and
  40. // Assist Stage.
  41. //
  42. // For Automated Agent Stage, there will be a dialogflow agent responding to
  43. // user queries.
  44. //
  45. // For Assist Stage, there's no dialogflow agent responding to user queries.
  46. // But we will provide suggestions which are generated from conversation.
  47. //
  48. // If [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile] is configured for a dialogflow
  49. // agent, conversation will start from `Automated Agent Stage`, otherwise, it
  50. // will start from `Assist Stage`. And during `Automated Agent Stage`, once an
  51. // [Intent][google.cloud.dialogflow.v2.Intent] with [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff] is triggered, conversation
  52. // will transfer to Assist Stage.
  53. rpc CreateConversation(CreateConversationRequest) returns (Conversation) {
  54. option (google.api.http) = {
  55. post: "/v2/{parent=projects/*}/conversations"
  56. body: "conversation"
  57. additional_bindings {
  58. post: "/v2/{parent=projects/*/locations/*}/conversations"
  59. body: "conversation"
  60. }
  61. };
  62. option (google.api.method_signature) = "parent,conversation";
  63. }
  64. // Returns the list of all conversations in the specified project.
  65. rpc ListConversations(ListConversationsRequest) returns (ListConversationsResponse) {
  66. option (google.api.http) = {
  67. get: "/v2/{parent=projects/*}/conversations"
  68. additional_bindings {
  69. get: "/v2/{parent=projects/*/locations/*}/conversations"
  70. }
  71. };
  72. option (google.api.method_signature) = "parent";
  73. }
  74. // Retrieves the specific conversation.
  75. rpc GetConversation(GetConversationRequest) returns (Conversation) {
  76. option (google.api.http) = {
  77. get: "/v2/{name=projects/*/conversations/*}"
  78. additional_bindings {
  79. get: "/v2/{name=projects/*/locations/*/conversations/*}"
  80. }
  81. };
  82. option (google.api.method_signature) = "name";
  83. }
  84. // Completes the specified conversation. Finished conversations are purged
  85. // from the database after 30 days.
  86. rpc CompleteConversation(CompleteConversationRequest) returns (Conversation) {
  87. option (google.api.http) = {
  88. post: "/v2/{name=projects/*/conversations/*}:complete"
  89. body: "*"
  90. additional_bindings {
  91. post: "/v2/{name=projects/*/locations/*/conversations/*}:complete"
  92. body: "*"
  93. }
  94. };
  95. option (google.api.method_signature) = "name";
  96. }
  97. // Lists messages that belong to a given conversation.
  98. // `messages` are ordered by `create_time` in descending order. To fetch
  99. // updates without duplication, send request with filter
  100. // `create_time_epoch_microseconds >
  101. // [first item's create_time of previous request]` and empty page_token.
  102. rpc ListMessages(ListMessagesRequest) returns (ListMessagesResponse) {
  103. option (google.api.http) = {
  104. get: "/v2/{parent=projects/*/conversations/*}/messages"
  105. additional_bindings {
  106. get: "/v2/{parent=projects/*/locations/*/conversations/*}/messages"
  107. }
  108. };
  109. option (google.api.method_signature) = "parent";
  110. }
  111. }
  112. // Represents a conversation.
  113. // A conversation is an interaction between an agent, including live agents
  114. // and Dialogflow agents, and a support customer. Conversations can
  115. // include phone calls and text-based chat sessions.
  116. message Conversation {
  117. option (google.api.resource) = {
  118. type: "dialogflow.googleapis.com/Conversation"
  119. pattern: "projects/{project}/conversations/{conversation}"
  120. pattern: "projects/{project}/locations/{location}/conversations/{conversation}"
  121. };
  122. // Enumeration of the completion status of the conversation.
  123. enum LifecycleState {
  124. // Unknown.
  125. LIFECYCLE_STATE_UNSPECIFIED = 0;
  126. // Conversation is currently open for media analysis.
  127. IN_PROGRESS = 1;
  128. // Conversation has been completed.
  129. COMPLETED = 2;
  130. }
  131. // Enumeration of the different conversation stages a conversation can be in.
  132. // Reference:
  133. // https://cloud.google.com/dialogflow/priv/docs/contact-center/basics#stages
  134. enum ConversationStage {
  135. // Unknown. Should never be used after a conversation is successfully
  136. // created.
  137. CONVERSATION_STAGE_UNSPECIFIED = 0;
  138. // The conversation should return virtual agent responses into the
  139. // conversation.
  140. VIRTUAL_AGENT_STAGE = 1;
  141. // The conversation should not provide responses, just listen and provide
  142. // suggestions.
  143. HUMAN_ASSIST_STAGE = 2;
  144. }
  145. // Output only. The unique identifier of this conversation.
  146. // Format: `projects/<Project ID>/locations/<Location
  147. // ID>/conversations/<Conversation ID>`.
  148. string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  149. // Output only. The current state of the Conversation.
  150. LifecycleState lifecycle_state = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  151. // Required. The Conversation Profile to be used to configure this
  152. // Conversation. This field cannot be updated.
  153. // Format: `projects/<Project ID>/locations/<Location
  154. // ID>/conversationProfiles/<Conversation Profile ID>`.
  155. string conversation_profile = 3 [
  156. (google.api.field_behavior) = REQUIRED,
  157. (google.api.resource_reference) = {
  158. type: "dialogflow.googleapis.com/ConversationProfile"
  159. }
  160. ];
  161. // Output only. It will not be empty if the conversation is to be connected over
  162. // telephony.
  163. ConversationPhoneNumber phone_number = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  164. // Output only. The time the conversation was started.
  165. google.protobuf.Timestamp start_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  166. // Output only. The time the conversation was finished.
  167. google.protobuf.Timestamp end_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  168. // The stage of a conversation. It indicates whether the virtual agent or a
  169. // human agent is handling the conversation.
  170. //
  171. // If the conversation is created with the conversation profile that has
  172. // Dialogflow config set, defaults to
  173. // [ConversationStage.VIRTUAL_AGENT_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.VIRTUAL_AGENT_STAGE]; Otherwise, defaults to
  174. // [ConversationStage.HUMAN_ASSIST_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.HUMAN_ASSIST_STAGE].
  175. //
  176. // If the conversation is created with the conversation profile that has
  177. // Dialogflow config set but explicitly sets conversation_stage to
  178. // [ConversationStage.HUMAN_ASSIST_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.HUMAN_ASSIST_STAGE], it skips
  179. // [ConversationStage.VIRTUAL_AGENT_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.VIRTUAL_AGENT_STAGE] stage and directly goes to
  180. // [ConversationStage.HUMAN_ASSIST_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.HUMAN_ASSIST_STAGE].
  181. ConversationStage conversation_stage = 7;
  182. }
  183. // The request message for [Conversations.CreateConversation][google.cloud.dialogflow.v2.Conversations.CreateConversation].
  184. message CreateConversationRequest {
  185. // Required. Resource identifier of the project creating the conversation.
  186. // Format: `projects/<Project ID>/locations/<Location ID>`.
  187. string parent = 1 [
  188. (google.api.field_behavior) = REQUIRED,
  189. (google.api.resource_reference) = {
  190. child_type: "dialogflow.googleapis.com/Conversation"
  191. }
  192. ];
  193. // Required. The conversation to create.
  194. Conversation conversation = 2 [(google.api.field_behavior) = REQUIRED];
  195. // Optional. Identifier of the conversation. Generally it's auto generated by Google.
  196. // Only set it if you cannot wait for the response to return a
  197. // auto-generated one to you.
  198. //
  199. // The conversation ID must be compliant with the regression fomula
  200. // "[a-zA-Z][a-zA-Z0-9_-]*" with the characters length in range of [3,64].
  201. // If the field is provided, the caller is resposible for
  202. // 1. the uniqueness of the ID, otherwise the request will be rejected.
  203. // 2. the consistency for whether to use custom ID or not under a project to
  204. // better ensure uniqueness.
  205. string conversation_id = 3 [(google.api.field_behavior) = OPTIONAL];
  206. }
  207. // The request message for [Conversations.ListConversations][google.cloud.dialogflow.v2.Conversations.ListConversations].
  208. message ListConversationsRequest {
  209. // Required. The project from which to list all conversation.
  210. // Format: `projects/<Project ID>/locations/<Location ID>`.
  211. string parent = 1 [
  212. (google.api.field_behavior) = REQUIRED,
  213. (google.api.resource_reference) = {
  214. child_type: "dialogflow.googleapis.com/Conversation"
  215. }
  216. ];
  217. // Optional. The maximum number of items to return in a single page. By
  218. // default 100 and at most 1000.
  219. int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
  220. // Optional. The next_page_token value returned from a previous list request.
  221. string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
  222. // A filter expression that filters conversations listed in the response. In
  223. // general, the expression must specify the field name, a comparison operator,
  224. // and the value to use for filtering:
  225. // <ul>
  226. // <li>The value must be a string, a number, or a boolean.</li>
  227. // <li>The comparison operator must be either `=`,`!=`, `>`, or `<`.</li>
  228. // <li>To filter on multiple expressions, separate the
  229. // expressions with `AND` or `OR` (omitting both implies `AND`).</li>
  230. // <li>For clarity, expressions can be enclosed in parentheses.</li>
  231. // </ul>
  232. // Only `lifecycle_state` can be filtered on in this way. For example,
  233. // the following expression only returns `COMPLETED` conversations:
  234. //
  235. // `lifecycle_state = "COMPLETED"`
  236. //
  237. // For more information about filtering, see
  238. // [API Filtering](https://aip.dev/160).
  239. string filter = 4;
  240. }
  241. // The response message for [Conversations.ListConversations][google.cloud.dialogflow.v2.Conversations.ListConversations].
  242. message ListConversationsResponse {
  243. // The list of conversations. There will be a maximum number of items
  244. // returned based on the page_size field in the request.
  245. repeated Conversation conversations = 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 [Conversations.GetConversation][google.cloud.dialogflow.v2.Conversations.GetConversation].
  251. message GetConversationRequest {
  252. // Required. The name of the conversation. Format:
  253. // `projects/<Project ID>/locations/<Location ID>/conversations/<Conversation
  254. // ID>`.
  255. string name = 1 [
  256. (google.api.field_behavior) = REQUIRED,
  257. (google.api.resource_reference) = {
  258. type: "dialogflow.googleapis.com/Conversation"
  259. }
  260. ];
  261. }
  262. // The request message for [Conversations.CompleteConversation][google.cloud.dialogflow.v2.Conversations.CompleteConversation].
  263. message CompleteConversationRequest {
  264. // Required. Resource identifier of the conversation to close.
  265. // Format: `projects/<Project ID>/locations/<Location
  266. // ID>/conversations/<Conversation ID>`.
  267. string name = 1 [
  268. (google.api.field_behavior) = REQUIRED,
  269. (google.api.resource_reference) = {
  270. type: "dialogflow.googleapis.com/Conversation"
  271. }
  272. ];
  273. }
  274. // The request message for [Conversations.ListMessages][google.cloud.dialogflow.v2.Conversations.ListMessages].
  275. message ListMessagesRequest {
  276. // Required. The name of the conversation to list messages for.
  277. // Format: `projects/<Project ID>/locations/<Location
  278. // ID>/conversations/<Conversation ID>`
  279. string parent = 1 [
  280. (google.api.field_behavior) = REQUIRED,
  281. (google.api.resource_reference) = {
  282. child_type: "dialogflow.googleapis.com/Message"
  283. }
  284. ];
  285. // Optional. Filter on message fields. Currently predicates on `create_time`
  286. // and `create_time_epoch_microseconds` are supported. `create_time` only
  287. // support milliseconds accuracy. E.g.,
  288. // `create_time_epoch_microseconds > 1551790877964485` or
  289. // `create_time > 2017-01-15T01:30:15.01Z`.
  290. //
  291. // For more information about filtering, see
  292. // [API Filtering](https://aip.dev/160).
  293. string filter = 4 [(google.api.field_behavior) = OPTIONAL];
  294. // Optional. The maximum number of items to return in a single page. By
  295. // default 100 and at most 1000.
  296. int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
  297. // Optional. The next_page_token value returned from a previous list request.
  298. string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
  299. }
  300. // The response message for [Conversations.ListMessages][google.cloud.dialogflow.v2.Conversations.ListMessages].
  301. message ListMessagesResponse {
  302. // The list of messages. There will be a maximum number of items
  303. // returned based on the page_size field in the request.
  304. // `messages` is sorted by `create_time` in descending order.
  305. repeated Message messages = 1;
  306. // Token to retrieve the next page of results, or empty if there are
  307. // no more results in the list.
  308. string next_page_token = 2;
  309. }
  310. // Represents a phone number for telephony integration. It allows for connecting
  311. // a particular conversation over telephony.
  312. message ConversationPhoneNumber {
  313. // Output only. The phone number to connect to this conversation.
  314. string phone_number = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
  315. }