Class SessionsClient
Sessions client wrapper, for convenient use.
Namespace: Google.Cloud.Dialogflow.V2
Assembly: Google.Cloud.Dialogflow.V2.dll
Syntax
public abstract class SessionsClient
Remarks
A service used for session interactions.
For more information, see the API interactions guide.
Properties
DefaultEndpoint
The default endpoint for the Sessions service, which is a host of "dialogflow.googleapis.com" and a port of 443.
Declaration
public static string DefaultEndpoint { get; }
Property Value
Type | Description |
---|---|
string |
DefaultScopes
The default Sessions scopes.
Declaration
public static IReadOnlyList<string> DefaultScopes { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<string> |
Remarks
The default Sessions scopes are:
- https://www.googleapis.com/auth/cloud-platform
- https://www.googleapis.com/auth/dialogflow
GrpcClient
The underlying gRPC Sessions client
Declaration
public virtual Sessions.SessionsClient GrpcClient { get; }
Property Value
Type | Description |
---|---|
Sessions.SessionsClient |
LocationsClient
The Google.Cloud.Location.LocationsClient associated with this client.
Declaration
public virtual LocationsClient LocationsClient { get; }
Property Value
Type | Description |
---|---|
LocationsClient |
ServiceMetadata
The service metadata associated with this client type.
Declaration
public static ServiceMetadata ServiceMetadata { get; }
Property Value
Type | Description |
---|---|
ServiceMetadata |
Methods
Create()
Synchronously creates a SessionsClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use SessionsClientBuilder.
Declaration
public static SessionsClient Create()
Returns
Type | Description |
---|---|
SessionsClient | The created SessionsClient. |
CreateAsync(CancellationToken)
Asynchronously creates a SessionsClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use SessionsClientBuilder.
Declaration
public static Task<SessionsClient> CreateAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The CancellationToken to use while creating the client. |
Returns
Type | Description |
---|---|
Task<SessionsClient> | The task representing the created SessionsClient. |
DetectIntent(DetectIntentRequest, CallSettings)
Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, because it may cause contexts and session entity types to be updated, which in turn might affect results of future queries.
If you might use
Agent Assist
or other CCAI products now or in the future, consider using
[AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]
instead of DetectIntent
. AnalyzeContent
has additional
functionality for Agent Assist and other CCAI products.
Note: Always use agent versions for production traffic. See Versions and environments.
Declaration
public virtual DetectIntentResponse DetectIntent(DetectIntentRequest request, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
DetectIntentRequest | request | The request object containing all of the parameters for the API call. |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
DetectIntentResponse | The RPC response. |
Sample code
// Create client
SessionsClient sessionsClient = SessionsClient.Create();
// Initialize request argument(s)
DetectIntentRequest request = new DetectIntentRequest
{
SessionAsSessionName = SessionName.FromProjectSession("[PROJECT]", "[SESSION]"),
QueryParams = new QueryParameters(),
QueryInput = new QueryInput(),
OutputAudioConfig = new OutputAudioConfig(),
InputAudio = ByteString.Empty,
OutputAudioConfigMask = new FieldMask(),
};
// Make the request
DetectIntentResponse response = sessionsClient.DetectIntent(request);
DetectIntent(SessionName, QueryInput, CallSettings)
Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, because it may cause contexts and session entity types to be updated, which in turn might affect results of future queries.
If you might use
Agent Assist
or other CCAI products now or in the future, consider using
[AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]
instead of DetectIntent
. AnalyzeContent
has additional
functionality for Agent Assist and other CCAI products.
Note: Always use agent versions for production traffic. See Versions and environments.
Declaration
public virtual DetectIntentResponse DetectIntent(SessionName session, QueryInput queryInput, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
SessionName | session | Required. The name of the session this query is sent to. Format:
For more information, see the API interactions guide. Note: Always use agent versions for production traffic. See Versions and environments. |
QueryInput | queryInput | Required. The input specification. It can be set to:
|
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
DetectIntentResponse | The RPC response. |
Sample code
// Create client
SessionsClient sessionsClient = SessionsClient.Create();
// Initialize request argument(s)
SessionName session = SessionName.FromProjectSession("[PROJECT]", "[SESSION]");
QueryInput queryInput = new QueryInput();
// Make the request
DetectIntentResponse response = sessionsClient.DetectIntent(session, queryInput);
DetectIntent(string, QueryInput, CallSettings)
Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, because it may cause contexts and session entity types to be updated, which in turn might affect results of future queries.
If you might use
Agent Assist
or other CCAI products now or in the future, consider using
[AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]
instead of DetectIntent
. AnalyzeContent
has additional
functionality for Agent Assist and other CCAI products.
Note: Always use agent versions for production traffic. See Versions and environments.
Declaration
public virtual DetectIntentResponse DetectIntent(string session, QueryInput queryInput, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
string | session | Required. The name of the session this query is sent to. Format:
For more information, see the API interactions guide. Note: Always use agent versions for production traffic. See Versions and environments. |
QueryInput | queryInput | Required. The input specification. It can be set to:
|
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
DetectIntentResponse | The RPC response. |
Sample code
// Create client
SessionsClient sessionsClient = SessionsClient.Create();
// Initialize request argument(s)
string session = "projects/[PROJECT]/agent/sessions/[SESSION]";
QueryInput queryInput = new QueryInput();
// Make the request
DetectIntentResponse response = sessionsClient.DetectIntent(session, queryInput);
DetectIntentAsync(DetectIntentRequest, CallSettings)
Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, because it may cause contexts and session entity types to be updated, which in turn might affect results of future queries.
If you might use
Agent Assist
or other CCAI products now or in the future, consider using
[AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]
instead of DetectIntent
. AnalyzeContent
has additional
functionality for Agent Assist and other CCAI products.
Note: Always use agent versions for production traffic. See Versions and environments.
Declaration
public virtual Task<DetectIntentResponse> DetectIntentAsync(DetectIntentRequest request, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
DetectIntentRequest | request | The request object containing all of the parameters for the API call. |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
Task<DetectIntentResponse> | A Task containing the RPC response. |
Sample code
// Create client
SessionsClient sessionsClient = await SessionsClient.CreateAsync();
// Initialize request argument(s)
DetectIntentRequest request = new DetectIntentRequest
{
SessionAsSessionName = SessionName.FromProjectSession("[PROJECT]", "[SESSION]"),
QueryParams = new QueryParameters(),
QueryInput = new QueryInput(),
OutputAudioConfig = new OutputAudioConfig(),
InputAudio = ByteString.Empty,
OutputAudioConfigMask = new FieldMask(),
};
// Make the request
DetectIntentResponse response = await sessionsClient.DetectIntentAsync(request);
DetectIntentAsync(DetectIntentRequest, CancellationToken)
Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, because it may cause contexts and session entity types to be updated, which in turn might affect results of future queries.
If you might use
Agent Assist
or other CCAI products now or in the future, consider using
[AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]
instead of DetectIntent
. AnalyzeContent
has additional
functionality for Agent Assist and other CCAI products.
Note: Always use agent versions for production traffic. See Versions and environments.
Declaration
public virtual Task<DetectIntentResponse> DetectIntentAsync(DetectIntentRequest request, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
DetectIntentRequest | request | The request object containing all of the parameters for the API call. |
CancellationToken | cancellationToken | A CancellationToken to use for this RPC. |
Returns
Type | Description |
---|---|
Task<DetectIntentResponse> | A Task containing the RPC response. |
Sample code
// Create client
SessionsClient sessionsClient = await SessionsClient.CreateAsync();
// Initialize request argument(s)
DetectIntentRequest request = new DetectIntentRequest
{
SessionAsSessionName = SessionName.FromProjectSession("[PROJECT]", "[SESSION]"),
QueryParams = new QueryParameters(),
QueryInput = new QueryInput(),
OutputAudioConfig = new OutputAudioConfig(),
InputAudio = ByteString.Empty,
OutputAudioConfigMask = new FieldMask(),
};
// Make the request
DetectIntentResponse response = await sessionsClient.DetectIntentAsync(request);
DetectIntentAsync(SessionName, QueryInput, CallSettings)
Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, because it may cause contexts and session entity types to be updated, which in turn might affect results of future queries.
If you might use
Agent Assist
or other CCAI products now or in the future, consider using
[AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]
instead of DetectIntent
. AnalyzeContent
has additional
functionality for Agent Assist and other CCAI products.
Note: Always use agent versions for production traffic. See Versions and environments.
Declaration
public virtual Task<DetectIntentResponse> DetectIntentAsync(SessionName session, QueryInput queryInput, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
SessionName | session | Required. The name of the session this query is sent to. Format:
For more information, see the API interactions guide. Note: Always use agent versions for production traffic. See Versions and environments. |
QueryInput | queryInput | Required. The input specification. It can be set to:
|
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
Task<DetectIntentResponse> | A Task containing the RPC response. |
Sample code
// Create client
SessionsClient sessionsClient = await SessionsClient.CreateAsync();
// Initialize request argument(s)
SessionName session = SessionName.FromProjectSession("[PROJECT]", "[SESSION]");
QueryInput queryInput = new QueryInput();
// Make the request
DetectIntentResponse response = await sessionsClient.DetectIntentAsync(session, queryInput);
DetectIntentAsync(SessionName, QueryInput, CancellationToken)
Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, because it may cause contexts and session entity types to be updated, which in turn might affect results of future queries.
If you might use
Agent Assist
or other CCAI products now or in the future, consider using
[AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]
instead of DetectIntent
. AnalyzeContent
has additional
functionality for Agent Assist and other CCAI products.
Note: Always use agent versions for production traffic. See Versions and environments.
Declaration
public virtual Task<DetectIntentResponse> DetectIntentAsync(SessionName session, QueryInput queryInput, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
SessionName | session | Required. The name of the session this query is sent to. Format:
For more information, see the API interactions guide. Note: Always use agent versions for production traffic. See Versions and environments. |
QueryInput | queryInput | Required. The input specification. It can be set to:
|
CancellationToken | cancellationToken | A CancellationToken to use for this RPC. |
Returns
Type | Description |
---|---|
Task<DetectIntentResponse> | A Task containing the RPC response. |
Sample code
// Create client
SessionsClient sessionsClient = await SessionsClient.CreateAsync();
// Initialize request argument(s)
SessionName session = SessionName.FromProjectSession("[PROJECT]", "[SESSION]");
QueryInput queryInput = new QueryInput();
// Make the request
DetectIntentResponse response = await sessionsClient.DetectIntentAsync(session, queryInput);
DetectIntentAsync(string, QueryInput, CallSettings)
Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, because it may cause contexts and session entity types to be updated, which in turn might affect results of future queries.
If you might use
Agent Assist
or other CCAI products now or in the future, consider using
[AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]
instead of DetectIntent
. AnalyzeContent
has additional
functionality for Agent Assist and other CCAI products.
Note: Always use agent versions for production traffic. See Versions and environments.
Declaration
public virtual Task<DetectIntentResponse> DetectIntentAsync(string session, QueryInput queryInput, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
string | session | Required. The name of the session this query is sent to. Format:
For more information, see the API interactions guide. Note: Always use agent versions for production traffic. See Versions and environments. |
QueryInput | queryInput | Required. The input specification. It can be set to:
|
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
Task<DetectIntentResponse> | A Task containing the RPC response. |
Sample code
// Create client
SessionsClient sessionsClient = await SessionsClient.CreateAsync();
// Initialize request argument(s)
string session = "projects/[PROJECT]/agent/sessions/[SESSION]";
QueryInput queryInput = new QueryInput();
// Make the request
DetectIntentResponse response = await sessionsClient.DetectIntentAsync(session, queryInput);
DetectIntentAsync(string, QueryInput, CancellationToken)
Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, because it may cause contexts and session entity types to be updated, which in turn might affect results of future queries.
If you might use
Agent Assist
or other CCAI products now or in the future, consider using
[AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]
instead of DetectIntent
. AnalyzeContent
has additional
functionality for Agent Assist and other CCAI products.
Note: Always use agent versions for production traffic. See Versions and environments.
Declaration
public virtual Task<DetectIntentResponse> DetectIntentAsync(string session, QueryInput queryInput, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
string | session | Required. The name of the session this query is sent to. Format:
For more information, see the API interactions guide. Note: Always use agent versions for production traffic. See Versions and environments. |
QueryInput | queryInput | Required. The input specification. It can be set to:
|
CancellationToken | cancellationToken | A CancellationToken to use for this RPC. |
Returns
Type | Description |
---|---|
Task<DetectIntentResponse> | A Task containing the RPC response. |
Sample code
// Create client
SessionsClient sessionsClient = await SessionsClient.CreateAsync();
// Initialize request argument(s)
string session = "projects/[PROJECT]/agent/sessions/[SESSION]";
QueryInput queryInput = new QueryInput();
// Make the request
DetectIntentResponse response = await sessionsClient.DetectIntentAsync(session, queryInput);
ShutdownDefaultChannelsAsync()
Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.
Declaration
public static Task ShutdownDefaultChannelsAsync()
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous shutdown operation. |
Remarks
After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.
StreamingDetectIntent(CallSettings, BidirectionalStreamingSettings)
Processes a natural language query in audio format in a streaming fashion and returns structured, actionable data as a result. This method is only available via the gRPC API (not REST).
If you might use
Agent Assist
or other CCAI products now or in the future, consider using
[StreamingAnalyzeContent][google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContent]
instead of StreamingDetectIntent
. StreamingAnalyzeContent
has
additional functionality for Agent Assist and other CCAI products.
Note: Always use agent versions for production traffic. See Versions and environments.
Declaration
public virtual SessionsClient.StreamingDetectIntentStream StreamingDetectIntent(CallSettings callSettings = null, BidirectionalStreamingSettings streamingSettings = null)
Parameters
Type | Name | Description |
---|---|---|
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
BidirectionalStreamingSettings | streamingSettings | If not null, applies streaming overrides to this RPC call. |
Returns
Type | Description |
---|---|
SessionsClient.StreamingDetectIntentStream | The client-server stream. |
Sample code
// Create client
SessionsClient sessionsClient = SessionsClient.Create();
// Initialize streaming call, retrieving the stream object
using SessionsClient.StreamingDetectIntentStream response = sessionsClient.StreamingDetectIntent();
// Sending requests and retrieving responses can be arbitrarily interleaved
// Exact sequence will depend on client/server behavior
// Create task to do something with responses from server
Task responseHandlerTask = Task.Run(async () =>
{
// Note that C# 8 code can use await foreach
AsyncResponseStream<StreamingDetectIntentResponse> responseStream = response.GetResponseStream();
while (await responseStream.MoveNextAsync())
{
StreamingDetectIntentResponse responseItem = responseStream.Current;
// Do something with streamed response
}
// The response stream has completed
});
// Send requests to the server
bool done = false;
while (!done)
{
// Initialize a request
StreamingDetectIntentRequest request = new StreamingDetectIntentRequest
{
SessionAsSessionName = SessionName.FromProjectSession("[PROJECT]", "[SESSION]"),
QueryParams = new QueryParameters(),
QueryInput = new QueryInput(),
OutputAudioConfig = new OutputAudioConfig(),
InputAudio = ByteString.Empty,
OutputAudioConfigMask = new FieldMask(),
EnableDebuggingInfo = false,
};
// Stream a request to the server
await response.WriteAsync(request);
// Set "done" to true when sending requests is complete
}
// Complete writing requests to the stream
await response.WriteCompleteAsync();
// Await the response handler
// This will complete once all server responses have been processed
await responseHandlerTask;