# Trigger action

URL: /code/project-structure/trigger-action · Id: `convention:trigger-action`

> A Trigger action is the code that runs when one Event fires, named for its Noun and Event.

A [Trigger](/business/nouns/trigger) action is the code that runs when one [Event](/business/nouns/event) fires, named for its [Noun](/business/nouns/noun) and Event.

| Property | Value |
| --- | --- |
| Path | `workflows/[process]/[workflow].ts` |
| Holds | [Trigger](/business/nouns/trigger) |
| Kind | file |
| Leaders | db-first, git-first |
| Team | [Engineering Team](/agents/engineering) |
| Written by | [Change.merge](/business/nouns/change/merge) |
| Compiled by | [StartupBuilder](/code/builders/startup) |

### Example
`workflows/close/open-on-activation.ts` in a Startup repository. Closewise, a sample business, declares a `Close` Noun.

```ts title="workflows/close/open-on-activation.ts"
on.Customer.activated(async (customer, $) => $.Close.create({ client: customer.$id, period: new Date().toISOString().slice(0, 7) }))

every.night(async ($) => {
  for await (const close of $.Close.list({ where: 'balanced = false' }).all()) await $.Close.reconcile({ close: close.$id, through: new Date().toISOString().slice(0, 10) })
})
```

### Signature
```ts
on.Noun.event(handler: (thing: Noun, $: $) => Promise<unknown>): Trigger
```

### Generates
[StartupBuilder](/code/builders/startup) compiles it into these records, Verbs and routes.

| Kind | What |
| --- | --- |
| Records | [Workflow](/business/nouns/workflow), [Trigger](/business/nouns/trigger), [Action](/business/nouns/action) |
| Verbs | None. |
| Routes | None. |