Class ConversationsClient (4.6.0)

public class ConversationsClient implements BackgroundResource

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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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().

The surface of this class includes several types of Java methods for each of the API's methods:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 ConversationsSettings conversationsSettings =
     ConversationsSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 ConversationsSettings conversationsSettings =
     ConversationsSettings.newBuilder().setEndpoint(myEndpoint).build();
 ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings);
 

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

Inheritance

java.lang.Object > ConversationsClient

Implements

BackgroundResource

Static Methods

create()

public static final ConversationsClient create()

Constructs an instance of ConversationsClient with default settings.

Returns
TypeDescription
ConversationsClient
Exceptions
TypeDescription
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
NameDescription
settingsConversationsSettings
Returns
TypeDescription
ConversationsClient
Exceptions
TypeDescription
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
NameDescription
stubConversationsStub
Returns
TypeDescription
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
NameDescription
settingsConversationsSettings

ConversationsClient(ConversationsStub stub)

protected ConversationsClient(ConversationsStub stub)
Parameter
NameDescription
stubConversationsStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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
NameDescription
requestBatchCreateMessagesRequest

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ConversationName parent =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
   BatchCreateMessagesResponse response = conversationsClient.batchCreateMessages(parent);
 }
 
Parameter
NameDescription
parentConversationName

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   String parent =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
   BatchCreateMessagesResponse response = conversationsClient.batchCreateMessages(parent);
 }
 
Parameter
NameDescription
parentString

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   CompleteConversationRequest request =
       CompleteConversationRequest.newBuilder()
           .setName(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .build();
   Conversation response = conversationsClient.completeConversation(request);
 }
 
Parameter
NameDescription
requestCompleteConversationRequest

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ConversationName name =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
   Conversation response = conversationsClient.completeConversation(name);
 }
 
Parameter
NameDescription
nameConversationName

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   String name =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
   Conversation response = conversationsClient.completeConversation(name);
 }
 
Parameter
NameDescription
nameString

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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
NameDescription
requestCreateConversationRequest

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   Conversation conversation = Conversation.newBuilder().build();
   Conversation response = conversationsClient.createConversation(parent, conversation);
 }
 
Parameters
NameDescription
parentLocationName

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

conversationConversation

Required. The conversation to create.

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   Conversation conversation = Conversation.newBuilder().build();
   Conversation response = conversationsClient.createConversation(parent, conversation);
 }
 
Parameters
NameDescription
parentProjectName

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

conversationConversation

Required. The conversation to create.

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   Conversation conversation = Conversation.newBuilder().build();
   Conversation response = conversationsClient.createConversation(parent, conversation);
 }
 
Parameters
NameDescription
parentString

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

conversationConversation

Required. The conversation to create.

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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
TypeDescription
UnaryCallable<CreateConversationRequest,Conversation>

getConversation(ConversationName name)

public final Conversation getConversation(ConversationName name)

Retrieves the specific conversation.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ConversationName name =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
   Conversation response = conversationsClient.getConversation(name);
 }
 
Parameter
NameDescription
nameConversationName

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

Returns
TypeDescription
Conversation

getConversation(GetConversationRequest request)

public final Conversation getConversation(GetConversationRequest request)

Retrieves the specific conversation.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   GetConversationRequest request =
       GetConversationRequest.newBuilder()
           .setName(
               ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
                   .toString())
           .build();
   Conversation response = conversationsClient.getConversation(request);
 }
 
Parameter
NameDescription
requestGetConversationRequest

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

Returns
TypeDescription
Conversation

getConversation(String name)

public final Conversation getConversation(String name)

Retrieves the specific conversation.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   String name =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
   Conversation response = conversationsClient.getConversation(name);
 }
 
Parameter
NameDescription
nameString

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

Returns
TypeDescription
Conversation

getConversationCallable()

public final UnaryCallable<GetConversationRequest,Conversation> getConversationCallable()

Retrieves the specific conversation.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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
TypeDescription
UnaryCallable<GetConversationRequest,Conversation>

getSettings()

public final ConversationsSettings getSettings()
Returns
TypeDescription
ConversationsSettings

getStub()

public ConversationsStub getStub()
Returns
TypeDescription
ConversationsStub

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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
NameDescription
requestListConversationsRequest

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentLocationName

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentProjectName

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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.getResponsesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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
TypeDescription
UnaryCallable<ListConversationsRequest,ListConversationsPagedResponse>

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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   ConversationName parent =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
   for (Message element : conversationsClient.listMessages(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentConversationName

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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
NameDescription
requestListMessagesRequest

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ConversationsClient conversationsClient = ConversationsClient.create()) {
   String parent =
       ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
   for (Message element : conversationsClient.listMessages(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

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

Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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.getResponsesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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
TypeDescription
UnaryCallable<ListMessagesRequest,ListMessagesPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()