# Configuring Google Sheets Prompt Logging This proxy can log incoming prompts and model responses to Google Sheets. Some configuration on the Google side is required to enable this feature. The APIs used are free, but you will need a Google account and a Google Cloud Platform project. NOTE: Concurrency is not supported. Don't connect two instances of the server to the same spreadsheet or bad things will happen. ## Prerequisites - A Google account - A Google Cloud Platform project Note that this process grants the proxy software access to your Google Sheets data for the spreadsheet ID you provide. Use a throwaway spreadsheet/Google Account if you're not comfortable with this. ### 0. Create a Google Cloud Platform Project _A Google Cloud Platform project is required to enable programmatic access to Google Sheets. If you already have a project, skip to the next step. You can also see the [Google Cloud Platform documentation](https://developers.google.com/workspace/guides/create-project) for more information._ - Go to the Google Cloud Platform Console and [create a new project](https://console.cloud.google.com/projectcreate). ### 1. Enable the Google Sheets API _The Google Sheets API must be enabled for your project. You can also see the [Google Sheets API documentation](https://developers.google.com/sheets/api/quickstart/nodejs) for more information._ - Go to the [Google Sheets API page](https://console.cloud.google.com/apis/library/sheets.googleapis.com) and click **Enable**, then fill in the form to enable the Google Sheets API for your project. ### 2. Create a Service Account _A service account is required to authenticate the proxy to Google Sheets._ - Once the Google Sheets API is enabled, click the **Credentials** tab on the Google Sheets API page. - Click **Create credentials** and select **Service account**. - Provide a name for the service account and click **Done** (the second and third steps can be skipped). ### 3. Download the Service Account Key _Once your account is created, you'll need to download the key file and include it in the proxy's secrets configuration._ - Click the Service Account you just created in the list of service accounts for the API. - Click the **Keys** tab and click **Add key**, then select **Create new key**. - Select **JSON** as the key type and click **Create**. The JSON file will be downloaded to your computer. ### 4. Set the Service Account key as a Secret _The JSON key file must be set as a secret in the proxy's configuration. Because files cannot be included in the secrets configuration, you'll need to base64 encode the file's contents and paste the encoded string as the value of the `GOOGLE_SHEETS_KEY` secret._ - Open the JSON key file in a text editor and copy the contents. - Visit the [base64 encode/decode tool](https://www.base64encode.org/) and paste the contents into the box, then click **Encode**. - Copy the encoded string and paste it as the value of the `GOOGLE_SHEETS_KEY` secret in the deployment's secrets configuration. - **WARNING:** Don't reveal this string publically. The `.env` file is NOT private -- unless you're running the proxy locally, you should not use it to store secrets! ### 5. Create a new spreadsheet and share it with the service account _The service account must be given permission to access the logging spreadsheet. Each service account has a unique email address, which can be found in the JSON key file; share the spreadsheet with that email address just as you would share it with another user._ - Open the JSON key file in a text editor and copy the value of the `client_email` field. - Open the spreadsheet you want to log to, or create a new one, and click **File > Share**. - Paste the service account's email address into the **Add people or groups** field. Ensure the service account has **Editor** permissions, then click **Done**.