> ## Documentation Index
> Fetch the complete documentation index at: https://botmesh.afaya.com.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Trigger

> Type alias exported by @botmesh/core.

```ts theme={null}
type Trigger = 
  | string
  | RegExp
  | (string | RegExp)[]
  | TriggerObject
  | ((ctx) => boolean)
  | TypeTrigger
  | WelcomeTrigger;
```

Defined in: [core/types.ts:476](https://github.com/andresayac/botmesh/blob/main/packages/core/src/core/types.ts#L476)

What `bot.when()` and `flow()` match: a text (normalized equality), a `RegExp`
(tested against the raw body), a list of them, a [TriggerObject](https://botmesh.afaya.com.co/api/core/interfaces/TriggerObject.md), a predicate, a type
trigger (`IMAGE`, `CALL`…) or `WELCOME`.

## Union Members

`string`

***

`RegExp`

***

(`string` | `RegExp`)\[]

***

[`TriggerObject`](https://botmesh.afaya.com.co/api/core/interfaces/TriggerObject)

***

### Function

```ts theme={null}
(ctx) => boolean
```

***

[`TypeTrigger`](https://botmesh.afaya.com.co/api/core/interfaces/TypeTrigger)

`IMAGE`, `MEDIA`, `CALL`, … or `typeTrigger(...)` — see `core/triggers.ts`.

***

[`WelcomeTrigger`](https://botmesh.afaya.com.co/api/core/interfaces/WelcomeTrigger)

The first-contact `WELCOME` trigger — see `core/triggers.ts`.

## Example

```ts theme={null}
bot.when('menu', showMenu) // "Menu" and "MENÚ " match too
bot.when(/^order\s+\d+$/i, showOrder)
bot.when(['hi', 'hello'], greet)
bot.when(IMAGE, (ctx) => ctx.reply('Nice picture!'))
```


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