FSM key: {chat_id, thread_id}.
Scopes FSM state per forum topic, shared by all users in that topic. This is useful for Telegram groups with Topics (forum mode) enabled, where you want each topic to carry its own independent conversation flow.
Key shape
| Update type | Key |
|---|---|
| Message in a forum topic | {chat_id, thread_id} |
| Message outside a topic | {chat_id, 0} — 0 is a sentinel for no-topic context |
| 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