conversation.proto 15 KB

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