# Google App Scripts

## What are Google App Scripts?

Google Apps Script is a scripting language and development platform that allows users to extend and automate the functionality of various Google products, including Google Sheets, Google Docs, Google Forms, and more. It is a cloud-based platform, which means that developers can write and deploy code directly within their Google Drive or G Suite account.

Read below to learn how to use Google App Scripts with Filebase.

{% hint style="success" %}

## Prerequisites:

* [x] [Install Node.js and npm](https://nodejs.org/en/download/).
* [x] Download and install an IDE of your choice, such as [VSCode](https://code.visualstudio.com/).
* [x] [Sign up](https://filebase.com/signup) for a free Filebase account.
* [x] Have your Filebase Access and Secret Keys. Learn how to view your access keys [here](https://docs.filebase.com/getting-started-guides/getting-started-guide#working-with-access-keys).
* [x] Create a Filebase IPFS Bucket. Learn how to create a bucket [here](https://docs.filebase.com/getting-started-guides/getting-started-guide#creating-and-working-with-buckets).
  {% endhint %}

### 1. Start by cloning the following GitHub repository:

`git clone https://github.com/jamongeon/s3-http-post-gs.git`

### 2. In the `main.js` file, replace the following variable values to match your configuration:

```jsx
const bucket = 'FILEBASE BUCKET NAME';
const accessKeyId = "FILEBASE ACCESS KEY";
const secretAccessKey = "FILEBASE SECRET KEY";
const region = 'us-east-1';
const acl = 'private';
```

### 3. Then, install Google Clasp with npm:

`npm install -g @google/clasp`

### 4. Login with Google to authenticate the workspace:

`clasp login`

This command will require that you log into your Google account and authorize Google App Scripts.

### 5. Next, open the [Google App Scripts settings page](https://script.google.com/home/usersettings%20then%20retry) and enable the Google Apps Script API:

<figure><img src="https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FFPhusbRmCVvMvnUddPvv%2Fimage.png?alt=media&#x26;token=29edf993-01b7-46ed-a9a5-dd56199044ed" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FiPTVxN3rsJLy9oUit36f%2Fimage.png?alt=media&#x26;token=d5a85ce5-88ab-4b2a-8fc5-dc4d2a5aa418" alt=""><figcaption></figcaption></figure>

### 6. Create the Google App Scripts project with the following commands:

`clasp create --type standalone --title "S3 http post"`

`clasp push`

`clasp open`

### 7. Your project will be opened in your web browser. Select ‘Deploy’ to run your script.

<figure><img src="https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2Fvrkq1Mh37OBBM142vcE7%2Fimage.png?alt=media&#x26;token=b43c3649-a089-43b9-a807-cf1cde319183" alt=""><figcaption></figcaption></figure>

### 8. Then select ‘New Deployment’. For the deployment type, select ‘API Executable’, then give your app a name and description.

<figure><img src="https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FNQ6zDqprQm5kWPfqDO76%2Fimage.png?alt=media&#x26;token=d8ed2642-959b-405d-8c36-bba4ca1c8fd1" alt=""><figcaption></figcaption></figure>

### 9. Then select ‘Deploy’. You will be prompted to authorize access to the web app with your Google account.

### 10. Once authenticated, your app will deploy.

<figure><img src="https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2F6YUCwZto5TwgY00ErPzM%2Fimage.png?alt=media&#x26;token=0a3885f3-a236-4dc6-998e-0ea18b30b5dd" alt=""><figcaption></figcaption></figure>

### 11. Then, select ‘Run’ from the script editor when viewing the `main.gs` file to run your script.

<figure><img src="https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FWl39nalpKjFJ2fhDHOLP%2Fimage.png?alt=media&#x26;token=d54a7cf1-bc43-454d-b95a-9992601ddd20" alt=""><figcaption></figcaption></figure>

This script is configured to use two example files to upload. Change these files to reflect what files you’d like to upload to Filebase.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.filebase.com/code-development-+-sdks/code-development/google-app-scripts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
