# Automation Events Reference

> The event shapes that entry stages get in Type.com automations: Slack, GitHub, and Linear events, event source events, and resource filters.

Canonical page: https://docs.type.com/automations/reference/events/

The entry stage of a subscription gets the event as its `input`. This page describes those events. Later stages get the input that the stage before them passes with `next()`.

| Source | Entry stage `input` |
| --- | --- |
| Recurring | [`RecurringEvent`](#recurringevent) |
| Integration or event source with a `schema` | `z.output<typeof schema>` |
| Integration or event source without a `schema` | The [default contract](#default-contracts) of the subscription |
| Any integration or event source with `debounce.delivery: "batch"` | An array of 1 to 100 of the events above, in the order that Type received them |

The entry stage's `input` schema must accept this event. The typecheck checks it when you deploy. Use the same schema for the subscription's `schema` and the entry stage's `input`.

## `RecurringEvent`

```ts
interface RecurringEvent {
  readonly scheduledAt: string; // ISO date-time
}
```

Use `recurringEventSchema` as the entry stage's `input`. `scheduledAt` is the time from Type's scheduler, not the time that the run started. Use it in effect keys, for example `report:${input.scheduledAt}`, so that a retry of the same tick uses the same key.

## `IntegrationEvent`

Every integration event and event source event has this envelope:

```ts
interface IntegrationEvent<Data = unknown> {
  type: string; // one of source.events
  id: string; // the delivery ID
  resourceId: string | null;
  resourceType: string | null;
  data: Data; // the provider's fields
}
```

- `id` stays the same when a provider sends the same event again. Type uses it to run each event one time for each subscription.
- Provider fields are always under `data`, not at the top level.
- Without a `schema`, Type.com does not check the fields in `data`. Parse them in the stage, or give a `schema`.

## Default contracts

If a subscription has no `schema`, Type.com picks its contract from `source.events` and `match`. The typecheck uses the event type, and Type saves the schema to check each event:

| Subscription | Event type | Schema that Type saves |
| --- | --- | --- |
| `events: ["message"]` with a `slack.message` matcher | [`SlackMessageEvent`](#slackmessageevent), with a required `data.ts` | `slackMessageEventSchema`, with `data.ts` required |
| The same, with `"message_deleted"` in the matcher's `subtypes` | `SlackMessageEvent` | `slackMessageEventSchema` |
| `events: ["app_mention"]` with a `slack.app_mention` matcher | [`SlackAppMentionEvent`](#slackappmentionevent) | `slackAppMentionEventSchema` |
| `events: ["reaction_added"]` with a `slack.reaction_added` matcher | [`SlackReactionAddedEvent`](#slack-reaction-events) | `slackReactionAddedEventSchema` |
| `events: ["reaction_removed"]` with a `slack.reaction_removed` matcher | [`SlackReactionRemovedEvent`](#slack-reaction-events) | `slackReactionRemovedEventSchema` |
| Anything else | [`IntegrationEvent`](#integrationevent), with `type` set to one of `events` | One envelope for each event. `data` is not checked. |

- Use the matcher keys in this table. Other forms of the Slack matchers can give a different contract.
- A Slack `message` subscription without a `slack.message` matcher gets the plain `IntegrationEvent` envelope, so an entry stage with `input: slackMessageEventSchema` fails the typecheck. Set `schema: slackMessageEventSchema` in that case.
- See [Event schema](https://docs.type.com/automations/reference/deployment/index.md#event-schema) for the rules of your own schema.

## `SlackMessageEvent`

```ts
type SlackMessageEvent = {
  type: "message";
  id: string;
  resourceId: string | null; // the channel ID
  resourceType: string | null; // "channel"
  data: {
    channel: string;
    ts: string; // can be missing when subtype is "message_deleted"
    thread_ts?: string | null;
    user?: string | null;
    text?: string | null;
    subtype?: string | null;
    bot_id?: string | null;
    deleted_ts?: string; // set when subtype is "message_deleted"
    // other Slack fields are kept
  };
};
```

If the matcher selects the `message_deleted` subtype, `data.ts` can be missing and `data.deleted_ts` is present. Otherwise the default contract requires `data.ts`.

## `SlackAppMentionEvent`

```ts
type SlackAppMentionEvent = {
  type: "app_mention";
  id: string;
  resourceId: string | null; // the channel ID
  resourceType: string | null; // "channel"
  data: {
    channel: string;
    ts: string;
    thread_ts?: string | null;
    user?: string | null;
    text?: string | null;
    subtype?: string | null;
    bot_id?: string | null;
    // other Slack fields are kept
  };
};
```

## Slack reaction events

```ts
type SlackReactionAddedEvent = {
  type: "reaction_added"; // "reaction_removed" in SlackReactionRemovedEvent
  id: string;
  resourceId: string | null; // the channel of the message
  resourceType: string | null; // "channel"
  data: {
    user: string; // who reacted
    reaction: string; // the emoji name, without colons
    item_user?: string | null; // the author of the message
    event_ts?: string;
    item: { type: string; channel?: string; ts?: string };
    // other Slack fields are kept
  };
};
```

## Slack events

Slack events use the Slack connection. Type receives them for you.

| Event | Starts when |
| --- | --- |
| `message` | Someone posts, edits, or deletes a message in a channel that the Type app is in. |
| `app_mention` | Someone mentions the Type app. |
| `reaction_added` | Someone adds an emoji reaction. |
| `reaction_removed` | Someone removes an emoji reaction. |
| `app_home_opened` | Someone opens the Type app's Home tab. |

| Envelope field | Value |
| --- | --- |
| `type` | The Slack event type. |
| `id` | Slack's `event_id`. |
| `resourceType` | `"channel"` when the event has a channel, otherwise `null`. |
| `resourceId` | The channel ID. For reactions, the channel of the message. Otherwise `null`. |
| `data` | The Slack event object, unchanged. |

> **Note:** Type.com always drops messages and mentions that Type itself posted. Your code never gets them. This stops loops.

- Slack event names must match exactly. Slack has no wildcard.
- The Type Slack app must be in the channel, and the app must be subscribed to the event.
- Use the [Slack matchers](https://docs.type.com/automations/reference/matchers/index.md#slackmessage) to filter events before your code runs.
- Use [`replyInSlackThread`](https://docs.type.com/automations/reference/sdk/index.md#helpers) to reply to a message or a mention.

## GitHub events

GitHub events use the GitHub connection. Type receives them for you. Event names have the form `github.<event>.<action>`. `github.*` selects every GitHub event that Type receives.

| Event name | Examples | `resourceType` / `resourceId` | Fields in `data` |
| --- | --- | --- | --- |
| `github.pull_request.<action>` | `github.pull_request.opened`, `github.pull_request.closed` | `pull_request` / PR number | `title`, `url`, `state`, `merged`, `body`, `draft`, `baseBranch`, `headBranch`, `author` |
| `github.push` | — | `commit` / the new commit SHA | `ref`, `branch`, `commits`, `pusher` |
| `github.create.branch`, `github.create.tag` | — | `branch` or `tag` / the ref | `ref`, `refType` |
| `github.delete.branch`, `github.delete.tag` | — | `branch` or `tag` / the ref | `ref`, `refType` |
| `github.issues.<action>` | `github.issues.opened` | `issue` / issue number | `title`, `body`, `url`, `state`, `author` |
| `github.issue_comment.<action>` | `github.issue_comment.created` | `pr_comment` on a pull request, otherwise `issue_comment` / comment ID | `isPullRequest`, `issueNumber`, `prNumber`, `commentBody`, `url`, `author` |
| `github.pull_request_review.<action>` | `github.pull_request_review.submitted` | `pr_review` / review ID | `prNumber`, `state`, `body`, `author`, `url` |
| `github.pull_request_review_comment.<action>` | `github.pull_request_review_comment.created` | `pr_comment` / comment ID | `prNumber`, `commentBody`, `author`, `url`, `path` |
| `github.release.<action>` | `github.release.published` | `release` / release ID | `tagName`, `name`, `url`, `draft`, `prerelease` |
| `github.workflow_run.<action>` | `github.workflow_run.completed` | `workflow_run` / run ID | `name`, `branch`, `status`, `conclusion`, `headSha`, `url` |
| `github.check_run.<action>` | `github.check_run.completed` | `check_run` / run ID | `name`, `branch`, `status`, `conclusion`, `headSha`, `url` |
| `github.check_suite.<action>` | `github.check_suite.completed` | `check_suite` / suite ID | `name`, `branch`, `status`, `conclusion`, `headSha`, `url` |
| `github.status` | — | `commit` / the SHA | `state`, `context`, `description`, `url` |

- All GitHub events also have `repositoryFullName`, `repositoryId`, and `sender` in `data` when GitHub sends them.
- `resourceId` is a string, also for numbers such as a PR number.
- `id` is GitHub's delivery ID.
- `<action>` is GitHub's `action` value, for example `opened`, `closed`, `created`, or `completed`. Type does not check it against a list. Use the names in GitHub's webhook documentation.
- A general comment on a pull request is an `issue_comment` event. An inline comment on a diff is a `pull_request_review_comment` event.
- Type does not send these GitHub events to automations: `deployment`, `deployment_status`, `pull_request_review_thread`, `label`, and `member`.
- The GitHub App of the connection must have the permission and the event subscription for each event. Saving an automation does not change the GitHub App settings.

Use the [GitHub matchers](https://docs.type.com/automations/reference/matchers/index.md#github-matchers) to filter by repository, branch, action, and more.

## Linear events

Linear events use the Linear connection. Type receives them for you. Event names have the form `linear.<type>.<action>`, for example `linear.issue.create` or `linear.comment.update`. `linear.*` selects every Linear event that Type receives.

| `<type>` | `resourceType` |
| --- | --- |
| `issue` | `issue` |
| `comment` | `comment` |
| `project` | `project` |
| `project_update` | `project_update` |
| `cycle` | `cycle` |
| `reaction` | `reaction` |
| `label` | `label` |

- Issue label events arrive as `linear.label.<action>`. Only `linear.*` selects them. A deploy does not accept `linear.label.<action>` as an event name.
- `<action>` is Linear's `action` value, for example `create`, `update`, or `remove`.
- `resourceId` is the ID of the Linear object. `data` has the fields that Type keeps from the object.
- `id` is the `webhook-id` header, or the `event_id`, `delivery_id`, or `id` field of the body. Without these, it is a hash of the request body.
- There are no built-in Linear matchers and no Linear resource filters. Filter in the entry stage.
- See [Linear](https://docs.type.com/automations/linear/index.md).

## Custom webhook events

A [webhook adapter](https://docs.type.com/automations/reference/webhook-adapters/index.md) makes these events. The adapter sets `type`, `id`, `resourceType`, `resourceId`, and `data`. The subscription `events` must be a subset of the events that the adapter declares.

## Event source events

An [event source](https://docs.type.com/automations/reference/deployment/index.md#event-source) sends one kind of event:

| Source | `type` | `resourceType` / `resourceId` | `id` | `data` |
| --- | --- | --- | --- | --- |
| Custom webhook URL | `webhook.received` | `webhook` / the webhook ID | The delivery ID. See [The event](https://docs.type.com/automations/webhooks/index.md#the-event). | The JSON body of a `POST`, or the query parameters of a `GET` |
| RSS feed | `rss.entry.received` | `rss_entry` / the entry GUID | The entry GUID | `{ feedTitle, feedUrl, item: { guid, title, description, link, pubDate, author } }` |
| Email inbox | `agentmail.message.received` | `email_message` / the message ID | The message ID | `{ inboxId, threadId, from, to, subject, text, html, timestamp }` |

Event sources have no built-in matchers and no resource filters.

## Resource filters

The `resources` field of an integration source filters events by `resourceType` and `resourceId`. The behavior is different for each kind of source.

| Source | Behavior |
| --- | --- |
| Slack | The only key is `channel`. An event with no channel, or with a channel that is not in the list, is skipped. |
| GitHub | Allowed keys: `pull_request`, `commit`, `branch`, `tag`, `issue`, `release`, `issue_comment`, `pr_comment`, `pr_review`, `workflow_run`, `check_run`, `check_suite`, `github_event`. A filter applies only to events with the same `resourceType`. Events with a different `resourceType` pass. |
| Linear | Not supported. The deploy fails if `resources` has a key. |
| Custom webhook | If `resources` has keys, the event must have a `resourceType` that is a key, and its `resourceId` must be in the list. Other events are skipped. |

> **Caution:** A GitHub resource filter does not filter by repository. To select repositories, use the `repositories` option of a [GitHub matcher](https://docs.type.com/automations/reference/matchers/index.md#github-matchers).

## Delivery guarantees

- Type saves each verified event before it starts work.
- A provider retry with the same `id` does not start a second run for the same subscription, also after you deploy new code.
- Type runs one code stage at a time for each automation. Other events wait in a queue. Type does not promise that runs start in the order that the provider sent the events.
- Events that come while an automation is paused are not saved for it. Resume does not replay them.
- Events that Type saved before the pause, for example events in a debounce group, wait. They run after you resume, if the current code still subscribes to their event type.
- A subscription that you add later does not get older events.
- A provider event can come late or not at all. If your workflow cannot miss an item, add a [recurring check](https://docs.type.com/automations/scheduled-automations/index.md) that reads the source.
