This resource comes from ManyChat's Knowledge Base. We've included it here for your convenience!
Google Sheets Integration
From this article, you will learn how to connect your ManyChat Account to Google Sheets, and how to simply transfer your subscriber's data to tables by actions in flows.
Connect your Google account
Firstly, you have to connect your Google account to ManyChat:
1. Go to Settings —> Integrations
2. Tap the button bellow: Connect Google Sheets Account, and confirm the authorization.
3. Now you can start using Google Sheets.
Add Google Sheets action to flows
You can add the integration action in one of your flows, and when your subscriber passes through this flow, their data will be pushed to your Google Sheet.
1. Create a new worksheet in your Google Docs and prepare column names on the first row of the document
2. Go to the flow where you want to add an action
3. Make a new action node and choose Google Sheet Actions
Set up your Worksheet action
1. Click on the Insert Row link, and Google Sheets wizard will appear.
2. Choose your spreadsheet, worksheet, and match ManyChat fields to the worksheet fields. All subscriber's data, Custom User Fields, Bot Fields or Tags are available to send.
Now you can try your flow, and then chosen data will appear in your Worksheet.
Note: If you want to change the structure of your Worksheet, you have to go to the wizard of your Google Sheets Action and refresh the fields.
Get a row from Google Sheet by lookup value
Our integration allows you to import data from the Google Sheet into Custom Fields in ManyChat. Refer to the screenshot below to match the narrative with the live action through the guide!
You will need to create
1. Number Bot Field "coupon_id",
2. Number Custom Field "user_coupon_id",
3. Text Custom Field "coupon_code" in ManyChat,
4. Coupon sheet at Google Sheets.
And it basically works like this: ManyChat takes value from the Number Bot Field "coupon_id", looks for the number in the sheet and saves it in the specified Custom Field, "user_coupon_id" in our case.
For example, value of "coupon_id" is now 3 — this will be Lookup Value. And then ManyChat goes and looks for "3" in the Google Sheet Column "ID" — this is Lookup Column.
It will find a Row with "1111-11111111-111111-1111" code and map it to the chosen Custom Field.
We're going to make a Flow that will give subscriber a coupon after the click on the button. We are making the request to Google Sheet (described on the screenshot above). We're receiving the coupon ID and checking with Condition if the user received the coupon at all (we need it in the case there are no more coupons). If there is a coupon, we'll increase "coupon_id" by 1 — that will increase Lookup Value and move us through the list giving the next subscriber the next coupon.
If Lookup Value is more than the number of the coupons and there are no more coupons, notning will be mapped to the "user_coupon_id" Custom Field and we'll sent the second message "No coupon".
Note that second Condition checks if the user has "Coupon_received" tag which is applied only when the user do not have it yet. If he has, he will receive the message that he already received the coupon. That will make sure that the same user won't be available to get the code twice.
Note: if Google Sheet doesn’t find any value identical to Lookup Value, then it wouldn’t return anything. And if you have two or more the same values, then the user will receive the first one.
Update Existing Row
This newest feature allows you to update the information in a Google Sheet you had already filled before, using a column and a Custom Field as the lookup values.
1. Create a Google Sheet action and select the sub-action "Update Existing Row".
2. Select the Sheet, the Lookup Column, and the Lookup Value so that they correspond to the column and the Custom Field that were used in the initial "Insert Row" acton.
3. Once it is done, the set up Custom Fields will get re-populated with the current values.