Connect Slack to Google Sheets (The Easiest Way in 2024)

In this article, we will show you how to connect Slack to Google Sheets in just a few simple steps, whether with a custom script or with Lido. If you want to streamline your workflow and save time, this method is perfect for you!

Connect Slack to Google Sheets with AppsScript

1. Create a Custom App in Slack on api.slack.com/apps

First, visit api.slack.com/apps. You can create a custom app in Slack that will allow you to send data to Google Sheets via the Slack API. Click on “Create an app”.

Next, you will need to set up your app. You can choose to create it from scratch or from an existing app manifest. Select “From Scratch”.

Once you have named your app and chosen the workspace you want to develop it in, click on “Create an app”.

After clicking on “Create an app”, the app information and settings will load. Go to the left sidebar and click on “OAuth & Permissions”.

You will see several options for authenticating access to Slack data through your custom app. Scroll down to find “Scopes” as the first option.

“Scopes” define the permissions and features of the custom app we created.

To add permissions, click on “Add an OAuth Scope”. A dropdown list will appear.

Add the following permissions:

  • channels:history
  • channels:read
  • users:read

2. Install the custom app

Go back to the top of the page, then click on “Install App” in the left sidebar.

A page with the message “Install the app to your team” will load. Click on “Install to Workspace”.

A new tab or window will load, where the app you created will ask for permission to access the workspace you configured. The list of permissions you set in the previous step will be displayed. Click on “Allow”.

3. Add the custom app to your Slack workspace channel

Go back to the channel in the workspace where you want to add the custom app’s bot. Click on the channel name preceded by the hashtag.

In the channel’s settings, click on the “Integrations” tab. Find the label “Applications” and click on “Add an app”.

You will be directed to the “Add apps” page. You can either type the app name in the search bar or scroll down to find the list of apps in your workspace. Click on the “Add” button next to the app name.

Alternatively, you can type /invite YourAppName in the channel’s chat box and press “Enter”.

A message stating that the custom app’s bot has been added to the channel will appear in the channel.

4. Add a custom script to Google Sheets

At this point, open Google Sheets. You can either create a new spreadsheet or open an existing one. Then, click on “Extensions” and select “Apps Script”.

A new tab or window will load for “Google Apps Script”.

Clear the code area, then copy the code from the box below. You can copy the code by clicking on the green copy button or by highlighting all the text in the box. Make sure to scroll the box as it is a long script.

Then, paste it into the Apps Script code area.

In the next step, we will modify the code to work with our Google spreadsheet and Slack accounts.

5. Add your Slack user authentication token and Google spreadsheet ID to the script

Go back to api.slack.com/apps and find the custom app you created earlier. Click on “OAuth & Permissions” again in the left sidebar.

Scroll down a bit to find “OAuth Tokens for Your Workspace”. There is a text field containing the token. Click on “Copy”.

Go back to the “Apps Script” tab, then edit line 3:

const SLACK_API_TOKEN = 'xoxb-...';

Replace the string within the single quotes with your token. It should also start with xoxb.

Go back to the Google Sheets tab. Copy the Google spreadsheet ID by looking at the address bar and copying the string after /d/.

In the “Apps Script” tab, then modify line 4:

const SHEET_ID = 'your_google_sheet_id';

Replace the string within the single quotes with your sheet ID.

Once these modifications are made, you can click on the save icon next to the execution button.

6. Run and authorize the script

We are now ready to run the script. Click on the dropdown list next to the “Debug” button in the toolbar above the code area and select “onOpen”.

Click on “Run the selected function”.

Since this is custom code and the first time it’s running in Google Apps Script, you need to authorize the code to run and access your data. A dialog box titled “Authorization Required” will appear. Click on “Continue”.

A new window will open, asking you to choose the Google account. Most of the time, only the account you use to create the sheet will be listed. Select it.

A warning that Google has not verified the app will appear. Click on the “Advanced” link at the bottom of the message. A link titled “Go to Untitled project (unsafe)” will appear. Click on it.

A list of permissions required by the app will then be displayed. Click on “Allow”.

The window will close, and you will be taken back to the “Apps Script” tab where a execution log will appear below the code area. You will receive two messages: “Execution started” and then “Execution completed”.

7. Select “Slack Backup”, then click on “Save Channel Messages”

Go back to the Google Sheets tab, then click on “Refresh”. A new option in the File menu will appear, titled “Slack Backup”. Click on “Save Channel Messages”.

8. Enter the channel name or ID

A small box will appear where you can enter the channel name or ID in a text field. You should enter your channel name in lowercase, without the #. After entering it, click on “OK”.

A new tab with the same name as the channel will be added and will contain all the messages that were in the channel.

And voila, you have now connected Slack to Google Sheets!

We hope this article has been helpful in understanding how to connect Slack to Google Sheets. You can also check out our articles on connecting Typeform to Google Sheets and connecting Discord to Google Sheets.

To further streamline your workflow, we recommend reading our guide on importing a CSV file from an email into Google Sheets and trying out our rent reminder software!

For more tips and advice, feel free to visit our website Crawlan.com.

Related posts