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 also allows you to import data from the Google Sheet to ManyChat, to the user's Custom Fields. Refer to the screenshot below to match the narrative with the live action! :D.
You will need to create Number Bot Field "coupon_id", Number Custom Field "user_coupon_id" and Text Custom Field "coupon_code" in ManyChat and then the coupon sheet at Google Sheets.
And it basically works like that: ManyChat takes value from the Number Bot Field "coupon_id".
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 Condition checks is "user_coupon_id" is exactly some CUF. This CUF is "coupon_id", out Number Bot Field. We've passed the number of the code to the user's custom field previously from the code row. 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. The best way is to check any field for a value. And if you have two or more the same values, then the user will receive the first one.