Reputation: 1279
I've built an app that receives events.
By default, the scope channels:history
lets it receive events for all messages in all public channels of the user who added the app.
Ideally the user would be able to limit it to only some channels, right in app settings. (Any event the app receives will be made world readable.)
Right now I see 2 options:
The message event contains the channel id (not the name). So code can filter on channel, assuming there is a way to set it and the user trusts it.
Create a bot user (even though the app is read-only) that the user can add to specific channels.
Is there a better way?
Upvotes: 6
Views: 2796
Reputation: 32698
If you don't want to use a bot user (your option 2) the only way is to filter out the messages from unwanted channels in your app. You will receive a message event for every new message created (including the ones sent from your app).
The message event does already contain the channel ID
, so you can easily filter based on that.
Example: (Source)
{
"type": "message",
"channel": "C2147483705",
"user": "U2147483697",
"text": "Hello world",
"ts": "1355517523.000005"
}
There is no parameter in the event settings that allows you to choose the channels beforehand. But since this appears to be a reoccurring question, I would suggest to send a feature request to the Slack team about this.
Upvotes: 8