Class ConversationsClient (4.49.0)

GitHub RepositoryProduct Reference

Service Description: Service for managing Conversations.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   Conversation conversation = Conversation.newBuilder().build();
   Conversation response = conversationsClient.createConversation(parent, conversation);
 }
 

Note: close() needs to be called on the ConversationsClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
Method Description Method Variants

CreateConversation

Creates a new conversation. Conversations are auto-completed after 24 hours.

Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage and Assist Stage.

For Automated Agent Stage, there will be a dialogflow agent responding to user queries.

For Assist Stage, there's no dialogflow agent responding to user queries. But we will provide suggestions which are generated from conversation.

If Conversation.conversation_profile is configured for a dialogflow agent, conversation will start from Automated Agent Stage, otherwise, it will start from Assist Stage. And during Automated Agent Stage, once an Intent with Intent.live_agent_handoff is triggered, conversation will transfer to Assist Stage.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createConversation(CreateConversationRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createConversation(LocationName parent, Conversation conversation)

  • createConversation(ProjectName parent, Conversation conversation)

  • createConversation(String parent, Conversation conversation)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createConversationCallable()

ListConversations

Returns the list of all conversations in the specified project.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listConversations(ListConversationsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listConversations(LocationName parent)

  • listConversations(ProjectName parent)

  • listConversations(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listConversationsPagedCallable()

  • listConversationsCallable()

GetConversation

Retrieves the specific conversation.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getConversation(GetConversationRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getConversation(ConversationName name)

  • getConversation(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getConversationCallable()

CompleteConversation

Completes the specified conversation. Finished conversations are purged from the database after 30 days.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • completeConversation(CompleteConversationRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • completeConversation(ConversationName name)

  • completeConversation(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • completeConversationCallable()

BatchCreateMessages

Batch ingests messages to conversation. Customers can use this RPC to ingest historical messages to conversation.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • batchCreateMessages(BatchCreateMessagesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • batchCreateMessages(ConversationName parent)

  • batchCreateMessages(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • batchCreateMessagesCallable()

ListMessages

Lists messages that belong to a given conversation. messages are ordered by create_time in descending order. To fetch updates without duplication, send request with filter create_time_epoch_microseconds > [first item's create_time of previous request] and empty page_token.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listMessages(ListMessagesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listMessages(ConversationName parent)

  • listMessages(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listMessagesPagedCallable()

  • listMessagesCallable()

SuggestConversationSummary

Suggest summary for a conversation based on specific historical messages. The range of the messages to be used for summary can be specified in the request.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • suggestConversationSummary(SuggestConversationSummaryRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • suggestConversationSummary(ConversationName conversation)

  • suggestConversationSummary(String conversation)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • suggestConversationSummaryCallable()

GenerateStatelessSummary

Generates and returns a summary for a conversation that does not have a resource created for it.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • generateStatelessSummary(GenerateStatelessSummaryRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • generateStatelessSummaryCallable()

SearchKnowledge

Get answers for the given query based on knowledge documents.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • searchKnowledge(SearchKnowledgeRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • searchKnowledgeCallable()

ListLocations

Lists information about the supported locations for this service.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listLocations(ListLocationsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listLocationsPagedCallable()

  • listLocationsCallable()

GetLocation

Gets information about a location.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getLocation(GetLocationRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getLocationCallable()

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of ConversationsSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ConversationsSettings conversationsSettings =
     ConversationsSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ConversationsSettings conversationsSettings =
     ConversationsSettings.newBuilder().setEndpoint(myEndpoint).build();
 ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings);
 

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ConversationsSettings conversationsSettings =
     ConversationsSettings.newHttpJsonBuilder().build();
 ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > ConversationsClient

Static Methods

create()

public static final ConversationsClient create()

Constructs an instance of ConversationsClient with default settings.

Returns
Type Description
ConversationsClient
Exceptions
Type Description
IOException

create(ConversationsSettings settings)

public static final ConversationsClient create(ConversationsSettings settings)

Constructs an instance of ConversationsClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings ConversationsSettings
Returns
Type Description
ConversationsClient
Exceptions
Type Description
IOException

create(ConversationsStub stub)

public static final ConversationsClient create(ConversationsStub stub)

Constructs an instance of ConversationsClient, using the given stub for making calls. This is for advanced usage - prefer using create(ConversationsSettings).

Parameter
Name Description
stub ConversationsStub
Returns
Type Description
ConversationsClient

Constructors

ConversationsClient(ConversationsSettings settings)

protected ConversationsClient(ConversationsSettings settings)

Constructs an instance of ConversationsClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
Name Description
settings ConversationsSettings

ConversationsClient(ConversationsStub stub)

protected ConversationsClient(ConversationsStub stub)
Parameter
Name Description
stub ConversationsStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

batchCreateMessages(BatchCreateMessagesRequest request)

public final BatchCreateMessagesResponse batchCreateMessages(BatchCreateMessagesRequest request)

Batch ingests messages to conversation. Customers can use this RPC to ingest historical messages to conversation.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   BatchCreateMessagesRequest request =
       BatchCreateMessagesRequest.newBuilder()
           .setParent(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .addAllRequests(new ArrayList<CreateMessageRequest>())
           .build();
   BatchCreateMessagesResponse response = conversationsClient.batchCreateMessages(request);
 }
 
Parameter
Name Description
request BatchCreateMessagesRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
BatchCreateMessagesResponse

batchCreateMessages(ConversationName parent)

public final BatchCreateMessagesResponse batchCreateMessages(ConversationName parent)

Batch ingests messages to conversation. Customers can use this RPC to ingest historical messages to conversation.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ConversationName parent =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
   BatchCreateMessagesResponse response = conversationsClient.batchCreateMessages(parent);
 }
 
Parameter
Name Description
parent ConversationName

Required. Resource identifier of the conversation to create message. Format: projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>.

Returns
Type Description
BatchCreateMessagesResponse

batchCreateMessages(String parent)

public final BatchCreateMessagesResponse batchCreateMessages(String parent)

Batch ingests messages to conversation. Customers can use this RPC to ingest historical messages to conversation.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   String parent =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
   BatchCreateMessagesResponse response = conversationsClient.batchCreateMessages(parent);
 }
 
Parameter
Name Description
parent String

Required. Resource identifier of the conversation to create message. Format: projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>.

Returns
Type Description
BatchCreateMessagesResponse

batchCreateMessagesCallable()

public final UnaryCallable<BatchCreateMessagesRequest,BatchCreateMessagesResponse> batchCreateMessagesCallable()

Batch ingests messages to conversation. Customers can use this RPC to ingest historical messages to conversation.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   BatchCreateMessagesRequest request =
       BatchCreateMessagesRequest.newBuilder()
           .setParent(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .addAllRequests(new ArrayList<CreateMessageRequest>())
           .build();
   ApiFuture<BatchCreateMessagesResponse> future =
       conversationsClient.batchCreateMessagesCallable().futureCall(request);
   // Do something.
   BatchCreateMessagesResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<BatchCreateMessagesRequest,BatchCreateMessagesResponse>

close()

public final void close()

completeConversation(CompleteConversationRequest request)

public final Conversation completeConversation(CompleteConversationRequest request)

Completes the specified conversation. Finished conversations are purged from the database after 30 days.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   CompleteConversationRequest request =
       CompleteConversationRequest.newBuilder()
           .setName(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .build();
   Conversation response = conversationsClient.completeConversation(request);
 }
 
Parameter
Name Description
request CompleteConversationRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Conversation

completeConversation(ConversationName name)

public final Conversation completeConversation(ConversationName name)

Completes the specified conversation. Finished conversations are purged from the database after 30 days.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ConversationName name =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
   Conversation response = conversationsClient.completeConversation(name);
 }
 
Parameter
Name Description
name ConversationName

Required. Resource identifier of the conversation to close. Format: projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>.

Returns
Type Description
Conversation

completeConversation(String name)

public final Conversation completeConversation(String name)

Completes the specified conversation. Finished conversations are purged from the database after 30 days.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   String name =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
   Conversation response = conversationsClient.completeConversation(name);
 }
 
Parameter
Name Description
name String

Required. Resource identifier of the conversation to close. Format: projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>.

Returns
Type Description
Conversation

completeConversationCallable()

public final UnaryCallable<CompleteConversationRequest,Conversation> completeConversationCallable()

Completes the specified conversation. Finished conversations are purged from the database after 30 days.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   CompleteConversationRequest request =
       CompleteConversationRequest.newBuilder()
           .setName(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .build();
   ApiFuture<Conversation> future =
       conversationsClient.completeConversationCallable().futureCall(request);
   // Do something.
   Conversation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CompleteConversationRequest,Conversation>

createConversation(CreateConversationRequest request)

public final Conversation createConversation(CreateConversationRequest request)

Creates a new conversation. Conversations are auto-completed after 24 hours.

Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage and Assist Stage.

For Automated Agent Stage, there will be a dialogflow agent responding to user queries.

For Assist Stage, there's no dialogflow agent responding to user queries. But we will provide suggestions which are generated from conversation.

If Conversation.conversation_profile is configured for a dialogflow agent, conversation will start from Automated Agent Stage, otherwise, it will start from Assist Stage. And during Automated Agent Stage, once an Intent with Intent.live_agent_handoff is triggered, conversation will transfer to Assist Stage.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   CreateConversationRequest request =
       CreateConversationRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setConversation(Conversation.newBuilder().build())
           .setConversationId("conversationId-1676095234")
           .build();
   Conversation response = conversationsClient.createConversation(request);
 }
 
Parameter
Name Description
request CreateConversationRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Conversation

createConversation(LocationName parent, Conversation conversation)

public final Conversation createConversation(LocationName parent, Conversation conversation)

Creates a new conversation. Conversations are auto-completed after 24 hours.

Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage and Assist Stage.

For Automated Agent Stage, there will be a dialogflow agent responding to user queries.

For Assist Stage, there's no dialogflow agent responding to user queries. But we will provide suggestions which are generated from conversation.

If Conversation.conversation_profile is configured for a dialogflow agent, conversation will start from Automated Agent Stage, otherwise, it will start from Assist Stage. And during Automated Agent Stage, once an Intent with Intent.live_agent_handoff is triggered, conversation will transfer to Assist Stage.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   Conversation conversation = Conversation.newBuilder().build();
   Conversation response = conversationsClient.createConversation(parent, conversation);
 }
 
Parameters
Name Description
parent LocationName

Required. Resource identifier of the project creating the conversation. Format: projects/<Project ID>/locations/<Location ID>.

conversation Conversation

Required. The conversation to create.

Returns
Type Description
Conversation

createConversation(ProjectName parent, Conversation conversation)

public final Conversation createConversation(ProjectName parent, Conversation conversation)

Creates a new conversation. Conversations are auto-completed after 24 hours.

Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage and Assist Stage.

For Automated Agent Stage, there will be a dialogflow agent responding to user queries.

For Assist Stage, there's no dialogflow agent responding to user queries. But we will provide suggestions which are generated from conversation.

If Conversation.conversation_profile is configured for a dialogflow agent, conversation will start from Automated Agent Stage, otherwise, it will start from Assist Stage. And during Automated Agent Stage, once an Intent with Intent.live_agent_handoff is triggered, conversation will transfer to Assist Stage.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   Conversation conversation = Conversation.newBuilder().build();
   Conversation response = conversationsClient.createConversation(parent, conversation);
 }
 
Parameters
Name Description
parent ProjectName

Required. Resource identifier of the project creating the conversation. Format: projects/<Project ID>/locations/<Location ID>.

conversation Conversation

Required. The conversation to create.

Returns
Type Description
Conversation

createConversation(String parent, Conversation conversation)

public final Conversation createConversation(String parent, Conversation conversation)

Creates a new conversation. Conversations are auto-completed after 24 hours.

Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage and Assist Stage.

For Automated Agent Stage, there will be a dialogflow agent responding to user queries.

For Assist Stage, there's no dialogflow agent responding to user queries. But we will provide suggestions which are generated from conversation.

If Conversation.conversation_profile is configured for a dialogflow agent, conversation will start from Automated Agent Stage, otherwise, it will start from Assist Stage. And during Automated Agent Stage, once an Intent with Intent.live_agent_handoff is triggered, conversation will transfer to Assist Stage.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   Conversation conversation = Conversation.newBuilder().build();
   Conversation response = conversationsClient.createConversation(parent, conversation);
 }
 
Parameters
Name Description
parent String

Required. Resource identifier of the project creating the conversation. Format: projects/<Project ID>/locations/<Location ID>.

conversation Conversation

Required. The conversation to create.

Returns
Type Description
Conversation

createConversationCallable()

public final UnaryCallable<CreateConversationRequest,Conversation> createConversationCallable()

Creates a new conversation. Conversations are auto-completed after 24 hours.

Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage and Assist Stage.

For Automated Agent Stage, there will be a dialogflow agent responding to user queries.

For Assist Stage, there's no dialogflow agent responding to user queries. But we will provide suggestions which are generated from conversation.

If Conversation.conversation_profile is configured for a dialogflow agent, conversation will start from Automated Agent Stage, otherwise, it will start from Assist Stage. And during Automated Agent Stage, once an Intent with Intent.live_agent_handoff is triggered, conversation will transfer to Assist Stage.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   CreateConversationRequest request =
       CreateConversationRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setConversation(Conversation.newBuilder().build())
           .setConversationId("conversationId-1676095234")
           .build();
   ApiFuture<Conversation> future =
       conversationsClient.createConversationCallable().futureCall(request);
   // Do something.
   Conversation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateConversationRequest,Conversation>

generateStatelessSummary(GenerateStatelessSummaryRequest request)

public final GenerateStatelessSummaryResponse generateStatelessSummary(GenerateStatelessSummaryRequest request)

Generates and returns a summary for a conversation that does not have a resource created for it.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   GenerateStatelessSummaryRequest request =
       GenerateStatelessSummaryRequest.newBuilder()
           .setStatelessConversation(
               GenerateStatelessSummaryRequest.MinimalConversation.newBuilder().build())
           .setConversationProfile(ConversationProfile.newBuilder().build())
           .setLatestMessage(
               MessageName.ofProjectConversationMessageName(
                       "[PROJECT]", "[CONVERSATION]", "[MESSAGE]")
                   .toString())
           .setMaxContextSize(-1134084212)
           .build();
   GenerateStatelessSummaryResponse response =
       conversationsClient.generateStatelessSummary(request);
 }
 
Parameter
Name Description
request GenerateStatelessSummaryRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
GenerateStatelessSummaryResponse

generateStatelessSummaryCallable()

public final UnaryCallable<GenerateStatelessSummaryRequest,GenerateStatelessSummaryResponse> generateStatelessSummaryCallable()

Generates and returns a summary for a conversation that does not have a resource created for it.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   GenerateStatelessSummaryRequest request =
       GenerateStatelessSummaryRequest.newBuilder()
           .setStatelessConversation(
               GenerateStatelessSummaryRequest.MinimalConversation.newBuilder().build())
           .setConversationProfile(ConversationProfile.newBuilder().build())
           .setLatestMessage(
               MessageName.ofProjectConversationMessageName(
                       "[PROJECT]", "[CONVERSATION]", "[MESSAGE]")
                   .toString())
           .setMaxContextSize(-1134084212)
           .build();
   ApiFuture<GenerateStatelessSummaryResponse> future =
       conversationsClient.generateStatelessSummaryCallable().futureCall(request);
   // Do something.
   GenerateStatelessSummaryResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GenerateStatelessSummaryRequest,GenerateStatelessSummaryResponse>

getConversation(ConversationName name)

public final Conversation getConversation(ConversationName name)

Retrieves the specific conversation.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ConversationName name =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
   Conversation response = conversationsClient.getConversation(name);
 }
 
Parameter
Name Description
name ConversationName

Required. The name of the conversation. Format: projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>.

Returns
Type Description
Conversation

getConversation(GetConversationRequest request)

public final Conversation getConversation(GetConversationRequest request)

Retrieves the specific conversation.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   GetConversationRequest request =
       GetConversationRequest.newBuilder()
           .setName(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .build();
   Conversation response = conversationsClient.getConversation(request);
 }
 
Parameter
Name Description
request GetConversationRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Conversation

getConversation(String name)

public final Conversation getConversation(String name)

Retrieves the specific conversation.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   String name =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
   Conversation response = conversationsClient.getConversation(name);
 }
 
Parameter
Name Description
name String

Required. The name of the conversation. Format: projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>.

Returns
Type Description
Conversation

getConversationCallable()

public final UnaryCallable<GetConversationRequest,Conversation> getConversationCallable()

Retrieves the specific conversation.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   GetConversationRequest request =
       GetConversationRequest.newBuilder()
           .setName(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .build();
   ApiFuture<Conversation> future =
       conversationsClient.getConversationCallable().futureCall(request);
   // Do something.
   Conversation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetConversationRequest,Conversation>

getLocation(GetLocationRequest request)

public final Location getLocation(GetLocationRequest request)

Gets information about a location.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
   Location response = conversationsClient.getLocation(request);
 }
 
Parameter
Name Description
request com.google.cloud.location.GetLocationRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
com.google.cloud.location.Location

getLocationCallable()

public final UnaryCallable<GetLocationRequest,Location> getLocationCallable()

Gets information about a location.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
   ApiFuture<Location> future = conversationsClient.getLocationCallable().futureCall(request);
   // Do something.
   Location response = future.get();
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location>

getSettings()

public final ConversationsSettings getSettings()
Returns
Type Description
ConversationsSettings

getStub()

public ConversationsStub getStub()
Returns
Type Description
ConversationsStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listConversations(ListConversationsRequest request)

public final ConversationsClient.ListConversationsPagedResponse listConversations(ListConversationsRequest request)

Returns the list of all conversations in the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ListConversationsRequest request =
       ListConversationsRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   for (Conversation element : conversationsClient.listConversations(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListConversationsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ConversationsClient.ListConversationsPagedResponse

listConversations(LocationName parent)

public final ConversationsClient.ListConversationsPagedResponse listConversations(LocationName parent)

Returns the list of all conversations in the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent LocationName

Required. The project from which to list all conversation. Format: projects/<Project ID>/locations/<Location ID>.

Returns
Type Description
ConversationsClient.ListConversationsPagedResponse

listConversations(ProjectName parent)

public final ConversationsClient.ListConversationsPagedResponse listConversations(ProjectName parent)

Returns the list of all conversations in the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent ProjectName

Required. The project from which to list all conversation. Format: projects/<Project ID>/locations/<Location ID>.

Returns
Type Description
ConversationsClient.ListConversationsPagedResponse

listConversations(String parent)

public final ConversationsClient.ListConversationsPagedResponse listConversations(String parent)

Returns the list of all conversations in the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The project from which to list all conversation. Format: projects/<Project ID>/locations/<Location ID>.

Returns
Type Description
ConversationsClient.ListConversationsPagedResponse

listConversationsCallable()

public final UnaryCallable<ListConversationsRequest,ListConversationsResponse> listConversationsCallable()

Returns the list of all conversations in the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ListConversationsRequest request =
       ListConversationsRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   while (true) {
     ListConversationsResponse response =
         conversationsClient.listConversationsCallable().call(request);
     for (Conversation element : response.getConversationsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListConversationsRequest,ListConversationsResponse>

listConversationsPagedCallable()

public final UnaryCallable<ListConversationsRequest,ConversationsClient.ListConversationsPagedResponse> listConversationsPagedCallable()

Returns the list of all conversations in the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ListConversationsRequest request =
       ListConversationsRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<Conversation> future =
       conversationsClient.listConversationsPagedCallable().futureCall(request);
   // Do something.
   for (Conversation element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListConversationsRequest,ListConversationsPagedResponse>

listLocations(ListLocationsRequest request)

public final ConversationsClient.ListLocationsPagedResponse listLocations(ListLocationsRequest request)

Lists information about the supported locations for this service.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Location element : conversationsClient.listLocations(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request com.google.cloud.location.ListLocationsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ConversationsClient.ListLocationsPagedResponse

listLocationsCallable()

public final UnaryCallable<ListLocationsRequest,ListLocationsResponse> listLocationsCallable()

Lists information about the supported locations for this service.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListLocationsResponse response = conversationsClient.listLocationsCallable().call(request);
     for (Location element : response.getLocationsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse>

listLocationsPagedCallable()

public final UnaryCallable<ListLocationsRequest,ConversationsClient.ListLocationsPagedResponse> listLocationsPagedCallable()

Lists information about the supported locations for this service.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Location> future =
       conversationsClient.listLocationsPagedCallable().futureCall(request);
   // Do something.
   for (Location element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.ListLocationsRequest,ListLocationsPagedResponse>

listMessages(ConversationName parent)

public final ConversationsClient.ListMessagesPagedResponse listMessages(ConversationName parent)

Lists messages that belong to a given conversation. messages are ordered by create_time in descending order. To fetch updates without duplication, send request with filter create_time_epoch_microseconds > [first item's create_time of previous request] and empty page_token.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ConversationName parent =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
   for (Message element : conversationsClient.listMessages(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent ConversationName

Required. The name of the conversation to list messages for. Format: projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>

Returns
Type Description
ConversationsClient.ListMessagesPagedResponse

listMessages(ListMessagesRequest request)

public final ConversationsClient.ListMessagesPagedResponse listMessages(ListMessagesRequest request)

Lists messages that belong to a given conversation. messages are ordered by create_time in descending order. To fetch updates without duplication, send request with filter create_time_epoch_microseconds > [first item's create_time of previous request] and empty page_token.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ListMessagesRequest request =
       ListMessagesRequest.newBuilder()
           .setParent(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Message element : conversationsClient.listMessages(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListMessagesRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ConversationsClient.ListMessagesPagedResponse

listMessages(String parent)

public final ConversationsClient.ListMessagesPagedResponse listMessages(String parent)

Lists messages that belong to a given conversation. messages are ordered by create_time in descending order. To fetch updates without duplication, send request with filter create_time_epoch_microseconds > [first item's create_time of previous request] and empty page_token.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   String parent =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
   for (Message element : conversationsClient.listMessages(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The name of the conversation to list messages for. Format: projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>

Returns
Type Description
ConversationsClient.ListMessagesPagedResponse

listMessagesCallable()

public final UnaryCallable<ListMessagesRequest,ListMessagesResponse> listMessagesCallable()

Lists messages that belong to a given conversation. messages are ordered by create_time in descending order. To fetch updates without duplication, send request with filter create_time_epoch_microseconds > [first item's create_time of previous request] and empty page_token.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ListMessagesRequest request =
       ListMessagesRequest.newBuilder()
           .setParent(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListMessagesResponse response = conversationsClient.listMessagesCallable().call(request);
     for (Message element : response.getMessagesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListMessagesRequest,ListMessagesResponse>

listMessagesPagedCallable()

public final UnaryCallable<ListMessagesRequest,ConversationsClient.ListMessagesPagedResponse> listMessagesPagedCallable()

Lists messages that belong to a given conversation. messages are ordered by create_time in descending order. To fetch updates without duplication, send request with filter create_time_epoch_microseconds > [first item's create_time of previous request] and empty page_token.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ListMessagesRequest request =
       ListMessagesRequest.newBuilder()
           .setParent(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Message> future =
       conversationsClient.listMessagesPagedCallable().futureCall(request);
   // Do something.
   for (Message element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListMessagesRequest,ListMessagesPagedResponse>

searchKnowledge(SearchKnowledgeRequest request)

public final SearchKnowledgeResponse searchKnowledge(SearchKnowledgeRequest request)

Get answers for the given query based on knowledge documents.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   SearchKnowledgeRequest request =
       SearchKnowledgeRequest.newBuilder()
           .setParent("parent-995424086")
           .setQuery(TextInput.newBuilder().build())
           .setConversationProfile(
               ConversationProfileName.ofProjectConversationProfileName(
                       "[PROJECT]", "[CONVERSATION_PROFILE]")
                   .toString())
           .setSessionId("sessionId607796817")
           .setConversation(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .setLatestMessage(
               MessageName.ofProjectConversationMessageName(
                       "[PROJECT]", "[CONVERSATION]", "[MESSAGE]")
                   .toString())
           .build();
   SearchKnowledgeResponse response = conversationsClient.searchKnowledge(request);
 }
 
Parameter
Name Description
request SearchKnowledgeRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
SearchKnowledgeResponse

searchKnowledgeCallable()

public final UnaryCallable<SearchKnowledgeRequest,SearchKnowledgeResponse> searchKnowledgeCallable()

Get answers for the given query based on knowledge documents.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   SearchKnowledgeRequest request =
       SearchKnowledgeRequest.newBuilder()
           .setParent("parent-995424086")
           .setQuery(TextInput.newBuilder().build())
           .setConversationProfile(
               ConversationProfileName.ofProjectConversationProfileName(
                       "[PROJECT]", "[CONVERSATION_PROFILE]")
                   .toString())
           .setSessionId("sessionId607796817")
           .setConversation(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .setLatestMessage(
               MessageName.ofProjectConversationMessageName(
                       "[PROJECT]", "[CONVERSATION]", "[MESSAGE]")
                   .toString())
           .build();
   ApiFuture<SearchKnowledgeResponse> future =
       conversationsClient.searchKnowledgeCallable().futureCall(request);
   // Do something.
   SearchKnowledgeResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<SearchKnowledgeRequest,SearchKnowledgeResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

suggestConversationSummary(ConversationName conversation)

public final SuggestConversationSummaryResponse suggestConversationSummary(ConversationName conversation)

Suggest summary for a conversation based on specific historical messages. The range of the messages to be used for summary can be specified in the request.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ConversationName conversation =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
   SuggestConversationSummaryResponse response =
       conversationsClient.suggestConversationSummary(conversation);
 }
 
Parameter
Name Description
conversation ConversationName

Required. The conversation to fetch suggestion for. Format: projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>.

Returns
Type Description
SuggestConversationSummaryResponse

suggestConversationSummary(SuggestConversationSummaryRequest request)

public final SuggestConversationSummaryResponse suggestConversationSummary(SuggestConversationSummaryRequest request)

Suggest summary for a conversation based on specific historical messages. The range of the messages to be used for summary can be specified in the request.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   SuggestConversationSummaryRequest request =
       SuggestConversationSummaryRequest.newBuilder()
           .setConversation(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .setLatestMessage(
               MessageName.ofProjectConversationMessageName(
                       "[PROJECT]", "[CONVERSATION]", "[MESSAGE]")
                   .toString())
           .setContextSize(1116903569)
           .setAssistQueryParams(AssistQueryParameters.newBuilder().build())
           .build();
   SuggestConversationSummaryResponse response =
       conversationsClient.suggestConversationSummary(request);
 }
 
Parameter
Name Description
request SuggestConversationSummaryRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
SuggestConversationSummaryResponse

suggestConversationSummary(String conversation)

public final SuggestConversationSummaryResponse suggestConversationSummary(String conversation)

Suggest summary for a conversation based on specific historical messages. The range of the messages to be used for summary can be specified in the request.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   String conversation =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
   SuggestConversationSummaryResponse response =
       conversationsClient.suggestConversationSummary(conversation);
 }
 
Parameter
Name Description
conversation String

Required. The conversation to fetch suggestion for. Format: projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>.

Returns
Type Description
SuggestConversationSummaryResponse

suggestConversationSummaryCallable()

public final UnaryCallable<SuggestConversationSummaryRequest,SuggestConversationSummaryResponse> suggestConversationSummaryCallable()

Suggest summary for a conversation based on specific historical messages. The range of the messages to be used for summary can be specified in the request.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   SuggestConversationSummaryRequest request =
       SuggestConversationSummaryRequest.newBuilder()
           .setConversation(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .setLatestMessage(
               MessageName.ofProjectConversationMessageName(
                       "[PROJECT]", "[CONVERSATION]", "[MESSAGE]")
                   .toString())
           .setContextSize(1116903569)
           .setAssistQueryParams(AssistQueryParameters.newBuilder().build())
           .build();
   ApiFuture<SuggestConversationSummaryResponse> future =
       conversationsClient.suggestConversationSummaryCallable().futureCall(request);
   // Do something.
   SuggestConversationSummaryResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<SuggestConversationSummaryRequest,SuggestConversationSummaryResponse>