Instructions

Set up Slack delivery, configure events, and send messages from your apps.

1. Create a Slack Incoming Webhook

  1. Open Create a Slack app or Slack app management and create or select an app for your workspace.
  2. Enable Incoming Webhooks.
  3. Create a webhook for the Slack channel that should receive messages.
  4. Copy the webhook URL. It should look like https://hooks.slack.com/services/....
  5. Store the webhook URL in Slack Bridge on the Slack bot.

Slack's official guide is here: Sending messages using incoming webhooks.

2. Configure Slack Bridge

  1. Create a Slack bot for the application that will send events, and paste the Slack webhook URL there.
  2. Open the Slack bot and create an API Key. Store it in the calling app's secret configuration.
  3. Create an Event Definition inside the Slack bot with a stable key such as user_signup.
  4. Write a Scriban template using fields from the event payload.
  5. Leave the event-level custom webhook off unless this event should go to a different Slack destination.
  6. Use Send test from the Slack bot workspace to confirm Slack delivery.

3. Example event definition

Event key

user_signup

Template

New signup
Email: {{ email }}
Plan: {{ plan }}
Source: {{ source }}

4. Give this to your coding agent

Implement Slack Bridge event delivery in this app.

Use these configuration values:
- SlackBridge:BaseUrl = https://your-slack-bridge.example.com
- SlackBridge:ApiKey = sb_your_bot_key

Requirements:
- Create a small typed client named SlackBridgeClient.
- Send POST /api/events with the x-api-key header.
- Request body must be { "key": "...", "data": { ... } }.
- Keep the API key in secret configuration only.
- Do not call Slack directly from this app.
- Add a clear call site for the event I describe below.
- Log or surface non-success responses without swallowing failures.

5. Send an event from .NET

public sealed class SlackBridgeClient(HttpClient httpClient, IConfiguration configuration)
{
    public async Task SendAsync(string key, object data, CancellationToken cancellationToken = default)
    {
        using var request = new HttpRequestMessage(HttpMethod.Post, "/api/events");
        request.Headers.Add("x-api-key", configuration["SlackBridge:ApiKey"]);
        request.Content = JsonContent.Create(new
        {
            key,
            data
        });

        using var response = await httpClient.SendAsync(request, cancellationToken);
        response.EnsureSuccessStatusCode();
    }
}

Register the client in the calling app:

builder.Services.AddHttpClient<SlackBridgeClient>(client =>
{
    client.BaseAddress = new Uri(builder.Configuration["SlackBridge:BaseUrl"]!);
});

Call it from application code or a Razor Page handler:

await slackBridge.SendAsync("user_signup", new
{
    email = user.Email,
    plan = "pro",
    source = "signup-page"
}, cancellationToken);

6. Send an event from JavaScript

await fetch("https://your-slack-bridge.example.com/api/events", {
  method: "POST",
  headers: {
    "content-type": "application/json",
    "x-api-key": "sb_your_bot_key"
  },
  body: JSON.stringify({
    key: "user_signup",
    data: {
      email: "user@example.com",
      plan: "pro",
      source: "signup-page"
    }
  })
});

Troubleshooting

  • 401: missing, inactive, or incorrect API key.
  • 404: no active event definition matches the event key for that Slack bot.
  • 429: current plan usage limit has been reached.
  • 502: Slack delivery failed. Check the event log result, the Slack bot's webhook URL, and any enabled event-level override.
  • Use Logs to inspect payloads, rendered messages, Slack status codes, and retry state.