Using token to connect Gsheet and Slackbot
Hi! I try to add slackbot to my current channel. The purpose of bot is getting data from Google Sheets than post message to certain channels. However with using webhooks, it seems it isnt possible because I want this bot calleable. If someone invites this bot to their channel, I want that the bot works on that channel properly. I am trying to do with Oauth token but I couldn't manage that. The appscript code that sends message to slack is below:
function sendAlert(payload) {
const webhook = "MY CHANNELS WEBHOOK";
var options = {
"method": "post",
"contentType": "application/json",
"muteHttpExceptions": true,
"payload": JSON.stringify(payload)
};
try {
UrlFetchApp.fetch(webhook, options);
} catch(e) {
Logger.log(e);
}
}