An example of some of the things you can do with a Slack app written with the help of SlackNet. It uses SlackNet's SlackSocketModeClient to connect to Slack as easily as possible.
This project makes use of Microsoft.Extensions.DependencyInjection and SlackNet.Extensions.DependencyInjection for configuring SlackNet.
This is the same DI container that ASP.NET Core uses, so configuring SlackNet in a web site will look almost identical.
Check out the other example projects to see how to configure SlackNet with other containers, or without any container.
- Create an app on the Slack developer website. Follow the prompts, selecting the "from scratch" option, rather than the app manifest option.
- Request the bot token scopes required by the demo:
users:readchannels:readgroups:readim:readmpim:readfor getting user & conversation info.chat:writefor posting messages.files:readfor uploading files.
- Install the app to your workspace and copy the bot user OAuth token from your app's OAuth & Permissions page into the demo's appsettings.json file for the value of the
ApiToken. - Enable socket mode for your app. You'll be required to generate an app-level token - copy this into appsettings.json for the value of the
AppLevelToken. - Enable the home tab for your app.
- Enable events and subscribe to the following bot events:
app_home_openedfor showing app home tab.message.channelsmessage.groupsmessage.immessage.mpimfor receiving messages.
- Add your app to any channels/groups etc. you want it to respond to.
- Optionally configure the slash command (see below).
- Run the demo.
- App Home - Tells you what you can do with the demo when you open the app's home view in Slack.
- Ping - A simple event handler that says pong when you say ping.
- Counter - Displays an interactive message that updates itself.
- Modal View - Opens a modal view with a range of different inputs.
The echo demo handles a /echo slash command and sends back the text after the command name.
Follow Slack's Creating a Slash Command instructions to create the slash command in your app, and make sure the command is set to /echo, to match up with the demo code.
After this is configured and the demo is running, you should be able to type /echo test into Slack and receive a message saying "test".