To make this run on both local machines and your various environments (staging, production, etc.) you can include additional redirect URLs in the list. You'd want to replace those with values from your code. Localhost:44329 is the hostname and port number assigned to my local application. Beneath the Redirect URLs section, include the following URL: Navigate back to the Slack app and select the OAuth & Permission menu item. Slack needs to know where to redirect the user once the authorization is given by the user. By including a scope of incoming-webhook, we ask Slack for permission to post messages to a Slack channel using a webhook URL. You will need to replace YOUR_CLIENT_ID with the client ID found on the Basic Information page on your slack app. The endpoint redirects the user to Slack's authorize page. Include a big Authorize button on the front page: Authorize SlackĬreate the AuthorizeSlack action in the HomeController class: public IActionResult AuthorizeSlack() For this example, I have chosen an MVC project, but it could be another project type as well. Keep the Basic Information page open, since that contains the app ID and secret which we will need in a moment.Ĭreate a new ASP.NET Core website. Give the app a proper name and select a workspace. In the modal, select the From scratch option. Start by navigating to and click the Create New App button. Here's an example of how to set that up in an ASP.NET Core website. The application now has access to post messages to the selected channel. Slack then redirects you back to the application and the integration is set up. You start by clicking an Authorize button, the application redirects you to Slack where you sign in and select a channel. You probably already tried connecting online apps with Slack. In this post, I'll show you how to create an ASP.NET Core web app that lets the user authorize their Slack workspace, select a channel, and post messages to that channel from C#. It's essential for moderne companies to be notified on Slack when new errors are logged, when a build fails, when customers are acquired, etc. All of your favorite tools (elmah.io anyone?) integrate with online messaging tools like Slack.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |