This page provides an instruction & guide for developers building a GPT Action for a specific application. Before you proceed, make sure to first familiarize yourself with the following information:
This particular GPT Action provides an overview of how to connect to Google BigQuery, Google Cloud's Analytical Data Warehouse. This Action takes a user’s question, scans the relevant tables to gather the data schema, then writes a SQL query to answer the user’s question.
Note: these instructions return back a functioning SQL statement, rather than the result itself. Currently middleware is required to return back a CSV file – we’ll be posting instructions on an example of that soon
Check out these links from the application before you get started:
Before you get started, make sure you go through the following steps in your application environment:
Once you've created a Custom GPT, copy the text below in the Instructions panel. Have questions? Check out Getting Started Example to see how this step works in more detail.
**Context**: You are an expert at writing BigQuery SQL queries. A user is going to ask you a question.
**Instructions**:
1. No matter the user's question, start by running `runQuery` operation using this query: "SELECT column_name, table_name, data_type, description FROM `{project}.{dataset}.INFORMATION_SCHEMA.COLUMN_FIELD_PATHS`"
-- Assume project = "<insert your default project here>", dataset = "<insert your default dataset here>", unless the user provides different values
-- Remember to include useLegacySql:false in the json output
2. Convert the user's question into a SQL statement that leverages the step above and run the `runQuery` operation on that SQL statement to confirm the query works. Add a limit of 100 rows
3. Now remove the limit of 100 rows and return back the query for the user to see
**Additional Notes**: If the user says "Let's get started", explain that the user can provide a project or dataset, along with a question they want answered. If the user has no ideas, suggest that we have a sample flights dataset they can query - ask if they want you to query that
Once you've created a Custom GPT, copy the text below in the Actions panel. Have questions? Check out Getting Started Example to see how this step works in more detail.
openapi: 3.1.0
info:
title: BigQuery API
description: API for querying a BigQuery table.
version: 1.0.0
servers:
- url: https://bigquery.googleapis.com/bigquery/v2
description: Google BigQuery API server
paths:
/projects/{projectId}/queries:
post:
operationId: runQuery
summary: Executes a query on a specified BigQuery table.
description: Submits a query to BigQuery and returns the results.
parameters:
- name: projectId
in: path
required: true
description: The ID of the Google Cloud project.
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
query:
type: string
description: The SQL query string.
useLegacySql:
type: boolean
description: Whether to use legacy SQL.
default: false
responses:
'200':
description: Successful query execution.
content:
application/json:
schema:
type: object
properties:
kind:
type: string
example: "bigquery#queryResponse"
schema:
type: object
description: The schema of the results.
jobReference:
type: object
properties:
projectId:
type: string
jobId:
type: string
rows:
type: array
items:
type: object
properties:
f:
type: array
items:
type: object
properties:
v:
type: string
totalRows:
type: string
description: Total number of rows in the query result.
pageToken:
type: string
description: Token for pagination of query results.
'400':
description: Bad request. The request was invalid.
'401':
description: Unauthorized. Authentication is required.
'403':
description: Forbidden. The request is not allowed.
'404':
description: Not found. The specified resource was not found.
'500':
description: Internal server error. An error occurred while processing the request.
Below are instructions on setting up authentication with this 3rd party application. Have questions? Check out Getting Started Example to see how this step works in more detail.
Before you set up authentication in ChatGPT, please take the following steps in the application.
In ChatGPT, click on "Authentication" and choose "OAuth". Enter in the information below.
Once you've set up authentication in ChatGPT, follow the steps below in the application to finalize the Action.
Are there integrations that you’d like us to prioritize? Are there errors in our integrations? File a PR or issue in our github, and we’ll take a look.