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

# Events

> Emit events from your integration to notify bots of external changes

Events notify bots when something happens in the external platform.

## Define events

```typescript integration.definition.ts theme={null}
export default new IntegrationDefinition({
  events: {
    messageReceived: {
      title: 'Message Received',
      description: 'Triggered when a message is received',
      schema: z.object({
        userId: z.string(),
        text: z.string(),
        timestamp: z.string(),
      }),
    },
  },
})
```

## Emit events

```typescript src/index.ts theme={null}
const integration = new bp.Integration({
  handler: async ({ req, client }) => {
    const event = req.body
    
    await client.createEvent({
      type: 'messageReceived',
      payload: {
        userId: event.user_id,
        text: event.text,
        timestamp: new Date().toISOString(),
      },
    })
    
    return { status: 200 }
  },
  // ...
})
```
