This article will walk through how to automatically send daily KPI's that live in a Google spreadsheet to Slack.
This solution will use Lido, a new spreadsheet that lets you automate your work, to connect to your Google Sheets data and send messages in Slack on a schedule you set.
Let's get started!
For this example, we have a Google Spreadsheet that has some summary KPI data in some specific cells.
It is required that you have your data in a tabular format, with a row of column headers - even if its just one row of summary data.
A couple of additional formatting requirements:
We will use Lido, a new spreadsheet built to automate repetitive tasks, to connect to your Google Sheet and send out automated Slack messages. There is a free tier with paid plans as well. You can create a new account here: https://www.lido.app/go/signup
Step 1. From the Lido Files page, click "New File"
Step 2. Click Connect Data and select Google Sheets.
Next, paste in your Google Sheet URL. If it's your first time connecting a Google Sheet to Lido, you'll need to authenticate into a Google account that has access to the sheet you're trying to connect.
Step 3: Select the specific range of KPI data in your spreadsheet.
For this example, we'll specify B4 through F5 so we grab just our KPI data, but include our header row as well. If your headers happen to be the top row of the sheet, you may not need to do this. Look at the Preview to make sure the correct data is showing.
Click Add Data.
Your Lido spreadsheet should now have connected data from your Google Sheet. It will look like this:
We are now ready to add the formula to send the message to Slack. The formula is:
```=SENDSLACK(<sender-credential>, "slackchannel", "message", E5)```
Pick an empty cell that is not going to be overrun by other data (such as records that will be added to a table) and start typing =SENDSLACK.
Step 1: Add Slack Credential
Start typing the SENDSLACK formula in the cell. The first argument of the formula is your Slack credential. Click "Add Credential" and follow the prompt. This will give Lido the permission to send Slack messages on your behalf.
A new tab will appear, where Lido App is requesting permission to access the workspace you set. Click Allow.
Step 2: Add the Slack Channel name
Enclose this in double quotes. If you want to post to the #product channel, it would look like:
```=SENDSLACK(<sender-credential>,"product","Daily Signups: " & C5, D6)```
Step 3: Add the Slack message
Add the message that you would like to send through Slack. This can be a string such as "hello!", a cell reference such as C7, or any spreadsheet formula.
For our example, we will send a Slack message inline, with line returns (use <opt> + <Enter> or <alt> + <Enter> just as you would in Google Sheets to add a new line):
If you haven't already sent a Slack test, choose "Run Action" in the cell menu where the SENDSLACK formula is. A Slack message will be sent to the channel you specify.
When the action runs successfully, you will get a notification in the Slack workspace!
Now that you know how to manually send a Slack message based on data from your Google Sheet, if you want to automatically send a Slack message - do the following:
1. Right-click on the cell that has SENDSLACK in it and choose "Add cell automation"
2. Choose the interval that makes sense and click Save.
Now, at the interval you choose the following will happen:
That's it!