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.
- (config) — Configure the Client client.
- config (Client::Configuration)
# 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.
def complete_conversation(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Conversation
complete_conversation
via a request object, either of type
Google::Cloud::Dialogflow::V2::CompleteConversationRequest or an equivalent Hash.
- 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
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).
-
name (::String) — Required. Resource identifier of the conversation to close.
Format:
projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>
.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Dialogflow::V2::Conversation)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
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.
- (config) — Configure the Client client.
- config (Client::Configuration)
#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.
def create_conversation(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Conversation
create_conversation
via a request object, either of type
Google::Cloud::Dialogflow::V2::CreateConversationRequest or an equivalent Hash.
- 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
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).
-
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
- the uniqueness of the ID, otherwise the request will be rejected.
- the consistency for whether to use custom ID or not under a project to better ensure uniqueness.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Dialogflow::V2::Conversation)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
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
#generate_stateless_summary
def generate_stateless_summary(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::GenerateStatelessSummaryResponse
def generate_stateless_summary(stateless_conversation: nil, conversation_profile: nil, latest_message: nil, max_context_size: nil) -> ::Google::Cloud::Dialogflow::V2::GenerateStatelessSummaryResponse
Generates and returns a summary for a conversation that does not have a resource created for it.
def generate_stateless_summary(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::GenerateStatelessSummaryResponse
generate_stateless_summary
via a request object, either of type
GenerateStatelessSummaryRequest or an equivalent Hash.
- request (::Google::Cloud::Dialogflow::V2::GenerateStatelessSummaryRequest, ::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 generate_stateless_summary(stateless_conversation: nil, conversation_profile: nil, latest_message: nil, max_context_size: nil) -> ::Google::Cloud::Dialogflow::V2::GenerateStatelessSummaryResponse
generate_stateless_summary
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).
- stateless_conversation (::Google::Cloud::Dialogflow::V2::GenerateStatelessSummaryRequest::MinimalConversation, ::Hash) — Required. The conversation to suggest a summary for.
- conversation_profile (::Google::Cloud::Dialogflow::V2::ConversationProfile, ::Hash) — Required. A ConversationProfile containing information required for Summary generation. Required fields: {language_code, security_settings} Optional fields: {agent_assistant_config}
- latest_message (::String) — The name of the latest conversation message used as context for generating a Summary. If empty, the latest message of the conversation will be used. The format is specific to the user and the names of the messages provided.
- max_context_size (::Integer) — Max number of messages prior to and including [latest_message] to use as context when compiling the suggestion. By default 500 and at most 1000.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Dialogflow::V2::GenerateStatelessSummaryResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
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::GenerateStatelessSummaryRequest.new # Call the generate_stateless_summary method. result = client.generate_stateless_summary request # The returned object is of type Google::Cloud::Dialogflow::V2::GenerateStatelessSummaryResponse. 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.
def get_conversation(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Conversation
get_conversation
via a request object, either of type
GetConversationRequest or an equivalent Hash.
- 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
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).
-
name (::String) — Required. The name of the conversation. Format:
projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>
.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Dialogflow::V2::Conversation)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
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.
- (config) — Configure the Conversations client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# 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.
def list_conversations(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Conversation>
list_conversations
via a request object, either of type
ListConversationsRequest or an equivalent Hash.
- 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>
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).
-
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 returnsCOMPLETED
conversations:lifecycle_state = "COMPLETED"
For more information about filtering, see API Filtering.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Conversation>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Conversation>)
- (::Google::Cloud::Error) — if the RPC is aborted.
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 elements, and API calls will be issued to fetch pages as needed. result.each do |item| # Each element is of type ::Google::Cloud::Dialogflow::V2::Conversation. p item 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.
def list_messages(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Message>
list_messages
via a request object, either of type
ListMessagesRequest or an equivalent Hash.
- 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>
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).
-
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
andcreate_time_epoch_microseconds
are supported.create_time
only support milliseconds accuracy. E.g.,create_time_epoch_microseconds > 1551790877964485
orcreate_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.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Message>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Message>)
- (::Google::Cloud::Error) — if the RPC is aborted.
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 elements, and API calls will be issued to fetch pages as needed. result.each do |item| # Each element is of type ::Google::Cloud::Dialogflow::V2::Message. p item end
#location_client
def location_client() -> Google::Cloud::Location::Locations::Client
Get the associated client for mix-in of the Locations.
- (Google::Cloud::Location::Locations::Client)
#suggest_conversation_summary
def suggest_conversation_summary(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::SuggestConversationSummaryResponse
def suggest_conversation_summary(conversation: nil, latest_message: nil, context_size: nil, assist_query_params: nil) -> ::Google::Cloud::Dialogflow::V2::SuggestConversationSummaryResponse
Suggests 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.
def suggest_conversation_summary(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::SuggestConversationSummaryResponse
suggest_conversation_summary
via a request object, either of type
SuggestConversationSummaryRequest or an equivalent Hash.
- request (::Google::Cloud::Dialogflow::V2::SuggestConversationSummaryRequest, ::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 suggest_conversation_summary(conversation: nil, latest_message: nil, context_size: nil, assist_query_params: nil) -> ::Google::Cloud::Dialogflow::V2::SuggestConversationSummaryResponse
suggest_conversation_summary
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).
-
conversation (::String) — Required. The conversation to fetch suggestion for.
Format:
projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>
. -
latest_message (::String) — The name of the latest conversation message used as context for
compiling suggestion. If empty, the latest message of the conversation will
be used.
Format:
projects/<Project ID>/locations/<Location ID>/conversations/<Conversation ID>/messages/<Message ID>
. - context_size (::Integer) — Max number of messages prior to and including [latest_message] to use as context when compiling the suggestion. By default 500 and at most 1000.
- assist_query_params (::Google::Cloud::Dialogflow::V2::AssistQueryParameters, ::Hash) — Parameters for a human assist query.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Dialogflow::V2::SuggestConversationSummaryResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
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::SuggestConversationSummaryRequest.new # Call the suggest_conversation_summary method. result = client.suggest_conversation_summary request # The returned object is of type Google::Cloud::Dialogflow::V2::SuggestConversationSummaryResponse. p result