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.v2;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/cloud/dialogflow/v2/conversation_profile.proto";
24import "google/cloud/dialogflow/v2/participant.proto";
25import "google/protobuf/timestamp.proto";
26
27option cc_enable_arenas = true;
28option csharp_namespace = "Google.Cloud.Dialogflow.V2";
29option go_package = "cloud.google.com/go/dialogflow/apiv2/dialogflowpb;dialogflowpb";
30option java_multiple_files = true;
31option java_outer_classname = "ConversationProto";
32option java_package = "com.google.cloud.dialogflow.v2";
33option objc_class_prefix = "DF";
34
35// Service for managing
36// [Conversations][google.cloud.dialogflow.v2.Conversation].
37service Conversations {
38  option (google.api.default_host) = "dialogflow.googleapis.com";
39  option (google.api.oauth_scopes) =
40      "https://www.googleapis.com/auth/cloud-platform,"
41      "https://www.googleapis.com/auth/dialogflow";
42
43  // Creates a new conversation. Conversations are auto-completed after 24
44  // hours.
45  //
46  // Conversation Lifecycle:
47  // There are two stages during a conversation: Automated Agent Stage and
48  // Assist Stage.
49  //
50  // For Automated Agent Stage, there will be a dialogflow agent responding to
51  // user queries.
52  //
53  // For Assist Stage, there's no dialogflow agent responding to user queries.
54  // But we will provide suggestions which are generated from conversation.
55  //
56  // If
57  // [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile]
58  // is configured for a dialogflow agent, conversation will start from
59  // `Automated Agent Stage`, otherwise, it will start from `Assist Stage`. And
60  // during `Automated Agent Stage`, once an
61  // [Intent][google.cloud.dialogflow.v2.Intent] with
62  // [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff]
63  // is triggered, conversation will transfer to Assist Stage.
64  rpc CreateConversation(CreateConversationRequest) returns (Conversation) {
65    option (google.api.http) = {
66      post: "/v2/{parent=projects/*}/conversations"
67      body: "conversation"
68      additional_bindings {
69        post: "/v2/{parent=projects/*/locations/*}/conversations"
70        body: "conversation"
71      }
72    };
73    option (google.api.method_signature) = "parent,conversation";
74  }
75
76  // Returns the list of all conversations in the specified project.
77  rpc ListConversations(ListConversationsRequest)
78      returns (ListConversationsResponse) {
79    option (google.api.http) = {
80      get: "/v2/{parent=projects/*}/conversations"
81      additional_bindings {
82        get: "/v2/{parent=projects/*/locations/*}/conversations"
83      }
84    };
85    option (google.api.method_signature) = "parent";
86  }
87
88  // Retrieves the specific conversation.
89  rpc GetConversation(GetConversationRequest) returns (Conversation) {
90    option (google.api.http) = {
91      get: "/v2/{name=projects/*/conversations/*}"
92      additional_bindings {
93        get: "/v2/{name=projects/*/locations/*/conversations/*}"
94      }
95    };
96    option (google.api.method_signature) = "name";
97  }
98
99  // Completes the specified conversation. Finished conversations are purged
100  // from the database after 30 days.
101  rpc CompleteConversation(CompleteConversationRequest) returns (Conversation) {
102    option (google.api.http) = {
103      post: "/v2/{name=projects/*/conversations/*}:complete"
104      body: "*"
105      additional_bindings {
106        post: "/v2/{name=projects/*/locations/*/conversations/*}:complete"
107        body: "*"
108      }
109    };
110    option (google.api.method_signature) = "name";
111  }
112
113  // Lists messages that belong to a given conversation.
114  // `messages` are ordered by `create_time` in descending order. To fetch
115  // updates without duplication, send request with filter
116  // `create_time_epoch_microseconds >
117  // [first item's create_time of previous request]` and empty page_token.
118  rpc ListMessages(ListMessagesRequest) returns (ListMessagesResponse) {
119    option (google.api.http) = {
120      get: "/v2/{parent=projects/*/conversations/*}/messages"
121      additional_bindings {
122        get: "/v2/{parent=projects/*/locations/*/conversations/*}/messages"
123      }
124    };
125    option (google.api.method_signature) = "parent";
126  }
127
128  // Suggests summary for a conversation based on specific historical messages.
129  // The range of the messages to be used for summary can be specified in the
130  // request.
131  rpc SuggestConversationSummary(SuggestConversationSummaryRequest)
132      returns (SuggestConversationSummaryResponse) {
133    option (google.api.http) = {
134      post: "/v2/{conversation=projects/*/conversations/*}/suggestions:suggestConversationSummary"
135      body: "*"
136      additional_bindings {
137        post: "/v2/{conversation=projects/*/locations/*/conversations/*}/suggestions:suggestConversationSummary"
138        body: "*"
139      }
140    };
141    option (google.api.method_signature) = "conversation";
142  }
143
144  // Generates and returns a summary for a conversation that does not have a
145  // resource created for it.
146  rpc GenerateStatelessSummary(GenerateStatelessSummaryRequest)
147      returns (GenerateStatelessSummaryResponse) {
148    option (google.api.http) = {
149      post: "/v2/{stateless_conversation.parent=projects/*}/suggestions:generateStatelessSummary"
150      body: "*"
151      additional_bindings {
152        post: "/v2/{stateless_conversation.parent=projects/*/locations/*}/suggestions:generateStatelessSummary"
153        body: "*"
154      }
155    };
156  }
157}
158
159// Represents a conversation.
160// A conversation is an interaction between an agent, including live agents
161// and Dialogflow agents, and a support customer. Conversations can
162// include phone calls and text-based chat sessions.
163message Conversation {
164  option (google.api.resource) = {
165    type: "dialogflow.googleapis.com/Conversation"
166    pattern: "projects/{project}/conversations/{conversation}"
167    pattern: "projects/{project}/locations/{location}/conversations/{conversation}"
168  };
169
170  // Enumeration of the completion status of the conversation.
171  enum LifecycleState {
172    // Unknown.
173    LIFECYCLE_STATE_UNSPECIFIED = 0;
174
175    // Conversation is currently open for media analysis.
176    IN_PROGRESS = 1;
177
178    // Conversation has been completed.
179    COMPLETED = 2;
180  }
181
182  // Enumeration of the different conversation stages a conversation can be in.
183  // Reference:
184  // https://cloud.google.com/dialogflow/priv/docs/contact-center/basics#stages
185  enum ConversationStage {
186    // Unknown. Should never be used after a conversation is successfully
187    // created.
188    CONVERSATION_STAGE_UNSPECIFIED = 0;
189
190    // The conversation should return virtual agent responses into the
191    // conversation.
192    VIRTUAL_AGENT_STAGE = 1;
193
194    // The conversation should not provide responses, just listen and provide
195    // suggestions.
196    HUMAN_ASSIST_STAGE = 2;
197  }
198
199  // Output only. The unique identifier of this conversation.
200  // Format: `projects/<Project ID>/locations/<Location
201  // ID>/conversations/<Conversation ID>`.
202  string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
203
204  // Output only. The current state of the Conversation.
205  LifecycleState lifecycle_state = 2
206      [(google.api.field_behavior) = OUTPUT_ONLY];
207
208  // Required. The Conversation Profile to be used to configure this
209  // Conversation. This field cannot be updated.
210  // Format: `projects/<Project ID>/locations/<Location
211  // ID>/conversationProfiles/<Conversation Profile ID>`.
212  string conversation_profile = 3 [
213    (google.api.field_behavior) = REQUIRED,
214    (google.api.resource_reference) = {
215      type: "dialogflow.googleapis.com/ConversationProfile"
216    }
217  ];
218
219  // Output only. It will not be empty if the conversation is to be connected
220  // over telephony.
221  ConversationPhoneNumber phone_number = 4
222      [(google.api.field_behavior) = OUTPUT_ONLY];
223
224  // Output only. The time the conversation was started.
225  google.protobuf.Timestamp start_time = 5
226      [(google.api.field_behavior) = OUTPUT_ONLY];
227
228  // Output only. The time the conversation was finished.
229  google.protobuf.Timestamp end_time = 6
230      [(google.api.field_behavior) = OUTPUT_ONLY];
231
232  // The stage of a conversation. It indicates whether the virtual agent or a
233  // human agent is handling the conversation.
234  //
235  // If the conversation is created with the conversation profile that has
236  // Dialogflow config set, defaults to
237  // [ConversationStage.VIRTUAL_AGENT_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.VIRTUAL_AGENT_STAGE];
238  // Otherwise, defaults to
239  // [ConversationStage.HUMAN_ASSIST_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.HUMAN_ASSIST_STAGE].
240  //
241  // If the conversation is created with the conversation profile that has
242  // Dialogflow config set but explicitly sets conversation_stage to
243  // [ConversationStage.HUMAN_ASSIST_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.HUMAN_ASSIST_STAGE],
244  // it skips
245  // [ConversationStage.VIRTUAL_AGENT_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.VIRTUAL_AGENT_STAGE]
246  // stage and directly goes to
247  // [ConversationStage.HUMAN_ASSIST_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.HUMAN_ASSIST_STAGE].
248  ConversationStage conversation_stage = 7;
249}
250
251// The request message for
252// [Conversations.CreateConversation][google.cloud.dialogflow.v2.Conversations.CreateConversation].
253message CreateConversationRequest {
254  // Required. Resource identifier of the project creating the conversation.
255  // Format: `projects/<Project ID>/locations/<Location ID>`.
256  string parent = 1 [
257    (google.api.field_behavior) = REQUIRED,
258    (google.api.resource_reference) = {
259      child_type: "dialogflow.googleapis.com/Conversation"
260    }
261  ];
262
263  // Required. The conversation to create.
264  Conversation conversation = 2 [(google.api.field_behavior) = REQUIRED];
265
266  // Optional. Identifier of the conversation. Generally it's auto generated by
267  // Google. Only set it if you cannot wait for the response to return a
268  // auto-generated one to you.
269  //
270  // The conversation ID must be compliant with the regression fomula
271  // "[a-zA-Z][a-zA-Z0-9_-]*" with the characters length in range of [3,64].
272  // If the field is provided, the caller is resposible for
273  // 1. the uniqueness of the ID, otherwise the request will be rejected.
274  // 2. the consistency for whether to use custom ID or not under a project to
275  // better ensure uniqueness.
276  string conversation_id = 3 [(google.api.field_behavior) = OPTIONAL];
277}
278
279// The request message for
280// [Conversations.ListConversations][google.cloud.dialogflow.v2.Conversations.ListConversations].
281message ListConversationsRequest {
282  // Required. The project from which to list all conversation.
283  // Format: `projects/<Project ID>/locations/<Location ID>`.
284  string parent = 1 [
285    (google.api.field_behavior) = REQUIRED,
286    (google.api.resource_reference) = {
287      child_type: "dialogflow.googleapis.com/Conversation"
288    }
289  ];
290
291  // Optional. The maximum number of items to return in a single page. By
292  // default 100 and at most 1000.
293  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
294
295  // Optional. The next_page_token value returned from a previous list request.
296  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
297
298  // A filter expression that filters conversations listed in the response. In
299  // general, the expression must specify the field name, a comparison operator,
300  // and the value to use for filtering:
301  // <ul>
302  //   <li>The value must be a string, a number, or a boolean.</li>
303  //   <li>The comparison operator must be either `=`,`!=`, `>`, or `<`.</li>
304  //   <li>To filter on multiple expressions, separate the
305  //       expressions with `AND` or `OR` (omitting both implies `AND`).</li>
306  //   <li>For clarity, expressions can be enclosed in parentheses.</li>
307  // </ul>
308  // Only `lifecycle_state` can be filtered on in this way. For example,
309  // the following expression only returns `COMPLETED` conversations:
310  //
311  // `lifecycle_state = "COMPLETED"`
312  //
313  // For more information about filtering, see
314  // [API Filtering](https://aip.dev/160).
315  string filter = 4;
316}
317
318// The response message for
319// [Conversations.ListConversations][google.cloud.dialogflow.v2.Conversations.ListConversations].
320message ListConversationsResponse {
321  // The list of conversations. There will be a maximum number of items
322  // returned based on the page_size field in the request.
323  repeated Conversation conversations = 1;
324
325  // Token to retrieve the next page of results, or empty if there are no
326  // more results in the list.
327  string next_page_token = 2;
328}
329
330// The request message for
331// [Conversations.GetConversation][google.cloud.dialogflow.v2.Conversations.GetConversation].
332message GetConversationRequest {
333  // Required. The name of the conversation. Format:
334  // `projects/<Project ID>/locations/<Location ID>/conversations/<Conversation
335  // ID>`.
336  string name = 1 [
337    (google.api.field_behavior) = REQUIRED,
338    (google.api.resource_reference) = {
339      type: "dialogflow.googleapis.com/Conversation"
340    }
341  ];
342}
343
344// The request message for
345// [Conversations.CompleteConversation][google.cloud.dialogflow.v2.Conversations.CompleteConversation].
346message CompleteConversationRequest {
347  // Required. Resource identifier of the conversation to close.
348  // Format: `projects/<Project ID>/locations/<Location
349  // ID>/conversations/<Conversation ID>`.
350  string name = 1 [
351    (google.api.field_behavior) = REQUIRED,
352    (google.api.resource_reference) = {
353      type: "dialogflow.googleapis.com/Conversation"
354    }
355  ];
356}
357
358// The request message for
359// [Conversations.ListMessages][google.cloud.dialogflow.v2.Conversations.ListMessages].
360message ListMessagesRequest {
361  // Required. The name of the conversation to list messages for.
362  // Format: `projects/<Project ID>/locations/<Location
363  // ID>/conversations/<Conversation ID>`
364  string parent = 1 [
365    (google.api.field_behavior) = REQUIRED,
366    (google.api.resource_reference) = {
367      child_type: "dialogflow.googleapis.com/Message"
368    }
369  ];
370
371  // Optional. Filter on message fields. Currently predicates on `create_time`
372  // and `create_time_epoch_microseconds` are supported. `create_time` only
373  // support milliseconds accuracy. E.g.,
374  // `create_time_epoch_microseconds > 1551790877964485` or
375  // `create_time > 2017-01-15T01:30:15.01Z`.
376  //
377  // For more information about filtering, see
378  // [API Filtering](https://aip.dev/160).
379  string filter = 4 [(google.api.field_behavior) = OPTIONAL];
380
381  // Optional. The maximum number of items to return in a single page. By
382  // default 100 and at most 1000.
383  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
384
385  // Optional. The next_page_token value returned from a previous list request.
386  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
387}
388
389// The response message for
390// [Conversations.ListMessages][google.cloud.dialogflow.v2.Conversations.ListMessages].
391message ListMessagesResponse {
392  // The list of messages. There will be a maximum number of items
393  // returned based on the page_size field in the request.
394  // `messages` is sorted by `create_time` in descending order.
395  repeated Message messages = 1;
396
397  // Token to retrieve the next page of results, or empty if there are
398  // no more results in the list.
399  string next_page_token = 2;
400}
401
402// Represents a phone number for telephony integration. It allows for connecting
403// a particular conversation over telephony.
404message ConversationPhoneNumber {
405  // Output only. The phone number to connect to this conversation.
406  string phone_number = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
407}
408
409// The request message for
410// [Conversations.SuggestConversationSummary][google.cloud.dialogflow.v2.Conversations.SuggestConversationSummary].
411message SuggestConversationSummaryRequest {
412  // Required. The conversation to fetch suggestion for.
413  // Format: `projects/<Project ID>/locations/<Location
414  // ID>/conversations/<Conversation ID>`.
415  string conversation = 1 [
416    (google.api.field_behavior) = REQUIRED,
417    (google.api.resource_reference) = {
418      type: "dialogflow.googleapis.com/Conversation"
419    }
420  ];
421
422  // The name of the latest conversation message used as context for
423  // compiling suggestion. If empty, the latest message of the conversation will
424  // be used.
425  //
426  // Format: `projects/<Project ID>/locations/<Location
427  // ID>/conversations/<Conversation ID>/messages/<Message ID>`.
428  string latest_message = 3 [(google.api.resource_reference) = {
429    type: "dialogflow.googleapis.com/Message"
430  }];
431
432  // Max number of messages prior to and including
433  // [latest_message] to use as context when compiling the
434  // suggestion. By default 500 and at most 1000.
435  int32 context_size = 4;
436
437  // Parameters for a human assist query.
438  AssistQueryParameters assist_query_params = 5;
439}
440
441// The response message for
442// [Conversations.SuggestConversationSummary][google.cloud.dialogflow.v2.Conversations.SuggestConversationSummary].
443message SuggestConversationSummaryResponse {
444  // Generated summary for a conversation.
445  message Summary {
446    // The summary content that is concatenated into one string.
447    string text = 1;
448
449    // The summary content that is divided into sections. The key is the
450    // section's name and the value is the section's content. There is no
451    // specific format for the key or value.
452    map<string, string> text_sections = 4;
453
454    // The name of the answer record. Format:
455    // "projects/<Project ID>/answerRecords/<Answer Record ID>"
456    string answer_record = 3 [(google.api.resource_reference) = {
457      type: "dialogflow.googleapis.com/AnswerRecord"
458    }];
459  }
460
461  // Generated summary.
462  Summary summary = 1;
463
464  // The name of the latest conversation message used as context for
465  // compiling suggestion.
466  //
467  // Format: `projects/<Project ID>/locations/<Location
468  // ID>/conversations/<Conversation ID>/messages/<Message ID>`.
469  string latest_message = 2 [(google.api.resource_reference) = {
470    type: "dialogflow.googleapis.com/Message"
471  }];
472
473  // Number of messages prior to and including
474  // [last_conversation_message][] used to compile the suggestion. It may be
475  // smaller than the [SuggestSummaryRequest.context_size][] field in the
476  // request if there weren't that many messages in the conversation.
477  int32 context_size = 3;
478}
479
480// The request message for
481// [Conversations.GenerateStatelessSummary][google.cloud.dialogflow.v2.Conversations.GenerateStatelessSummary].
482message GenerateStatelessSummaryRequest {
483  // The minimum amount of information required to generate a Summary without
484  // having a Conversation resource created.
485  message MinimalConversation {
486    // Required. The messages that the Summary will be generated from. It is
487    // expected that this message content is already redacted and does not
488    // contain any PII. Required fields: {content, language_code, participant,
489    // participant_role} Optional fields: {send_time} If send_time is not
490    // provided, then the messages must be provided in chronological order.
491    repeated Message messages = 1 [(google.api.field_behavior) = REQUIRED];
492
493    // Required. The parent resource to charge for the Summary's generation.
494    // Format: `projects/<Project ID>/locations/<Location ID>`.
495    string parent = 2 [
496      (google.api.field_behavior) = REQUIRED,
497      (google.api.resource_reference) = {
498        type: "locations.googleapis.com/Location"
499      }
500    ];
501  }
502
503  // Required. The conversation to suggest a summary for.
504  MinimalConversation stateless_conversation = 1
505      [(google.api.field_behavior) = REQUIRED];
506
507  // Required. A ConversationProfile containing information required for Summary
508  // generation.
509  // Required fields: {language_code, security_settings}
510  // Optional fields: {agent_assistant_config}
511  ConversationProfile conversation_profile = 2
512      [(google.api.field_behavior) = REQUIRED];
513
514  // The name of the latest conversation message used as context for
515  // generating a Summary. If empty, the latest message of the conversation will
516  // be used. The format is specific to the user and the names of the messages
517  // provided.
518  string latest_message = 3 [(google.api.resource_reference) = {
519    type: "dialogflow.googleapis.com/Message"
520  }];
521
522  // Max number of messages prior to and including
523  // [latest_message] to use as context when compiling the
524  // suggestion. By default 500 and at most 1000.
525  int32 max_context_size = 4;
526}
527
528// The response message for
529// [Conversations.GenerateStatelessSummary][google.cloud.dialogflow.v2.Conversations.GenerateStatelessSummary].
530message GenerateStatelessSummaryResponse {
531  // Generated summary for a conversation.
532  message Summary {
533    // The summary content that is concatenated into one string.
534    string text = 1;
535
536    // The summary content that is divided into sections. The key is the
537    // section's name and the value is the section's content. There is no
538    // specific format for the key or value.
539    map<string, string> text_sections = 2;
540  }
541
542  // Generated summary.
543  Summary summary = 1;
544
545  // The name of the latest conversation message used as context for
546  // compiling suggestion. The format is specific to the user and the names of
547  // the messages provided.
548  string latest_message = 2 [(google.api.resource_reference) = {
549    type: "dialogflow.googleapis.com/Message"
550  }];
551
552  // Number of messages prior to and including
553  // [last_conversation_message][] used to compile the suggestion. It may be
554  // smaller than the [GenerateStatelessSummaryRequest.context_size][] field in
555  // the request if there weren't that many messages in the conversation.
556  int32 context_size = 3;
557}
558