Integration of **Google Sheets** allows you to use Google tables as a data source and storage for the bot. ChatRex can read lines, add new entries, and update existing data.

Main scenarios:

- preservation of applications, contacts and results of dialogue;
- updating the client by phone, email or other key;
- obtaining price, order status or background information;
- Work with multiple tables for different processes.

## Connecting a Google account

1. Open **Integrations**.
2. Click **Connect integration** and select **Google Sheets**.
3. Open the tab **Connection installation**.
4. Press **Connect**.
5. Select a Google account and confirm access to the tables.

After successful authorization, the status **Connected** and the email associated account will appear.

!!!note
ChatRex only accesses tables that are available to a connected Google account. If the table belongs to another user, first give that account access through Google Sheets.
!!!

## Addition of the table

1. In the integration settings, go to the **Settings** tab.
2. Press **Add table**.
3. Insert the full Google Sheets link.
4. Press **Connect**.

If the link is incorrect, the table does not exist or the account does not have access, ChatRex will show an error. Correct the link or access rights and reconnect.

## Basic data of the table

After adding, the table will be edited. In the tab **Basic data** specify:

- **Reference to the table**;
- **The name of the table** is an understandable name within ChatRex.
- **A sheet from the table** is a specific sheet that the bot will work with.

If the document has one sheet, it can be selected automatically. If there are several sheets, choose the one you need manually and save the basic data.

Each connection works with one selected sheet. To work with another sheet, add a separate table setting.

## Column setting

The **Columns** tab becomes available after selecting and saving the sheet. ChatRex reads the first line of the sheet as headlines and shows the columns found.

For each column, adjust:

- the name or corresponding field of ChatRex;
- type of data: text, number, telephone, email, date, date and time or list;
- **Key**.

A key column is used to find and update an existing row. There can only be one key. Usually choose a unique field: phone, email, order number or internal identifier.

!!!warning
Do not use a column with repeating values as a key. Otherwise, the action may update the wrong line.
!!!

If the structure of the sheet has changed, click **Update fields**, check the correspondences and save them again. Headings should be in the first line and not empty.

## Several tables

You can connect several Google tables, for example:

- leads and applications;
- catalog or price;
- order statuses;
- Journal of dialogue results.

In each action, a specific connected table is selected. The names inside ChatRex should help distinguish them from each other.

## Actions bot

After connecting and configuring the columns, add read and write operations in the bot settings.

Detailed instructions: [**Google Sheets**](<../../actions/integrations/google-sheets.md>).

## Removal and disconnection

Deleting a table from ChatRex settings removes its connection and column matching, but does not delete the file itself in Google Sheets.

When the connection is broken, actions will stop reading and changing tables. Before disabling, check which bots are using this integration.
