> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks

> Slack Bot incoming webhooks: event paths, payloads, and response data.

The Slack Bot plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see [Overview](https://docs.corsair.dev/plugins/slackbot/overview.md) for setup context and the exact URL shape).

> [!NOTE]
>
> **New to Corsair?** See [webhooks](https://docs.corsair.dev/concepts/webhooks.md) and [hooks](https://docs.corsair.dev/concepts/hooks.md).

## Webhook map

* `channels`
  * `created` (`channels.created`)
* `messages`
  * `botMessage` (`messages.botMessage`)
  * `directMessage` (`messages.directMessage`)
  * `groupDirectMessage` (`messages.groupDirectMessage`)
  * `message` (`messages.message`)
  * `privateChannelMessage` (`messages.privateChannelMessage`)
  * `threadReply` (`messages.threadReply`)
* `reactions`
  * `added` (`reactions.added`)
  * `removed` (`reactions.removed`)
* `setup`
  * `challenge` (`setup.challenge`)

## HTTP handler setup

```ts app/api/webhook/route.ts theme={null}
import { processWebhook } from "corsair";
import { corsair } from "@/server/corsair";

export async function POST(request: Request) {
    const headers = Object.fromEntries(request.headers);
    const body = await request.json();
    const result = await processWebhook(corsair, headers, body);
    return result.response;
}
```

## Events

## Channels

### Created

`channels.created`

A new channel created in the workspace

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `channel_created` | Yes | — |
| `channel` | `object` | Yes | — |
| `event_ts` | `string` | No | — |

> [accordion] channel full type
>
> ```ts theme={null}
> {
>   id: string,
>   name?: string,
>   created?: number,
>   creator?: string,
>   is_channel?: boolean,
>   is_private?: boolean
> }
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   type: channel_created,
>   channel: {
>     id: string,
>     name?: string,
>     created?: number,
>     creator?: string,
>     is_channel?: boolean,
>     is_private?: boolean
>   },
>   event_ts?: string
> }
> ```

**`webhookHooks` example**

```ts theme={null}
slackbot({
    webhookHooks: {
        channels: {
            created: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

## Messages

### Bot Message

`messages.botMessage`

A message posted by another bot or app

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `message` | Yes | — |
| `subtype` | `string` | No | — |
| `channel` | `string` | Yes | — |
| `channel_type` | `channel \| group \| im \| mpim` | No | — |
| `user` | `string` | No | — |
| `bot_id` | `string` | No | — |
| `app_id` | `string` | No | — |
| `bot_profile` | `Record<string, any>` | No | — |
| `text` | `string` | No | — |
| `ts` | `string` | Yes | — |
| `thread_ts` | `string` | No | — |
| `parent_user_id` | `string` | No | — |
| `team` | `string` | No | — |
| `event_ts` | `string` | No | — |
| `blocks` | `Record<string, any>[]` | No | — |
| `files` | `Record<string, any>[]` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   type: message,
>   subtype?: string,
>   channel: string,
>   channel_type?: channel | group | im | mpim,
>   user?: string,
>   bot_id?: string,
>   app_id?: string,
>   bot_profile?: Record<string, any>,
>   text?: string,
>   ts: string,
>   thread_ts?: string,
>   parent_user_id?: string,
>   team?: string,
>   event_ts?: string,
>   blocks?: Record<string, any>[],
>   files?: Record<string, any>[]
> }
> ```

**`webhookHooks` example**

```ts theme={null}
slackbot({
    webhookHooks: {
        messages: {
            botMessage: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Direct Message

`messages.directMessage`

A direct message sent to the bot

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `message` | Yes | — |
| `subtype` | `string` | No | — |
| `channel` | `string` | Yes | — |
| `channel_type` | `channel \| group \| im \| mpim` | No | — |
| `user` | `string` | No | — |
| `bot_id` | `string` | No | — |
| `app_id` | `string` | No | — |
| `bot_profile` | `Record<string, any>` | No | — |
| `text` | `string` | No | — |
| `ts` | `string` | Yes | — |
| `thread_ts` | `string` | No | — |
| `parent_user_id` | `string` | No | — |
| `team` | `string` | No | — |
| `event_ts` | `string` | No | — |
| `blocks` | `Record<string, any>[]` | No | — |
| `files` | `Record<string, any>[]` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   type: message,
>   subtype?: string,
>   channel: string,
>   channel_type?: channel | group | im | mpim,
>   user?: string,
>   bot_id?: string,
>   app_id?: string,
>   bot_profile?: Record<string, any>,
>   text?: string,
>   ts: string,
>   thread_ts?: string,
>   parent_user_id?: string,
>   team?: string,
>   event_ts?: string,
>   blocks?: Record<string, any>[],
>   files?: Record<string, any>[]
> }
> ```

**`webhookHooks` example**

```ts theme={null}
slackbot({
    webhookHooks: {
        messages: {
            directMessage: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Group Direct Message

`messages.groupDirectMessage`

A message in a multi-person direct message

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `message` | Yes | — |
| `subtype` | `string` | No | — |
| `channel` | `string` | Yes | — |
| `channel_type` | `channel \| group \| im \| mpim` | No | — |
| `user` | `string` | No | — |
| `bot_id` | `string` | No | — |
| `app_id` | `string` | No | — |
| `bot_profile` | `Record<string, any>` | No | — |
| `text` | `string` | No | — |
| `ts` | `string` | Yes | — |
| `thread_ts` | `string` | No | — |
| `parent_user_id` | `string` | No | — |
| `team` | `string` | No | — |
| `event_ts` | `string` | No | — |
| `blocks` | `Record<string, any>[]` | No | — |
| `files` | `Record<string, any>[]` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   type: message,
>   subtype?: string,
>   channel: string,
>   channel_type?: channel | group | im | mpim,
>   user?: string,
>   bot_id?: string,
>   app_id?: string,
>   bot_profile?: Record<string, any>,
>   text?: string,
>   ts: string,
>   thread_ts?: string,
>   parent_user_id?: string,
>   team?: string,
>   event_ts?: string,
>   blocks?: Record<string, any>[],
>   files?: Record<string, any>[]
> }
> ```

**`webhookHooks` example**

```ts theme={null}
slackbot({
    webhookHooks: {
        messages: {
            groupDirectMessage: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Message

`messages.message`

A message posted by a person in a public channel

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `message` | Yes | — |
| `subtype` | `string` | No | — |
| `channel` | `string` | Yes | — |
| `channel_type` | `channel \| group \| im \| mpim` | No | — |
| `user` | `string` | No | — |
| `bot_id` | `string` | No | — |
| `app_id` | `string` | No | — |
| `bot_profile` | `Record<string, any>` | No | — |
| `text` | `string` | No | — |
| `ts` | `string` | Yes | — |
| `thread_ts` | `string` | No | — |
| `parent_user_id` | `string` | No | — |
| `team` | `string` | No | — |
| `event_ts` | `string` | No | — |
| `blocks` | `Record<string, any>[]` | No | — |
| `files` | `Record<string, any>[]` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   type: message,
>   subtype?: string,
>   channel: string,
>   channel_type?: channel | group | im | mpim,
>   user?: string,
>   bot_id?: string,
>   app_id?: string,
>   bot_profile?: Record<string, any>,
>   text?: string,
>   ts: string,
>   thread_ts?: string,
>   parent_user_id?: string,
>   team?: string,
>   event_ts?: string,
>   blocks?: Record<string, any>[],
>   files?: Record<string, any>[]
> }
> ```

**`webhookHooks` example**

```ts theme={null}
slackbot({
    webhookHooks: {
        messages: {
            message: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Private Channel Message

`messages.privateChannelMessage`

A message posted by a person in a private channel

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `message` | Yes | — |
| `subtype` | `string` | No | — |
| `channel` | `string` | Yes | — |
| `channel_type` | `channel \| group \| im \| mpim` | No | — |
| `user` | `string` | No | — |
| `bot_id` | `string` | No | — |
| `app_id` | `string` | No | — |
| `bot_profile` | `Record<string, any>` | No | — |
| `text` | `string` | No | — |
| `ts` | `string` | Yes | — |
| `thread_ts` | `string` | No | — |
| `parent_user_id` | `string` | No | — |
| `team` | `string` | No | — |
| `event_ts` | `string` | No | — |
| `blocks` | `Record<string, any>[]` | No | — |
| `files` | `Record<string, any>[]` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   type: message,
>   subtype?: string,
>   channel: string,
>   channel_type?: channel | group | im | mpim,
>   user?: string,
>   bot_id?: string,
>   app_id?: string,
>   bot_profile?: Record<string, any>,
>   text?: string,
>   ts: string,
>   thread_ts?: string,
>   parent_user_id?: string,
>   team?: string,
>   event_ts?: string,
>   blocks?: Record<string, any>[],
>   files?: Record<string, any>[]
> }
> ```

**`webhookHooks` example**

```ts theme={null}
slackbot({
    webhookHooks: {
        messages: {
            privateChannelMessage: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Thread Reply

`messages.threadReply`

A reply posted inside a message thread

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `message` | Yes | — |
| `subtype` | `string` | No | — |
| `channel` | `string` | Yes | — |
| `channel_type` | `channel \| group \| im \| mpim` | No | — |
| `user` | `string` | No | — |
| `bot_id` | `string` | No | — |
| `app_id` | `string` | No | — |
| `bot_profile` | `Record<string, any>` | No | — |
| `text` | `string` | No | — |
| `ts` | `string` | Yes | — |
| `thread_ts` | `string` | No | — |
| `parent_user_id` | `string` | No | — |
| `team` | `string` | No | — |
| `event_ts` | `string` | No | — |
| `blocks` | `Record<string, any>[]` | No | — |
| `files` | `Record<string, any>[]` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   type: message,
>   subtype?: string,
>   channel: string,
>   channel_type?: channel | group | im | mpim,
>   user?: string,
>   bot_id?: string,
>   app_id?: string,
>   bot_profile?: Record<string, any>,
>   text?: string,
>   ts: string,
>   thread_ts?: string,
>   parent_user_id?: string,
>   team?: string,
>   event_ts?: string,
>   blocks?: Record<string, any>[],
>   files?: Record<string, any>[]
> }
> ```

**`webhookHooks` example**

```ts theme={null}
slackbot({
    webhookHooks: {
        messages: {
            threadReply: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

## Reactions

### Added

`reactions.added`

An emoji reaction added to a message or file

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `reaction_added` | Yes | — |
| `user` | `string` | Yes | — |
| `reaction` | `string` | Yes | — |
| `item_user` | `string` | No | — |
| `item` | `object` | Yes | — |
| `event_ts` | `string` | No | — |

> [accordion] item full type
>
> ```ts theme={null}
> {
>   type: string,
>   channel?: string,
>   ts?: string,
>   file?: string
> }
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   type: reaction_added,
>   user: string,
>   reaction: string,
>   item_user?: string,
>   item: {
>     type: string,
>     channel?: string,
>     ts?: string,
>     file?: string
>   },
>   event_ts?: string
> }
> ```

**`webhookHooks` example**

```ts theme={null}
slackbot({
    webhookHooks: {
        reactions: {
            added: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Removed

`reactions.removed`

An emoji reaction removed from a message or file

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `reaction_removed` | Yes | — |
| `user` | `string` | Yes | — |
| `reaction` | `string` | Yes | — |
| `item_user` | `string` | No | — |
| `item` | `object` | Yes | — |
| `event_ts` | `string` | No | — |

> [accordion] item full type
>
> ```ts theme={null}
> {
>   type: string,
>   channel?: string,
>   ts?: string,
>   file?: string
> }
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   type: reaction_removed,
>   user: string,
>   reaction: string,
>   item_user?: string,
>   item: {
>     type: string,
>     channel?: string,
>     ts?: string,
>     file?: string
>   },
>   event_ts?: string
> }
> ```

**`webhookHooks` example**

```ts theme={null}
slackbot({
    webhookHooks: {
        reactions: {
            removed: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

## Setup

### Challenge

`setup.challenge`

Slack Events API URL verification handshake

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `url_verification` | Yes | — |
| `token` | `string` | No | — |
| `challenge` | `string` | Yes | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   type: url_verification,
>   challenge: string
> }
> ```

**`webhookHooks` example**

```ts theme={null}
slackbot({
    webhookHooks: {
        setup: {
            challenge: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.