I am trying to create a slack bot using nodejs. I have a requirement where my bot needs to save the link of some slack messages that contains a specific text. This needs to be done for new messages that comes after a bot joined a channel, and also before the bot joined a channel. I tried using search.message api call of slack, but it gives me
"ok":"false", "error":"user_is_bot"
So I guess I can't use this way.
Is there any other way?
Thanks heaps!!
The search.message
method is not availble for bot users. That is why you get that error message.
There are two ways around this.
1. Use a user token instead of a bot token to call the API method
When you received your bot access token you also received a user access token. Use use the user access token to call the API method. (see page Bot Users, section "Share your bot user as a Slack app")
2. Use channels.history to retrieve messages
The channels.history
method also allows you to retrieve messages for a channel and will also work with bot tokens.