Dialogflow V2 API - Class Google::Cloud::Dialogflow::V2::Conversations::Client (v0.17.1)

Reference documentation and code samples for the Dialogflow V2 API class Google::Cloud::Dialogflow::V2::Conversations::Client.

Client for the Conversations service.

Service for managing Conversations.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the Conversations Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all Conversations clients
::Google::Cloud::Dialogflow::V2::Conversations::Client.configure do |config|
  config.timeout = 10.0
end

#complete_conversation

def complete_conversation(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Conversation
def complete_conversation(name: nil) -> ::Google::Cloud::Dialogflow::V2::Conversation

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

Overloads
def complete_conversation(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Conversation
Pass arguments to complete_conversation via a request object, either of type Google::Cloud::Dialogflow::V2::CompleteConversationRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::CompleteConversationRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def complete_conversation(name: nil) -> ::Google::Cloud::Dialogflow::V2::Conversation
Pass arguments to complete_conversation via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • name (::String) — Required. Resource identifier of the conversation to close. Format: projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Conversations::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::CompleteConversationRequest.new

# Call the complete_conversation method.
result = client.complete_conversation request

# The returned object is of type Google::Cloud::Dialogflow::V2::Conversation.
p result

#configure

def configure() { |config| ... } -> Client::Configuration

Configure the Conversations Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#create_conversation

def create_conversation(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Conversation
def create_conversation(parent: nil, conversation: nil, conversation_id: nil) -> ::Google::Cloud::Dialogflow::V2::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.

Overloads
def create_conversation(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Conversation
Pass arguments to create_conversation via a request object, either of type Google::Cloud::Dialogflow::V2::CreateConversationRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::CreateConversationRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def create_conversation(parent: nil, conversation: nil, conversation_id: nil) -> ::Google::Cloud::Dialogflow::V2::Conversation
Pass arguments to create_conversation via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. Resource identifier of the project creating the conversation. Format: projects/<Project ID>/locations/<Location ID>.
  • conversation (::Google::Cloud::Dialogflow::V2::Conversation, ::Hash) — Required. The conversation to create.
  • conversation_id (::String) —

    Optional. Identifier of the conversation. Generally it's auto generated by Google. Only set it if you cannot wait for the response to return a auto-generated one to you.

    The conversation ID must be compliant with the regression fomula "[a-zA-Z][a-zA-Z0-9_-]*" with the characters length in range of [3,64]. If the field is provided, the caller is resposible for

    1. the uniqueness of the ID, otherwise the request will be rejected.
    2. the consistency for whether to use custom ID or not under a project to better ensure uniqueness.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Conversations::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::CreateConversationRequest.new

# Call the create_conversation method.
result = client.create_conversation request

# The returned object is of type Google::Cloud::Dialogflow::V2::Conversation.
p result

#get_conversation

def get_conversation(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Conversation
def get_conversation(name: nil) -> ::Google::Cloud::Dialogflow::V2::Conversation

Retrieves the specific conversation.

Overloads
def get_conversation(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Conversation
Pass arguments to get_conversation via a request object, either of type GetConversationRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::GetConversationRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_conversation(name: nil) -> ::Google::Cloud::Dialogflow::V2::Conversation
Pass arguments to get_conversation via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • name (::String) — Required. The name of the conversation. Format: projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Conversations::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::GetConversationRequest.new

# Call the get_conversation method.
result = client.get_conversation request

# The returned object is of type Google::Cloud::Dialogflow::V2::Conversation.
p result

#initialize

def initialize() { |config| ... } -> Client

Create a new Conversations client object.

Yields
  • (config) — Configure the Conversations client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::Dialogflow::V2::Conversations::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Dialogflow::V2::Conversations::Client.new do |config|
  config.timeout = 10.0
end

#list_conversations

def list_conversations(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Conversation>
def list_conversations(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Conversation>

Returns the list of all conversations in the specified project.

Overloads
def list_conversations(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Conversation>
Pass arguments to list_conversations via a request object, either of type ListConversationsRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::ListConversationsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_conversations(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Conversation>
Pass arguments to list_conversations via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. The project from which to list all conversation. Format: projects/<Project ID>/locations/<Location ID>.
  • page_size (::Integer) — Optional. The maximum number of items to return in a single page. By default 100 and at most 1000.
  • page_token (::String) — Optional. The next_page_token value returned from a previous list request.
  • filter (::String) — A filter expression that filters conversations listed in the response. In general, the expression must specify the field name, a comparison operator, and the value to use for filtering:

    • The value must be a string, a number, or a boolean.
    • The comparison operator must be either `=`,`!=`, `>`, or `<>
    • To filter on multiple expressions, separate the expressions with `AND` or `OR` (omitting both implies `AND`).
    • For clarity, expressions can be enclosed in parentheses.

    Only lifecycle_state can be filtered on in this way. For example, the following expression only returns COMPLETED conversations:

    lifecycle_state = "COMPLETED"

    For more information about filtering, see API Filtering.

Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Conversations::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::ListConversationsRequest.new

# Call the list_conversations method.
result = client.list_conversations request

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Dialogflow::V2::Conversation.
  p response
end

#list_messages

def list_messages(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Message>
def list_messages(parent: nil, filter: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Message>

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.

Overloads
def list_messages(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Message>
Pass arguments to list_messages via a request object, either of type ListMessagesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::ListMessagesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_messages(parent: nil, filter: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Message>
Pass arguments to list_messages via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. The name of the conversation to list messages for. Format: projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>
  • filter (::String) — Optional. Filter on message fields. Currently predicates on create_time and create_time_epoch_microseconds are supported. create_time only support milliseconds accuracy. E.g., create_time_epoch_microseconds > 1551790877964485 or create_time > 2017-01-15T01:30:15.01Z.

    For more information about filtering, see API Filtering.

  • page_size (::Integer) — Optional. The maximum number of items to return in a single page. By default 100 and at most 1000.
  • page_token (::String) — Optional. The next_page_token value returned from a previous list request.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Conversations::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::ListMessagesRequest.new

# Call the list_messages method.
result = client.list_messages request

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Dialogflow::V2::Message.
  p response
end

#location_client

def location_client() -> Google::Cloud::Location::Locations::Client

Get the associated client for mix-in of the Locations.

Returns
  • (Google::Cloud::Location::Locations::Client)