0

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);
  }
}
Tarık
  • 1
  • 1
  • I don't know what you mean by "calleable", but I'm assuming you mean responding to your webhook bot, which you cannot do with webhooks. I suggest you research what is and is not possible with webhooks. You also cannot just invite slackbot, you need to receive a webhook for that server/'s channel. – NEWAZA Mar 12 '23 at 04:11
  • I mean, when I invite or add bot to the any channel, I want that bot works on that channel properly. I don't want to add channels' webhooks one by one to my appscript code. – Tarık Mar 12 '23 at 11:14
  • Cannot be done in Apps Script with a simple webhook. I suggest looking into Node.js and creating an actual bot. – NEWAZA Mar 12 '23 at 12:50
  • Actually I am asking how to do it without webhook. I've got bot token but I can't do the integration part – Tarık Mar 13 '23 at 13:05

0 Answers0