Reputation: 83
I'm currently creating a slack bot that reads messages from a slack channel and then parses the message.
I have successfully created this using app_mention. But the problem now is that only the messages that mention my bot are being read by the bot.
I would like my bot to read and respond to All messages inside a particular channel.
Current code :
//listen to messages
const slackEvents = createEventAdapter(slackSigningSecret);
//post messages
const slackClient = new WebClient(slackToken);
//all messages
slackEvents.on('message', (event) => {
console.log('This is not working. Please help!');
});
//when the bot is mentioned
slackEvents.on('app_mention', (event) => {
console.log('This is working.);
My code slackEvents.on('app_mention', (event) => ()
is working perfectly.
However, the slackEvents.on('message', (event) => ()
is not working.
I have added all the scopes that i thought were required for this. channels:history, groups:history, but still nothing happens.
How can i make the bot listen to all the messages in a particular channel? Please help!
Upvotes: 2
Views: 4877
Reputation: 1
Adding to the above answer -
You can use message event to subscribe to all the messages sent in a channel.
For this you'll need:
Invite the bot to the channel
This worked for me.
Upvotes: 0
Reputation: 2881
You can use message
event to subscribe to all the messages sent in a channel.
For this you'll need:
If configured properly, you'll receive event whenever a message is posted in the channel.
Upvotes: 4