Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Examples

James Marcogliese edited this page Jan 30, 2019 · 9 revisions

Sending a message to a channel (Async)

using Slack.Api.CSharp.WebApi;

string accessToken = "xoxp-EXAMPLE-ACCESS-TOKEN";     
string channel = "D0PNCRP9N";
string message = "This is a test message!";

ISlackWebAPI slackWebAPI = new SlackWebAPI(); 

PostMessageOKResponse res = await slackWebAPI.Chat.PostMessageAsync(token: accessToken, text: message, channel: channel); 

Using the JSON EventApi Wrapper Object in a .Net Controller


using Slack.Api.CSharp.EventsApi;

namespace slackBot.Controllers
{
    [Route("events")]
    [ApiController]
    public class EventsController : ControllerBase
    {
        [HttpPost]
        public IActionResult Event([FromBody]SlackEvent request)
        {
             // DoSomething();
        }
    }
}

Clone this wiki locally