Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
> ### **10 minutes read                                                                                                                         `Intermediate`**
<h3>
<table>
<tr>
<td><b>10 minutes read</b></td>
<td style={{ paddingLeft: '40px' }}><b>Level:Intermediate</b></td>
<td style={{ paddingLeft: '40px' }}><b>Last Updated: October 2025</b></td>
</tr>
</table>
</h3>

___
**The Link Google Sheets action allows you to connect your flows in Glific directly to Google Sheets so you can read, write, and update data in real time.**

## Video Tutorial
### When to use Read from Google Sheet

**Use this when you need to:**

<iframe width="800" height="500" src="https://www.youtube.com/embed/tdFPJg1aLXU" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
- Send reminders, schedules, or event details stored in a central sheet.

- Populate lists or menus dynamically from sheet data.

### How to set Google Sheet:

- Google Sheets API is linked with Glific.

- The service account has Viewer or Editor access to the sheet.

- The sheet is shared with the service account email.

_Please note: Glific has a new UI, so the visuals from the video will not match the present UI, but the functionality and buttons will remain the same_
___

## Add Readable Google Sheet

1 . Log in to your Glific account.
1. Log in to your Glific account.

2 . Click on `Flows` from the left panel and find `Google sheets`
2. Click on `Flows` from the left panel and find `Google sheets`

4 . Click on `+Create` button to add a sheet to read from
3. Click on `+Create` button to add a sheet to read from

<img width="1468" alt="Screenshot 2024-02-29 at 1 35 52 PM" src="https://github.com/glific/docs/assets/141305477/d0605089-b71e-41ba-85c2-593dabf49b40" />


5 . Add the `Sheet URL` and `Name` of the sheet which you want to integrate. Check the `Read` checkbox and Click on the`Save` button. Follow next steps to get the URL
4. Add the `Sheet URL` and `Name` of the sheet which you want to integrate. Check the `Read` checkbox and Click on the`Save` button. Follow next steps to get the URL

<img width="413" alt="Screenshot 2024-02-29 at 1 38 46 PM" src="https://github.com/glific/docs/assets/141305477/2612f184-eb99-4e02-aca9-6b4c1adbec16"/>

6. Open the Google sheet and click on share button on the right hand side to update the sheet permission to at least `Anyone with the link` can `View`
5. Open the Google sheet and click on share button on the right hand side to update the sheet permission to at least `Anyone with the link` can `View`

