{"id":25091794,"url":"https://github.com/stoiveyp/slack.netstandard","last_synced_at":"2025-04-12T18:47:31.874Z","repository":{"id":38315372,"uuid":"174305538","full_name":"stoiveyp/Slack.NetStandard","owner":"stoiveyp","description":".NET Core package that helps with Slack interactions","archived":false,"fork":false,"pushed_at":"2025-03-04T13:25:20.000Z","size":682,"stargazers_count":44,"open_issues_count":1,"forks_count":18,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T21:13:30.659Z","etag":null,"topics":["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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-07T08:42:39.000Z","updated_at":"2025-03-04T13:25:16.000Z","dependencies_parsed_at":"2024-06-21T16:52:40.565Z","dependency_job_id":"e2d3252f-75b9-4192-8600-69e11d2cfbcf","html_url":"https://github.com/stoiveyp/Slack.NetStandard","commit_stats":{"total_commits":207,"total_committers":9,"mean_commits":23.0,"dds":0.05797101449275366,"last_synced_commit":"f689e8ffa637fbd487a1c394625a4c2350caae78"},"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","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoiveyp%2FSlack.NetStandard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoiveyp%2FSlack.NetStandard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoiveyp%2FSlack.NetStandard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stoiveyp","download_url":"https://codeload.github.com/stoiveyp/Slack.NetStandard/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248617856,"owners_count":21134197,"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":["dotnet","hacktoberfest","slack"],"created_at":"2025-02-07T13:56:28.908Z","updated_at":"2025-04-12T18:47:31.848Z","avatar_url":"https://github.com/stoiveyp.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slack.NetStandard\n[![Latest NuGet version](https://img.shields.io/nuget/v/Slack.NetStandard.svg?style=flat-square\u0026label=nuget)](https://www.nuget.org/packages/Slack.NetStandard)\n\n.NET Core NuGet package that helps with Slack interactions\nAvailable at https://www.nuget.org/packages/Slack.NetStandard\n\n## Create OAuth URL\n\n```csharp\nusing Slack.NetStandard.Auth;\n\nvar builder = new OAuthV2Builder(\"clientId\")\n{\n    State = \"stateGoesHere\", \n    BotScope = \"channels:read\"\n};\nvar redirectUri = builder.BuildUri(); \n```\n\n## Get OAuth Access Token from Code\n\n```csharp\nusing Slack.NetStandard.Auth;\n\nvar token = await OAuthV2Builder.Exchange(code,clientId,clientSecret);\n```\n\n\n## Verify Incoming Request is from Slack\n\n```csharp\nusing Slack.NetStandard;\n\nvar verifier = new RequestVerifier(signingSecret);\nvar verified = verifier.Verify(request.Headers[RequestVerifier.SignatureHeaderName], long.Parse(request.Headers[RequestVerifier.TimestampHeaderName]), request.Body);\n```\n\n## Receive/Respond to a slash command payload\n\n```csharp\nvar command = new SlashCommand(payloadText);\n\nvar message = new InteractionMessage();\nmessage.Blocks.Add(new Section{Text = new PlainText(\"Only title is required\")});\nmessage.Blocks.Add(new Divider());\nmessage.Send(command.ResponseUrl);\n\nawait command.Respond(message);\n\n// or - if it's not from a slash command, any response url can use\nawait command.Response(responseUrl);\n```\n\n## Building \u0026 sending a modal\n\n```csharp\nvar view = new View\n{\n    Type = \"modal\",\n    Title = \"Create New Story\",\n    Close = \"Cancel\",\n    Submit = \"Submit\",\n    Blocks = new List\u003cIMessageBlock\u003e\n    {\n       new Section{Text = new PlainText(\"Only title is required\")}\n    }\n};\n\nvar client = new SlackWebApiClient(accessToken);\nvar response = await client.View.Open(triggerId,view);\n```\n\n## Sending a new message to a channel\n\n```csharp\nvar request = new PostMessageRequest {Channel = \"C123456\"};\nrequest.Blocks.Add(new Section{Text = new PlainText(\"Hi There!\")});\n\nvar client = new SlackWebApiClient(\"token\");\nawait client.Chat.Post(request);\n```\n\n## Parse Events API Body\n\n```csharp\nusing Slack.NetStandard.EventsApi;\nusing Slack.NetStandard.EventsApi.CallbackEvents;\n\nvar eventObject = JsonConvert.DeserializeObject\u003cEvent\u003e(input.Body);\n\nif (eventObject is EventCallback callback)\n{\n    switch(callback.Event)\n    {\n        case AppHomeOpened appHome:\n            break;\n        case GroupClose groupClose:\n            break;\n\n    }\n}\n```\n\n## Parse incoming text for entities (channels, users, links etc.)\n```csharp\nvar entities = TextParser.FindEntities(\"\u003c@W123456|Steven\u003e\");\nif(entities.First() is UserMention mention)\n{\n    var userId = mention.UserId //W123456\n    var label = mention.Label //Steven\n}\n```\n\n## Socket Mode - getting to your payload\n```csharp\nif(msg.Contains(\"envelope_id\")) //If there's no envelope ID it's a Hello or Disconnect object\n{\n   var env = JsonConvert.DeserializeObject\u003cEnvelope\u003e(msg);\n   switch(env.Payload) {\n     case SlashCommand command:\n       //logic here\n       break;\n     case EventCallback evt: \n       //logic here\n       break;\n     case InteractionPayload payload:\n       //logic here\n       break;\n   }\n   var ack = new Acknowledge{EnvelopeId=env.EnvelopeId} //All messages must be acknowledged within a few seconds\n   Send(ack);\n}\n```\nFor a .NET 3.1 client that helps with a lot of the Socket Mode plumbing, the SocketSample app is now available at [Slack.NetStandard.AsyncEnumerable](https://www.nuget.org/packages/Slack.NetStandard.AsyncEnumerable)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoiveyp%2Fslack.netstandard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstoiveyp%2Fslack.netstandard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoiveyp%2Fslack.netstandard/lists"}