Is there a way to post a message via the web API as a bot user? Right now it seems the flow is to use as_user=False and set channel to @username that you want to send it to.
However, if I'm not using RTM, is there a nice way to send a direct message as the bot itself? https://api.slack.com/methods/chat.postMessage
Yes. If you use the
bot_access_token
that you receive after installing your Slack app to the team with thebot
scope when invoking the API method chat.postMessage, the direct message will come from your bot user.as_user
has to befalse
, which is the default.See Using Oauth 2.0 section "Bot user access tokens" for an example of how to get the
bot_access_token
.