Testing

In Development

Testing your endpoint and handlers locally, you need to turn off Slack Request Verification (opens in a new tab) (on by default):

app.UseSlackbot(enableAuth:!app.Environment.IsDevelopment());

Then, post a payload to the Slack callback endpoint:

test.http
POST http://localhost:1337/slack/event
 
{
  "event": {
    "type": "app_mention",
    "text" : "<@BOT123> execute handlerOne, please!",
  }
}

This 👆 test payload is a stripped down version of the full payload, to only include fields that are of interest to your handler.

For reference, the full payload as provided by Slack looks more like this (opens in a new tab) – here including the Slack Verification Headers.

The most relevant bits is found in the event parameter:

POST http://localhost:1337/slack/event
X-Slack-Request-Timestamp: 12331231
X-Slack-Signature: v0:abc123etcetc
 
{
  "type": "event_callback",
  "token": "XXYYZZ",
  "team_id": "T123ABC456",
  "api_app_id": "A123ABC456",
  "event": {
    "type": "name_of_event",
    "event_ts": "1234567890.123456",
    "user": "U123ABC456",
    ...
  },
  "event_context": "EC123ABC456",
  "event_id": "Ev123ABC456",
  "event_time": 1234567890,
  "authorizations": [{
      "enterprise_id": "E123ABC456",
      "team_id": "T123ABC456",
      "user_id": "U123ABC456",
      "is_bot": false,
      "is_enterprise_install": false,
  }],
  "is_ext_shared_channel": false,
  "context_team_id": "T123ABC456",
  "context_enterprise_id": null
}