> ## Documentation Index
> Fetch the complete documentation index at: https://docs.refold.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Building a Google Sheets integration

> This tutorial will give an example of how to create a Sheets integration that adds a new row to your Linked Account's spreadsheet.

## Pre-requisites

1. Sheets App is enabled in Refold.
2. Google Sheets OAuth app credentials added to Refold. Refer [here](https://docs.gocobalt.io/resources/integration-providers/google_sheets#creating-an-app-in-google-sheets).
3. Trigger created in Refold. Refer [here](https://docs.gocobalt.io/guides/workflow/triggers).
4. Linked Account available. Refer [here](https://docs.gocobalt.io/guides/platform/linked-account).

## Building a Workflow

#### 1. Create Workflow in app

* Go to your [`Apps catalog`](https://app.gocobalt.io/apps) in **Refold** > Search for `Google Sheets` > `Workflows` > `Add Workflow` > Choose `Manually` > Give it a name and click on `Add Workflow`.

<img height="200" src="https://mintcdn.com/cobalt-55/6ZvwOHqAhmVnIyqF/images/Sheets/sheets_workflow.png?fit=max&auto=format&n=6ZvwOHqAhmVnIyqF&q=85&s=eb96fc8b6f1645b6661ca25edddb64a3" alt="Navigation for Workflow setup" data-path="images/Sheets/sheets_workflow.png" />

#### 2. Adding the Trigger

To add a trigger for a Workflow in Refold, you need to select details about the Trigger like the Type and which trigger to be implemented.

To add a Trigger, follow these steps:

* Click on the **Start node** to add a trigger.
* In the right side, select the **Type** and the **Trigger** and click on the `Add Trigger` button.

<img height="200" src="https://mintcdn.com/cobalt-55/6ZvwOHqAhmVnIyqF/images/Sheets/Sheets_start.png?fit=max&auto=format&n=6ZvwOHqAhmVnIyqF&q=85&s=7fd6e8f68f1cf0179c046b3a375b11c1" alt="Start Node Trigger" data-path="images/Sheets/Sheets_start.png" />

#### 3. Adding the Sheets Action

* From `Actions`, add a Google Sheets node to the workflow.
* Click on the node and select `Add a new row` from **Choose an Action**, provide the `Spreadsheet ID`, `Worksheet ID` and optionally provide `Data for Column` and click on `Save`.

<Note>
  We have added data for 2 columns in the sheet for Headers A and B.
</Note>

<img height="200" src="https://mintcdn.com/cobalt-55/6ZvwOHqAhmVnIyqF/images/Sheets/sheets_action.png?fit=max&auto=format&n=6ZvwOHqAhmVnIyqF&q=85&s=5fc515234be8f92cf2e2cceb4911a74b" alt="Sheets Node" data-path="images/Sheets/sheets_action.png" />

* Connect the two nodes by clicking on `+` button on the `Start` node and dragging the arrow to the **Sheets** node.

#### 4. Publishing the Workflow

* To publish the workflow, click on the `Publish` button in the top, **Select Environments** of the Workflow and click on `Publish`.

<img height="200" src="https://mintcdn.com/cobalt-55/6ZvwOHqAhmVnIyqF/images/Sheets/sheets_publish.png?fit=max&auto=format&n=6ZvwOHqAhmVnIyqF&q=85&s=1923ef2d1f142925c4c220f47d6b5d3d" alt="Publish Workflow" data-path="images/Sheets/sheets_publish.png" />

## Enabling the Workflow

To enable a workflow, end user or a Linked Account needs to Toggle On the Workflow after connecting with the application.

* Navigate to the Linked Account in which the Workflow needs to be enabled by getting its' **Hosted URL**.

<img height="200" src="https://mintcdn.com/cobalt-55/JZIwRzAqkgW8vPoP/images/Salesforce/Salesforce_linked.png?fit=max&auto=format&n=JZIwRzAqkgW8vPoP&q=85&s=299ceef4856775339eefb9415723bb55" alt="Navigate to Linked Account" data-path="images/Salesforce/Salesforce_linked.png" />

* Go to the Hosted URL and select **Google Sheets** from `Manage your Integrations` list.
* Click on the `Connect` button, review the permissions and allow them for a successful connection.
* After a successful connection, you can see the `Configure` section in the **Google Sheets** Application page.
* Enable the Workflow **New Row** by turning the **toggle On** and click on `Save`.

<img height="200" src="https://mintcdn.com/cobalt-55/6ZvwOHqAhmVnIyqF/images/Sheets/sheets_enable.png?fit=max&auto=format&n=6ZvwOHqAhmVnIyqF&q=85&s=9fae00d522e9b57100f8e596e04412f0" alt="Enable Workflow in Linked Account" data-path="images/Sheets/sheets_enable.png" />

## Fire an App Event

Lastly, we'll fire an App Event whenever a contact is created in your app by using the Workflow.

* Navigate to `Try API` in **Refold**.
* Choose the **Linked Account** created to test the workflow, select the **Event** and `Google Sheets` as the **Application**.
* Click on the `Fire Event` button in the top right.

<img height="200" src="https://mintcdn.com/cobalt-55/6ZvwOHqAhmVnIyqF/images/Sheets/sheets_fire.png?fit=max&auto=format&n=6ZvwOHqAhmVnIyqF&q=85&s=acd8b9dfc37a0f99587a5e8cb1da4fb2" alt="Fire an App Event" data-path="images/Sheets/sheets_fire.png" />

* You can check the status of the event by navigating to `Logs` > `Events` in **Refold**.

Congratulations! We have successfully built a Sheets integration that adds a new row to your Linked Account's spreadsheet.
