Google BigQuery
Connect Google BigQuery to BotDojo so agents can discover accessible datasets and tables, inspect table schemas, and run GoogleSQL using a Google user's permissions.
Before You Start
You will need:
- a Google Cloud project with the BigQuery API enabled
- a Google account that has
bigquery.jobs.createon the project that will run and be billed for queries - permission to read the tables referenced by each query
- the dataset location, such as
US,EU, orus-central1
The exact data permissions depend on the SQL. Reading a table commonly requires bigquery.tables.getData in addition to permission to create the query job.
Configure BotDojo's Google OAuth Client
BotDojo deployment administrators must configure the shared Google web OAuth client before users connect BigQuery:
-
Open the Google Cloud Console project that owns BotDojo's OAuth client.
-
Enable the BigQuery API.
-
Add the read-only BigQuery scope:
https://www.googleapis.com/auth/bigquery.readonly. -
Register each environment's exact callback URL. Production uses:
https://app.botdojo.com/integrations/google-bigquery/oauth_redirect -
Ensure the server has
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETconfigured.
The callback URL must exactly match the URL generated from BOTDOJO_APP_URL.
Connect BigQuery in BotDojo
- Open Integrations in BotDojo.
- Find Google BigQuery and click Connect.
- Enter the Google Cloud Project ID that should create and be billed for query jobs.
- Optionally enter a Default Dataset for unqualified table names.
- Enter the BigQuery Location when the datasets are not discoverable in the default location.
- Continue to Google, choose an account, and approve the requested access.
- Use Test Connection to run a minimal query in the configured project.
Discover Datasets and Tables
The integration provides three read-only metadata tools:
List BigQuery Datasetsreturns datasets in the configured project that Google makes visible to the connected account.List BigQuery Tablesreturns tables and views in a specified dataset.Get BigQuery Table Schemareturns column definitions, nested fields, descriptions, and basic partitioning or clustering metadata.
Dataset and table listings return up to 100 results by default. Pass maxResults to request between 1 and 1,000 results. When a response includes nextPageToken, pass it back as pageToken to retrieve the next page.
These tools use BigQuery's native metadata APIs instead of project-wide INFORMATION_SCHEMA queries. List BigQuery Datasets is filtered to datasets on which the connected account has bigquery.datasets.get. Listing tables requires bigquery.tables.list on the dataset, and schema lookup requires bigquery.tables.get on the table.
For common least-privilege access:
- grant
roles/bigquery.jobUseron the project that runs query jobs - grant
roles/bigquery.metadataVieweron datasets whose tables should be discoverable - grant
roles/bigquery.dataVieweron datasets whose table data may be queried
Grant roles/bigquery.metadataViewer at project level only when the connected account should discover metadata across the entire project.
Execute BigQuery SQL
The Execute BigQuery SQL Agent Tool accepts read-only GoogleSQL beginning with SELECT or WITH:
query: Google Standard SQLparameters: optional named parameters referenced as@nameuseQueryCache: whether BigQuery may reuse cached resultsmaximumBytesBilled: an optional decimal byte limit that causes BigQuery to reject a more expensive query
Example:
SELECT order_id, total
FROM `analytics.sales.orders`
WHERE customer_id = @customerId
ORDER BY created_at DESC
LIMIT 20
For @customerId, pass a named parameter with type STRING.
The tool waits for asynchronous query jobs, follows all result pages, and returns rows as JSON objects. Numeric and temporal values retain BigQuery's lossless string representation.
The tool rejects DML and DDL before calling BigQuery, and the OAuth token is limited to BigQuery read access. Google Cloud IAM still controls which projects, datasets, tables, rows, and columns the connected account may query. Use maximumBytesBilled where query cost needs a hard ceiling.
Manual Verification
- Connect a Google account that can query a small test dataset.
- Test the connection and confirm the configured project is named in the success message.
- Add
List BigQuery Datasetsto an agent and confirm it returns only datasets shared with the connected account. - List tables in one returned dataset and inspect one table's schema.
- Add
Execute BigQuery SQLto the agent and runSELECT 1 AS value. - Run a query with a named
STRINGparameter and confirm the returned row values. - Run a multi-page query and confirm
rowCountmatchestotalRows. - Set a low
maximumBytesBilledvalue and confirm an over-limit query returns a clear BigQuery error. - Attempt a mutation statement and confirm BotDojo rejects it before calling BigQuery.
Troubleshooting
redirect_uri_mismatch: register the exact environment callback URL on the Google OAuth web client.- No refresh token: reconnect and approve consent; BotDojo requests offline access for scheduled loaders.
bigquery.jobs.createdenied: grant the connected user permission to create jobs in the configured project.- No datasets returned: verify the connected Google account has
bigquery.datasets.geton at least one dataset in the configured project. - Table listing denied: grant
roles/bigquery.metadataVieweror another role containingbigquery.tables.liston the dataset. - Schema lookup denied: grant a role containing
bigquery.tables.geton the table or its dataset. - Query access denied: grant
roles/bigquery.dataVieweron the queried dataset or table, or connect a different Google account. - Location error: set the integration location to the dataset's location.