![image](https://user-images.githubusercontent.com/32592458/219550695-58224a6f-4312-4981-b518-1dd6de639e3a.png)

6 . Copy the URL
6. Copy the URL

![image](https://user-images.githubusercontent.com/32592458/219550711-8471dcf3-974c-459d-a486-b77b841742d0.png)

Expand All @@ -43,19 +58,41 @@ ___
<img width="1298" alt="Screenshot 2024-02-29 at 1 42 44 PM" src="https://github.com/glific/docs/assets/141305477/1a1d5fcf-5d18-4ffe-bfa8-22f0ffabc5d3" />

- `It is important to note that the first cell in the Sheet should be named as 'Key' for the Read function to work.`
___


**Examples**

- Daily Reminders: Match today’s date to a schedule column and send the corresponding message.

- User Lookup: Pull registration details based on phone number or ID.

- Dynamic Menu: Read items from a sheet and send them as interactive list options.


### Why to use Write Mode of Google Sheet

Write Mode lets you send data from WhatsApp conversations directly into Google Sheets, removing the need for manual entry and ensuring immediate updates.

### When to use Write Mode

- Use this when you need to:
- Record survey answers in real time.
- Collect event registrations or sign-ups
- Track responses, feedback, or status updates.



## Configuring Readable Google Sheet in the Flow

9 . Create a new flow and open it for editing
1 . Create a new flow and open it for editing

10. Use `link Google sheet` node
2. Use `link Google sheet` node

1. Select `Link google Sheet`
3. Select `Link google Sheet`

2. In the second drop-down select the sheet
4. In the second drop-down select the sheet

3. In `Select row` add any variable that uniquely defines the `Key` column of the linked Google sheet
5. In `Select row` add any variable that uniquely defines the `Key` column of the linked Google sheet

<img width="505" alt="Screenshot 2024-02-29 at 1 47 48 PM" src="https://github.com/glific/docs/assets/141305477/f15cce2a-7882-4f83-901e-48b7d7bba09d" />

Expand All @@ -68,13 +105,23 @@ These all are the below calendar functions that can be used :
To write date and time, use the following expression:
`<%= DateTime.now!("Asia/Kolkata") |> Calendar.strftime("%Y/%m/%d %H:%M:%S") %>`

4. Click on `OK`
6. Click on `OK`

5. Use column header like below and access the relevant column of the identified row.
7. Use column header like below and access the relevant column of the identified row.

`@results.sheet.col_nameA`

![image](https://user-images.githubusercontent.com/32592458/219550825-82831f46-a239-4600-b95e-bf0533f0565b.png)


**Examples**

- Survey Submission: Write answers to a new row for each participant.
- Registration Forms: Save participant name, contact number, and event preferences.
- Attendance Logs: Record check-ins directly into the sheet.



___

## Send template messages using Google Sheets
Expand All @@ -96,9 +143,9 @@ Let us dive in a bit deeper by looking at the steps involved :

As you can see, the row input field is given an expression `@calendar.current_date` which tries to match the current date value with a `Key` value. If a match is found, then that row is chosen.

5. In the next step, `Send contact a message` is used and an expression is given in place of the template selection drop-down. The expression reads `<%= Glific.send_template("{uuid}", ["{variables}"]) %>`
5. In the next step, `Send contact a message` is used and an expression is given in place of the template selection drop-down. The expression reads `<%= Glific.send_template("@results.sheet.template_uuid", ["@contact.name"] ) %>` and if no variables then `<%= Glific.send_template("@results.sheet.template_uuid", [] ) %>`

![Screenshot 2023-09-15 at 1 56 54 PM](https://user-images.githubusercontent.com/132430123/268223071-9f2730b9-9364-46fc-b062-1bbd39c102f9.png)


In this expression, the `template_uuid` matching the row in the given date gets send to the user. The expression also passes the value of the contact's name. You can pass multiple variables in this expression, if the template message demands it, using comma separation.

Expand All @@ -121,18 +168,18 @@ Let's dive in a bit deeper to see how it works.

<img width="1294" alt="Screenshot 2024-02-29 at 2 08 50 PM" src="https://github.com/glific/docs/assets/141305477/e5c8b2b4-c33f-4360-9f6d-ff14a76c12f3"/>

3. Now since we have the Google Sheets linked & the interactive message created, let's create a sample flow to understand how it works :
4. Now since we have the Google Sheets linked & the interactive message created, let's create a sample flow to understand how it works :
<img width="738" alt="Screenshot 2023-09-19 at 11 51 38 AM" src="https://user-images.githubusercontent.com/132430123/268859289-c3af33c5-8bc2-4eb0-96ff-d2d8aa4cba01.png"/>

4. As you can see, the flow starts with a Link Google Sheets node, where the readable google sheets from which the options to be fetched inside the interactive message is added. This is how the Google Sheets node is configured :
5. As you can see, the flow starts with a Link Google Sheets node, where the readable google sheets from which the options to be fetched inside the interactive message is added. This is how the Google Sheets node is configured :
<img width="628" alt="Screenshot 2023-09-19 at 11 53 27 AM" src="https://user-images.githubusercontent.com/132430123/268859658-2780aa59-e56c-4b7d-aecf-9b55ff47496e.png"/>

- In the node above, the sheet we created have been linked & the corresponding action is marked as `Read` since the options for `Interactive Message` are being read from the Google Sheets.
- Here 1 is added in `Select row` field, as the values for the interactive message are present on the row with the key value as 1 and it is stored under the variable name `sheet`
- Instead of 1, you can also use dynamic values like [flow variables or contact variables](https://glific.github.io/docs/docs/Product%20Features/Flows/Flow%20Variables/Flow%20variables%20vs%20Contact%20variables), functions like @calendar.current_date etc.


5. The next node consists of `Send contact an interactive message` node and this is how it is configured
6. The next node consists of `Send contact an interactive message` node and this is how it is configured
<img width="611" alt="Screenshot 2023-09-19 at 2 14 22 PM" src="https://user-images.githubusercontent.com/132430123/268894962-90c136b4-3775-426d-9962-269e7407feba.png"/>

- The interactive message we've created is chosen from the dropdown.
Expand All @@ -141,7 +188,7 @@ Let's dive in a bit deeper to see how it works.
- The `id` and `variable` values need to be filled. The id could be any unique value for referencing & variable value is being fetched from the linked Google Sheet.
- The variable names are filled as `@results.sheet.course1`, `@results.sheet.course2` and so on representing each row value from the row we've chosen to read from.

6. Now since the flow is configured, let's test the flow
7. Now since the flow is configured, let's test the flow
<img width="286" alt="Screenshot 2023-09-19 at 12 07 16 PM" src="https://user-images.githubusercontent.com/132430123/268862637-8919962e-840e-47dd-9865-919dd902b483.png"/>

As you can see on the preview above, the list of options we had given in the Google Sheets are shown as a list of options inside the Interactive Message.
Expand Down