Registry /
ai-ml / google-cloud-dialogflow
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SessionsClient
✓ from google.cloud.dialogflow_v2 import SessionsClient
✗ from google.cloud import dialogflow_v2
Direct import of client classes from submodule avoids ambiguity.
QueryResult
✓ from google.cloud.dialogflow_v2.types import QueryResult
IntentsClient
✓ from google.cloud.dialogflow_v2 import IntentsClient
Detect intent from a text query. Ensure GOOGLE_CLOUD_PROJECT env var is set and credentials configured (gcloud auth application-default-login).
import os
from google.cloud.dialogflow_v2 import SessionsClient
project_id = os.environ.get('GOOGLE_CLOUD_PROJECT', 'my-project')
session_id = 'test-session'
text = 'Hello'
language_code = 'en'
client = SessionsClient()
session = client.session_path(project_id, session_id)
text_input = {'text': {'text': text, 'language_code': language_code}}
query_input = {'text': text_input['text']}
response = client.detect_intent(request={'session': session, 'query_input': query_input})
print('Query:', response.query_result.query_text)
print('Response:', response.query_result.fulfillment_text)
Errors
Common errors & fixes
google.api_core.exceptions.PermissionDenied: 403 Request had insufficient authentication scopes.
Default application credentials (ADC) do not include Dialogflow API scope.
fixSet environment variable GOOGLE_APPLICATION_CREDENTIALS to a service account JSON file with 'Dialogflow API Client' role.
google.api_core.exceptions.InvalidArgument: 400 Session path not found.
The session_id does not exist; sessions are created on-the-fly but must be alphanumeric.
fixUse a simple alphanumeric session ID (e.g., 'test-session-1') without special characters.
TypeError: __init__() got an unexpected keyword argument 'request'
Using old-style positional arguments instead of dict-based request parameter.
fixPass request as a keyword argument: client.detect_intent(request={'session': ..., 'query_input': ...}) Upgrade
Version history
2.48.0latest on PyPI · released Jun 3, 2026
Audit
Dependencies
google-api-corerequiredCore Google API infrastructure
grpciorequiredgRPC transport for API calls
google-cloud-storageoptionalStoring audio files for streaming recognition