A slack bot that adds the option to report a message to a private channel for review.
The setup of the Slack application, permissions and general approach is outlined at Getting started with Bolt.
The application does require a 'Request URL' to listen to events (e.g. when a message is reported). This is an external endpoint that Slack can send event notifications to, during local deveopment this can be achieved using 'ngrok' - see tunneling with ngrok.
Visit 'Interactive Components' and add an action:
The app can be configured by either environment variables and/or a configuration file
export SLACKREPORT_SIGNING_SECRET=...
export SLACKREPORT_BOT_TOKEN=xoxb-...
export SLACKREPORT_REPORT_CHANNEL=reports
{
"SLACKREPORT_REPORT_MESSAGE_TEXT": "<@${body.user.id}> reported message '${payload.message.text}' from <@${payload.message.user}> in channel <#${payload.channel.id}>",
"SLACKREPORT_ACKNOWLEDGE_MESSAGE_TEXT": "The message was successfully reported, we will review the message and contact you if any further information is required."
}
npm install
node app.js
To aid debugging, the logLevel can be increased:
const app = new App({
token: process.env.SLACKREPORT_BOT_TOKEN,
signingSecret: process.env.SLACKREPORT_SIGNING_SECRET,
logLevel: LogLevel.DEBUG
});