FSM key: {chat_id, thread_id, user_id}.
Scopes FSM state per-user per forum topic. This is the most granular scoping available for Telegram groups with Topics (forum mode) enabled.
Each user gets their own independent FSM state within each forum topic, while different topics remain completely isolated.
Key shape
| Update type | Key |
|---|---|
| Message in a forum topic | {chat_id, thread_id, user_id} |
| Message outside a topic | {chat_id, 0, user_id} — 0 is a sentinel for no-topic context |
| Channel post (no user) | :error — FSM state is skipped |
| Inline query (no chat) | :error — FSM state is skipped |
Accessing thread_id
The message_thread_id field is read from:
update.message.message_thread_id— for regular messagesupdate.callback_query.message.message_thread_id— for callback queries