@@ -22,6 +22,7 @@ import "google/api/field_behavior.proto";
2222import "google/api/resource.proto" ;
2323import "google/cloud/dialogflow/v2/conversation_profile.proto" ;
2424import "google/cloud/dialogflow/v2/participant.proto" ;
25+ import "google/cloud/dialogflow/v2/session.proto" ;
2526import "google/protobuf/timestamp.proto" ;
2627
2728option cc_enable_arenas = true ;
@@ -154,6 +155,27 @@ service Conversations {
154155 }
155156 };
156157 }
158+
159+ // Get answers for the given query based on knowledge documents.
160+ rpc SearchKnowledge (SearchKnowledgeRequest )
161+ returns (SearchKnowledgeResponse ) {
162+ option (google.api.http ) = {
163+ post : "/v2/{parent=projects/*}/suggestions:searchKnowledge"
164+ body : "*"
165+ additional_bindings {
166+ post : "/v2/{parent=projects/*/locations/*}/suggestions:searchKnowledge"
167+ body : "*"
168+ }
169+ additional_bindings {
170+ post : "/v2/{conversation=projects/*/conversations/*}/suggestions:searchKnowledge"
171+ body : "*"
172+ }
173+ additional_bindings {
174+ post : "/v2/{conversation=projects/*/locations/*/conversations/*}/suggestions:searchKnowledge"
175+ body : "*"
176+ }
177+ };
178+ }
157179}
158180
159181// Represents a conversation.
@@ -563,3 +585,99 @@ message GenerateStatelessSummaryResponse {
563585 // the request if there weren't that many messages in the conversation.
564586 int32 context_size = 3 ;
565587}
588+
589+ // The request message for
590+ // [Conversations.SearchKnowledge][google.cloud.dialogflow.v2.Conversations.SearchKnowledge].
591+ message SearchKnowledgeRequest {
592+ // The parent resource contains the conversation profile
593+ // Format: 'projects/<Project ID>' or `projects/<Project
594+ // ID>/locations/<Location ID>`.
595+ string parent = 6 ;
596+
597+ // Required. The natural language text query for knowledge search.
598+ TextInput query = 1 [(google.api.field_behavior ) = REQUIRED ];
599+
600+ // Required. The conversation profile used to configure the search.
601+ // Format: `projects/<Project ID>/locations/<Location
602+ // ID>/conversationProfiles/<Conversation Profile ID>`.
603+ string conversation_profile = 2 [
604+ (google.api.field_behavior ) = REQUIRED ,
605+ (google.api.resource_reference ) = {
606+ type : "dialogflow.googleapis.com/ConversationProfile"
607+ }
608+ ];
609+
610+ // The ID of the search session.
611+ // The session_id can be combined with Dialogflow V3 Agent ID retrieved from
612+ // conversation profile or on its own to identify a search session. The search
613+ // history of the same session will impact the search result. It's up to the
614+ // API caller to choose an appropriate `Session ID`. It can be a random number
615+ // or some type of session identifiers (preferably hashed). The length must
616+ // not exceed 36 characters.
617+ string session_id = 3 ;
618+
619+ // The conversation (between human agent and end user) where the search
620+ // request is triggered. Format: `projects/<Project ID>/locations/<Location
621+ // ID>/conversations/<Conversation ID>`.
622+ string conversation = 4 [(google.api.resource_reference ) = {
623+ type : "dialogflow.googleapis.com/Conversation"
624+ }];
625+
626+ // The name of the latest conversation message when the request is
627+ // triggered.
628+ // Format: `projects/<Project ID>/locations/<Location
629+ // ID>/conversations/<Conversation ID>/messages/<Message ID>`.
630+ string latest_message = 5 [(google.api.resource_reference ) = {
631+ type : "dialogflow.googleapis.com/Message"
632+ }];
633+ }
634+
635+ // The response message for
636+ // [Conversations.SearchKnowledge][google.cloud.dialogflow.v2.Conversations.SearchKnowledge].
637+ message SearchKnowledgeResponse {
638+ // Most relevant snippets extracted from articles in the given knowledge base,
639+ // ordered by confidence.
640+ repeated SearchKnowledgeAnswer answers = 2 ;
641+ }
642+
643+ // Represents a SearchKnowledge answer.
644+ message SearchKnowledgeAnswer {
645+ // The type of the answer.
646+ enum AnswerType {
647+ // The answer has a unspecified type.
648+ ANSWER_TYPE_UNSPECIFIED = 0 ;
649+
650+ // The answer is from FAQ doucments.
651+ FAQ = 1 ;
652+
653+ // The answer is from generative model.
654+ GENERATIVE = 2 ;
655+ }
656+
657+ // The sources of the answers.
658+ message AnswerSource {
659+ // The title of the article.
660+ string title = 1 ;
661+
662+ // The URI of the article.
663+ string uri = 2 ;
664+
665+ // The relevant snippet of the article.
666+ string snippet = 3 ;
667+ }
668+
669+ // The piece of text from the knowledge base documents that answers
670+ // the search query
671+ string answer = 1 ;
672+
673+ // The type of the answer.
674+ AnswerType answer_type = 2 ;
675+
676+ // All sources used to generate the answer.
677+ repeated AnswerSource answer_sources = 3 ;
678+
679+ // The name of the answer record.
680+ // Format: `projects/<Project ID>/locations/<location ID>/answer
681+ // Records/<Answer Record ID>`
682+ string answer_record = 5 ;
683+ }
0 commit comments