Quickstart Guide
Get the MABQ BigQuery Agent running locally and test natural language SQL queries with BigQuery.Prerequisites
Before you begin, ensure you have:Python 3.11+
Required for the backend agent
Node.js 20+
Required for the Next.js frontend
Google Cloud Account
With BigQuery and Vertex AI enabled
Azure AD Tenant
For authentication (optional for local testing)
Setup Steps
Configure Backend
Navigate to the backend directory and install dependencies:The key dependencies include:
google-adk>=0.7.0- Google Agent Development Kitgoogle-cloud-aiplatform[adk]>=1.125.0- Vertex AI integrationfastapi- Web frameworkuvicorn- ASGI serverPyJWT[crypto]>=2.8.0- JWT authentication
Set Backend Environment Variables
Create a
.env file in the POC_ADK directory:.env
For local development without Azure AD, you can bypass authentication by commenting out the middleware in
main.py.Authenticate with Google Cloud
Set up Google Cloud credentials for local development:Ensure your account has the following permissions:
- BigQuery Data Viewer
- BigQuery Job User
- Vertex AI User
Start the Backend Server
Run the FastAPI backend with uvicorn:You should see output like:
The backend will be available at
http://localhost:8000. The ADK agent endpoint is mounted at /.Configure Frontend
In a new terminal, navigate to the frontend directory:Key dependencies installed:
[email protected]- Next.js framework@copilotkit/react-core@^1.51.3- Chat UI framework@ag-ui/client@^0.0.44- ADK HTTP agent@microsoft/teams-js@^2.48.1- Teams integration
Set Frontend Environment Variables
Create a
.env.local file in the frontend-agente directory:.env.local
Test Your Setup
Access the Application
For local testing without Teams, modify
app/page.tsx to bypass the Teams check:app/page.tsx
Ask a Question
Open
http://localhost:3000 in your browser and try these example queries:- “Show me all tables in the dataset”
- “What columns are in the [table_name] table?”
- “Count the total number of records in [table_name]”
- “Show me the top 10 records from [table_name]”
Troubleshooting
Backend fails to start with authentication errors
Backend fails to start with authentication errors
If you see JWT validation errors, either:
- Set valid
AZURE_TENANT_IDandAZURE_CLIENT_IDin your.env - Or comment out the authentication middleware in
main.py:32-108for local testing
Frontend shows 'Acceso Restringido' message
Frontend shows 'Acceso Restringido' message
The app is configured for Microsoft Teams by default. To test locally:
- Open
frontend-agente/app/page.tsx - Comment out the Teams restriction check (lines 41-47)
- Set a mock auth token or modify the backend to allow unauthenticated requests
Agent can't connect to BigQuery
Agent can't connect to BigQuery
Verify:
gcloud auth application-default loginwas runPROJECT_IDandBIGQUERY_DATASETare correct in.env- Your GCP account has BigQuery permissions
- The dataset exists and contains tables
CORS errors when frontend calls backend
CORS errors when frontend calls backend
Ensure:
FRONTEND_URL=http://localhost:3000is set in backend.env- The backend CORS middleware is properly configured
- Both services are running on the expected ports
Next Steps
Understand the Architecture
Learn how the components interact
Configure the Agent
Customize behavior and security settings
Deploy to Cloud Run
Deploy to production on GCP
Set Up Teams Integration
Deploy as a Microsoft Teams app