How can I do when the slackbot invited to channel that works properly

69 Views Asked by At

By using Oauth2 token

I want to send some data from Google Sheets by using Slackbot. I've done everything, tokens connections etc. however I still have to add channel id to my script manually. So I want to build something when the bot invited to channel, it works by itself properly without adding channel id manually.

1

There are 1 best solutions below

0
Vinicius Souza On

You can try the Events API: https://api.slack.com/apis/connections/events-api

Check the basic setup, you'll need to provide a URL to where slack will send the events you subscribe.

The event you are probably looking for is member_joined_channel You will receive an event everytime a user joins the channel(including your own bot), so you would need to verify the userId, see if it's your bot, otherwise simply ack the event without further processing it.

Hope that helps.