# Trigger Node

## What is a trigger node?

A **trigger node** is a node that executes automatically when a specific event occurs in a channel or group, rather than in response to a user command.

Use cases:
- Welcoming new channel or group members.
- Responding to specific messages or keywords in a group.
- Processing reactions to posts.
- Sending a notification when a message is edited.

## Adding a trigger

1. Click the **flag icon** on the canvas to add a trigger.
2. Select the **event type** in the node settings.
3. Specify the **source** — a specific channel or group (or "any").
4. Add the blocks the bot should execute when the trigger fires.
5. Publish the scenario.

## Event types

| Event | Description |
|---|---|
| **New member** | User joined a group or channel |
| **Member left** | User left a group |
| **New message** | New message sent to a group |
| **Message edited** | Message was edited |
| **New channel post** | Post published in a channel |
| **Post edited** | Channel post edited |
| **Message reaction** | User added a reaction |
| **Reaction removed** | Reaction removed |
| **Message pinned** | Message pinned in a group |
| **Poll created** | Telegram poll added to a group |
| **Member promoted/demoted** | Member status changed (admin/member) |

## Payload variables

When a trigger fires, information about the event is automatically recorded in variables. The set of variables depends on the event type.

**For the "New Member" event:**

| Variable | Value |
|---|---|
| `{{payload.user_id}}` | New member's ID |
| `{{payload.username}}` | Username (if available) |
| `{{payload.first_name}}` | First name |
| `{{payload.chat_id}}` | Group/channel ID |

**For the "New Message" event:**

| Variable | Value |
|---|---|
| `{{payload.text}}` | Message text |
| `{{payload.from_id}}` | Sender's ID |
| `{{payload.from_username}}` | Sender's username |
| `{{payload.message_id}}` | Message ID |

> The full list of variables for each event type is displayed directly within the trigger editor.

## Trigger statistics

A counter appears on the trigger node card on the canvas, showing how many times the trigger has fired. This helps track activity and identify popular events.

## Tips

- Use a "Condition" block after the trigger to filter events (e.g., to react only to messages containing a specific word).
- Add a short delay of a few seconds when greeting new members; it makes the interaction feel more natural.
- Ensure the bot is an administrator of the group or channel; events will not be received without administrator privileges.
- To read messages in groups, the bot's privacy mode must be disabled via @BotFather > Your Bot > Bot Settings > Group privacy > Turn off.
