Integrate slack with google sheets

Price - Free
(If you are facing problems during checkout, please Contact us)
Details
In this video we are going to learn how to integrate slack with google sheetsDescription
NOTE: Fill up the form on the right and make the payment to get access to the folder which contains the solution and the code.
The integration of Slack with Google Sheets and App Script is a powerful combination that can greatly enhance productivity and collaboration within teams. Slack, a popular team communication platform, allows for real-time messaging, file sharing, and integration with various tools and services. When integrated with Google Sheets and App Script, it offers several important benefits.
Firstly, the integration enables seamless data sharing and updates between Slack channels and Google Sheets. Team members can easily import data from Sheets into Slack and vice versa, ensuring everyone has access to the latest information. This facilitates effective collaboration and decision-making, as team members can quickly analyze and discuss data within the Slack environment.
Secondly, the integration allows for automated workflows and notifications. Using App Script, you can create custom scripts that trigger actions in response to specific events or data changes in Google Sheets. For example, you can set up alerts to notify the team when certain conditions are met or automate data entry processes. This streamlines workflows, reduces manual effort, and ensures timely actions.
Moreover, the integration promotes transparency and accountability. By integrating Google Sheets with Slack, team members can easily share progress updates, reports, and insights from Sheets in dedicated channels. This fosters a culture of transparency and ensures that everyone is on the same page, enhancing team coordination and alignment.
In conclusion, integrating Slack with Google Sheets and App Script brings numerous advantages to teams. It facilitates data sharing, automates workflows, and promotes transparency, ultimately improving productivity and collaboration. By harnessing the power of these tools together, teams can streamline their processes, save time, and make data-driven decisions with ease.
Here is the Code, add this to the script editor, (access the sheet for free -> fill up the get access form)
//add your channel name
var channelName1 = 'example:-#myapp';// add your user name
var userName1 = 'example:-digitalfreelancerdoti';//add your webhook url
var webhookUrl = 'example:-https://hooks.slack.com/services/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';
function onOpen() {
SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
.createMenu('Slack')
.addItem("Set up trigger", "activateTrigger")
.addToUi();
}function activateTrigger(){
var triggers = ScriptApp.getProjectTriggers();
if(triggers.length > 0){
for (var i=0;i<=triggers.length;i++) {
ScriptApp.deleteTrigger(triggers[i]);
}
}
ScriptApp.newTrigger("postDataFromSheet").timeBased().everyMinutes(15).create();
SpreadsheetApp.getActiveSpreadsheet().toast("Trigger set up success!");
}function postDataFromSheet() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheetByName("Sheet1");
var StartRow = 2;
var rows = sheet.getLastRow();
var cols = sheet.getLastColumn();
var dataRange = sheet.getRange(2,1,rows,cols);
var data = dataRange.getValues();
var sanitizedData = removeBlankRowsFromRowResults(data);
for (var i = 0; i < sanitizedData.length; ++i) {
var row = sanitizedData[i];
if (row[4] != "Y") {
var imageUrl = row[1];
var title = row[2];
var itemUrl = row[3];
postToSlackWithOptions(title, itemUrl, imageUrl);
var setRow = i + StartRow;
sheet.getRange(setRow, 5).setValue("Y");
SpreadsheetApp.flush();
}else{
Logger.log("no new records found to post");
}
}
}function removeBlankRowsFromRowResults(spreadSheetRangeData) {
var filteredVal = spreadSheetRangeData.filter(function(r){
return r.join("").length>0;
});
return filteredVal;
}function postToSlackWithOptions(message, itemURL, imageURL) {
var payload = {
'channel' : channelName1,
'username' : userName1,
'text' : message+'\n'+itemURL,
'attachments': [{
"image_url": imageURL
}]
}
var options = {
'method' : 'post',
'contentType' : 'application/json',
'payload' : JSON.stringify(payload)
};
return UrlFetchApp.fetch(webhookUrl, options)
}