{"id":25091735,"url":"https://github.com/stoiveyp/slack.netstandard.annotations","last_synced_at":"2026-05-09T15:11:34.873Z","repository":{"id":62950429,"uuid":"543967196","full_name":"stoiveyp/Slack.NetStandard.Annotations","owner":"stoiveyp","description":"Library that uses method attributes to build a Slack app ","archived":false,"fork":false,"pushed_at":"2022-11-12T11:07:13.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-09T05:39:18.706Z","etag":null,"topics":["csharp","dotnet","hacktoberfest","slack"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stoiveyp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-01T09:28:22.000Z","updated_at":"2022-10-01T10:18:30.000Z","dependencies_parsed_at":"2022-11-09T18:46:45.182Z","dependency_job_id":null,"html_url":"https://github.com/stoiveyp/Slack.NetStandard.Annotations","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoiveyp%2FSlack.NetStandard.Annotations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoiveyp%2FSlack.NetStandard.Annotations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoiveyp%2FSlack.NetStandard.Annotations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoiveyp%2FSlack.NetStandard.Annotations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stoiveyp","download_url":"https://codeload.github.com/stoiveyp/Slack.NetStandard.Annotations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246710835,"owners_count":20821470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","hacktoberfest","slack"],"created_at":"2025-02-07T13:55:51.361Z","updated_at":"2026-05-09T15:11:34.798Z","avatar_url":"https://github.com/stoiveyp.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slack.NetStandard.Annotations\nLibrary that uses method attributes to generate a Slack app \n\n## Creating an Slack App\nTo create an app, add Slack.NetStandard.Annotations as a NuGet reference and then you can tag a class with the SlackApp attribute. The big requirement is that the class has to be partial as the generator adds code to your class behind the scenes.\nThe code generated uses the attributes to match methods to incoming requests, and maps the method parameters for you\n\n```csharp\nusing Slack.NetStandard.Annotations.Markers;\nusing Slack.NetStandard.EventsApi.CallbackEvents;\nusing Slack.NetStandard.Interaction;\n\nnamespace ExampleApp\n{\n    [SlackApp]\n    public partial class Example\n    {\n        [RespondsToEventCallback(typeof(AppHomeOpened))]\n        public async Task\u003cobject\u003e GenerateHome(AppHomeOpened appHome)\n        {\n            return Task.FromResult((object)null!);\n        }\n\n        [RespondsToInteraction(typeof(BlockActionsPayload),\"callbackId\"]\n        public object ExampleSyncCommand()\n        {\n            return null!;\n        }\n\n        [RespondsToSlashCommand(\"command2\")]\n        public async Task\u003cobject\u003e ExampleAsyncCommand(SlashCommand command)\n        {\n            return Task.FromResult((object)null!);\n        }\n    }\n}\n```\nThese attributes add several `Execute` methods to your class which can be called from your code, and work with existing Slack.NetStandard objects\n```csharp\n        public Task\u003cobject\u003e Execute(SlackContext context)\n        public Task\u003cobject\u003e Execute(Envelope envelope)\n        public Task\u003cobject\u003e Execute(Slack.NetStandard.EventsApi.Event @event)\n        public Task\u003cobject\u003e Execute(InteractionPayload InteractionPayload)\n        public Task\u003cobject\u003e Execute(SlashCommand slashCommand)\n```\n\n### What about the return value? Why does it only return object?\n\nThis is the default return value assumed by the generator if you just use the standard `SlackApp` attribute.\n\nYou can pass in a Type parameter if you want the return type to be something else\n\n```csharp\n[SlackApp(typeof(ApiGatewayProxyResponse))]\npublic class ExampleApp {\n        [RespondsToEventCallback(typeof(AppHomeOpened))]\n        public async Task\u003cApiGatewayProxyResponse\u003e GenerateHome(AppHomeOpened appHome)\n        {\n            return Task.FromResult((object)null!);\n        }\n        ...\n```\n\n### What if I want a method to match more specific criteria?\n\nIn this case there is the `SlackMatches` attribute that you can use to point to a static method within the class.\nThis method must have the signature `static bool MethodName(SlackContext)` and it will be used as a secondary check on top of the standard attribute matching\nFor example\n\n```csharp\ninternal static TestCmd(SlackContext cxt) =\u003e true;\n\n[RespondsToSlashCommand()]\n[SlackMatches(nameof(TestCmd))]\npublic Task\u003cobject\u003e SlashCommand(SlashCommand evt, SlackContext context)\n{\n    return Task.FromResult((object)null!);\n}\n```\n\n# Attribute Information\n\nThere are several attributes available right now. The method name you attach these two doesn't matter and can be called anything, they're just examples.\n\n## RespondsToEventCallback\n\nThis attribute triggers the method if a particular type of callback event (So a high level type of `EventCallback` and it's Event property is the type you passed in)\nThe first parameter is the type of callback event\n\n```csharp\n[RespondsToEventCallback(typeof(AppHomeOpened))]\npublic async Task\u003cobject\u003e GenerateHome(AppHomeOpened appHome)\n\n```\n\nThe callback event can then be passed in to your method as a parameter (as well as the usual `SlackContext` object)\n\n## RespondsToEvent\n\nThis attribute indicates that the method is to be triggered in response to a particular high level event type, the event type name is indicated by the parameter passed in.\n\n```csharp\n[RespondsToEvent(typeof(UrlVerification))]\npublic async Task\u003cApiGatewayProxyResponse\u003e VerifyUrl(UrlVerification appHome)\n\n```\n\nThe event type can then be passed in to your method as a parameter (as well as the usual `SlackContext` object)\n\n## RespondsToInteraction\n\nUse this attribute when you want a particular interaction payload.\nThe first parameter is the type of payload. \nThe second optional parameter is the payload `CallbackId` property (or in the case of the BlockActionsPayload it's the first `ActionId`)\n\n```csharp\n[RespondsToInteraction(typeof(BlockActionsPayload), \"actionId\")]\npublic async Task\u003cobject\u003e BlockActionPayloadResponse(BlockActionsPayload blocks)\n```\n\nThe interaction payload can be used by your method as a passed in parameter (as well as the usual `SlackContext` object)\n\n## RespondsToCommand\n\nThis attribute ensures your method is triggered by a command\nThe command name is passed in as the first attribute parameter\n\n```csharp\n[RespondsToSlashCommand(\"command2\")]\npublic async Task\u003cobject\u003e ExampleAsyncCommand(SlashCommand command)\n```\n\nThe command can then be passed in as a method parameter (as well as the usual `SlackContext` object)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoiveyp%2Fslack.netstandard.annotations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstoiveyp%2Fslack.netstandard.annotations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoiveyp%2Fslack.netstandard.annotations/lists"}